Carlos Aguni

Highly motivated self-taught IT analyst. Always learning and ready to explore new skills. An eternal apprentice.


Edgerouter SNMP_Exporter

05 Oct 2021 »

https://grafana.com/docs/grafana-cloud/metrics-prometheus/

prometheus.yml


scrape_configs:
  - job_name: 'snmp'
    scrape_interval: 15s
    static_configs:
      - targets:
        - 127.0.0.1:9116
    metrics_path: /snmp
    params:
      module: [edgerouter]
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance 
      - target_label: __param_target
        replacement: 192.168.100.1

global:
  external_labels:
    origin_prometheus: prometheus01

remote_write:
  - url: https://prometheus-prod-10-prod-us-central-0.grafana.net/api/prom/push
    basic_auth:
      username: <username>
      password: eyJrIjoiN2Y2ZjUyN2ZiZTA0YzU1ZWI5YmY4NDI4NmViYzlhZDFhZmI3YTBiNSI

Prometheus remote_write

global:
  external_labels:
    origin_prometheus: prometheus01
remote_write:
- url: <Your Metrics instance remote_write endpoint>
  basic_auth:
    username: <Your Metrics instance ID>
    password: <Your Grafana.com API Key>

EdgeRouter

https://grafana.com/grafana/dashboards/7963

SNMP Interface Throughput (Ubiquiti EdgeMax-16-XG)

https://grafana.com/grafana/dashboards/8570

Build SNMP Generator

https://github.com/prometheus/snmp_exporter/tree/main/generator

# Redhat-based distributions.
sudo yum install gcc gcc-g++ make net-snmp net-snmp-utils net-snmp-libs net-snmp-devel # RHEL-based distros

go get github.com/prometheus/snmp_exporter/generator
cd ${GOPATH-$HOME/go}/src/github.com/prometheus/snmp_exporter/generator
go build
make mibs
export MIBDIRS=mibs
./generator generate

https://github.com/j18e/prometheus-edgerouter

generator.yml

modules:
  edgerouter:
    auth:
      community: public
    walk:
    - memTotalReal
    - memAvailReal
    - ssCpuRawIdle
    # host resource metrics
    - hrSystemUptime
    - hrSystemProcesses
    - hrSystemMaxProcesses
    - hrMemorySize
    - hrStorageSize
    - hrStorageUsed
    - hrProcessorLoad # non idle percent past minute
    # interface metrics
    - ifAdminStatus # 1=up,2=down,3=testing
    - ifOperStatus # 1=up,2=down,3=testing,4=unknown,5=dormant,6=notPresent,7=lowerLayerDown
    - ifLastChange
    - ifInDiscards
    - ifInErrors
    - ifOutDiscards
    - ifOutErrors
    - ifHCInOctets
    - ifHCOutOctets
    # tcp metrics
    - tcpMaxConn
    - tcpActiveOpens
    - tcpPassiveOpens
    - tcpEstabResets
    - tcpCurrEstab
  #version: 1
    #lookups:
    #- old_index: ifIndex
    #  new_index: ifName
    lookups:
      - source_indexes: [ifIndex]
        lookup: ifName

Download Install SNMP_Exporter

https://github.com/prometheus/snmp_exporter/releases/download/v0.20.0/snmp_exporter-0.20.0.linux-amd64.tar.gz

snmpwalk

edgemax enable snmp export

configure
edit service snmp
set community public client 192.168.100.52
set community public authorization ro
set listen-address 192.168.100.1 port 161
commit

get mibs folder
scp -r /usr/share/snmp/mibs ...