Categorygithub.com/megadata-dev/go-snmp-olt-zte-c320

# README

Monitoring OLT ZTE C320 with SNMP

build Go Report Card codecov

Service for integration into the C320 OLT with the Go programming language

👨‍💻 Full list what has been used:

  • Go - Programming language
  • Chi - HTTP Server
  • GoSNMP - SNMP library for Go
  • Redis - Redis client for Go
  • Zerolog - Logger
  • Viper - Configuration management
  • Docker - Containerization
  • Task - Task runner
  • Air - Live reload for Go apps

Note : This service is still in development ⚠️👨‍💻👩‍💻

Getting Started 🚀

👨‍💻Recommendation for local development most comfortable usage:

task dev

Docker development usage:

task up
docker-compose -f docker-compose.local.yaml up -d && air -c .air.toml

Production usage with internal redis in docker:

task docker-run
docker network create local-dev && \
docker run -d --name redis-container \
--network local-dev -p 6379:6379 redis:7.2 && \
docker run -d -p 8081:8081 --name go-snmp-olt-zte-c320 \
--network local-dev -e REDIS_HOST=redis-container \
-e REDIS_PORT=6379 -e REDIS_DB=0 \
-e REDIS_MIN_IDLE_CONNECTIONS=200 -e REDIS_POOL_SIZE=12000 \
-e REDIS_POOL_TIMEOUT=240 -e SNMP_HOST=192.168.213.174 \
-e SNMP_PORT=161 -e SNMP_COMMUNITY=homenetro \
sumitroajiprabowo/go-snmp-olt-zte-c320:latest

Production usage without external redis:

docker run -d -p 8081:8081 --name go-snmp-olt-zte-c320 \
-e REDIS_HOST=redis_host \
-e REDIS_PORT=redis_port \
-e REDIS_DB=redis_db \
-e REDIS_MIN_IDLE_CONNECTIONS=redis_min_idle_connection \
-e REDIS_POOL_SIZE=redis_pool_size \
-e REDIS_POOL_TIMEOUT=redis_pool_timeout \
-e SNMP_HOST=snmp_host \
-e SNMP_PORT=snmp_port \
-e SNMP_COMMUNITY=snmp_community \
sumitroajiprabowo/go-snmp-olt-zte-c320:latest

Available tasks for this project:

SyntaxDescription
initInitialize the environment
devStart the local development
app-buildBuild the app binary
build-imageBuild docker image with tag latest
push-imagepush docker image with tag latest
pull-imagepull docker image with tag latest
docker-runRun the docker container image with tag latest
docker-stopStop the docker container
docker-removeRemove the docker container
upStart the docker containers in the background
up-rebuildRebuild the docker containers
downStop and remove the docker containers
restartRestart the docker containers
rebuildRebuild the docker image and up with detached mode
tidyClean up dependencies

Test with curl GET method Board 2 Pon 7

curl -sS localhost:8081/api/v1/board/2/pon/7 | jq

Result

{
  "code": 200,
  "status": "OK",
  "data": [
    {
      "board": 2,
      "pon": 7,
      "onu_id": 3,
      "name": "Siti Khotimah",
      "onu_type": "F670LV7.1",
      "serial_number": "ZTEGCE3E0FFF",
      "rx_power": "-22.22",
      "status": "Online"
    },
    {
      "board": 2,
      "pon": 7,
      "onu_id": 4,
      "name": "Isroh",
      "onu_type": "F670LV7.1",
      "serial_number": "ZTEGCEEA1119",
      "rx_power": "-21.08",
      "status": "Online"
    },
    {
      "board": 2,
      "pon": 7,
      "onu_id": 5,
      "name": "Hadi Susilo",
      "onu_type": "F670LV7.1",
      "serial_number": "ZTEGCEC3033C",
      "rx_power": "-19.956",
      "status": "Online"
    }
  ]
}

Test with curl GET method Board 2 Pon 7 Onu 4

 curl -sS localhost:8081/api/v1/board/2/pon/7/onu/4 | jq

Result

{
  "code": 200,
  "status": "OK",
  "data": {
    "board": 2,
    "pon": 7,
    "onu_id": 4,
    "name": "Isroh",
    "description": "Bale Agung",
    "onu_type": "F670LV7.1",
    "serial_number": "ZTEGCEEA1119",
    "rx_power": "-21.08",
    "tx_power": "2.5340000000000007",
    "status": "Online",
    "ip_address": "10.90.1.214"
  }
}

Test with curl GET method Get Empty ONU_ID in Board 2 Pon 5

curl -sS localhost:8081/api/v1/board/2/pon/5/onu_id/empty | jq

Result

{
  "code": 200,
  "status": "OK",
  "data": [
    {
      "board": 2,
      "pon": 5,
      "onu_id": 123
    },
    {
      "board": 2,
      "pon": 5,
      "onu_id": 124
    },
    {
      "board": 2,
      "pon": 5,
      "onu_id": 125
    },
    {
      "board": 2,
      "pon": 5,
      "onu_id": 126
    }
  ]
}

Test with curl GET method Get Empty ONU_ID After Add ONU in Board 2 Pon 5

curl -sS localhost:8081/api/v1/board/2/pon/5/onu_id/update | jq
{
  "code": 200,
  "status": "OK",
  "data": "Success Update Empty ONU_ID"
}

Test with curl GET method Get Onu Information in Board 2 Pon 8 with paginate

curl -sS 'http://localhost:8081/api/v1/paginate/board/2/pon/8?limit=3&page=2' | jq

Result

{
  "code": 200,
  "status": "OK",
  "page": 2,
  "limit": 3,
  "page_count": 23,
  "total_rows": 69,
  "data": [
    {
      "board": 2,
      "pon": 8,
      "onu_id": 4,
      "name": "Arif Irwan Setiawan",
      "onu_type": "F670LV7.1",
      "serial_number": "ZTEGC5A27AE1",
      "rx_power": "-19.17",
      "status": "Online"
    },
    {
      "board": 2,
      "pon": 8,
      "onu_id": 5,
      "name": "Putra Chandra Agusta",
      "onu_type": "F660V6.0",
      "serial_number": "ZTEGD00E4BCC",
      "rx_power": "-19.54",
      "status": "Online"
    },
    {
      "board": 2,
      "pon": 8,
      "onu_id": 6,
      "name": "Tarjito",
      "onu_type": "F670LV7.1",
      "serial_number": "ZTEGC5A062E0",
      "rx_power": "-21.81",
      "status": "Online"
    }
  ]
}

Description of Paginate

SyntaxDescription
pagePage number
limitLimit data per page
page_countTotal page
total_rowsTotal rows
dataData of onu

Default paginate

var (
	DefaultPageSize = 10 // default page size
	MaxPageSize     = 100 // max page size
	PageVar         = "page"
	PageSizeVar     = "limit"
)

LICENSE

MIT License

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author