SNMP monitoring and easing it with Prometheus.

How it works:

tar xvfz prometheus-*.tar.gz
cd prometheus-*
./snmp_exporter

Due to the dynamic dependency on NetSNMP, you must build the generator yourself.

sudo apt-get install build-essential libsnmp-dev snmp-mibs-downloader  # Debian-based distros
go get github.com/prometheus/snmp_exporter/generator
cd ${GOPATH-$HOME/go}/src/github.com/prometheus/snmp_exporter/generator
go build
docker build -t snmp-generator .
docker run -ti \
-v $HOME/.snmp/mibs:/root/.snmp/mibs \
-v $PWD/generator.yml:/opt/generator.yml:ro \
-v $PWD/out/:/opt/ \
snmp-generator generate
Cisco:
version: 3
auth:
username: snmpUser
password: yourPassword
auth_protocol: SHA
priv_protocol: DES
security_level: authPriv
priv_password: privacyPassword
walk:
- 1.3.6.1.2.1.1 # sysInfo
- 1.3.6.1.2.1.2.2 # ifTable
- 1.3.6.1.2.1.31.1.1 # ifXTable
metrics:
#sysInfo
- name: sysUpTime
oid: 1.3.6.1.2.1.1.3
type: counter
lookups:
- labels:
labelname: sysDescr
oid: 1.3.6.1.2.1.1.1.0
type: DisplayString
- labels:
labelname: sysName
oid: 1.3.6.1.2.1.1.5.0
type: DisplayString
- labels:
labelname: sysLocation
oid: 1.3.6.1.2.1.1.6.0
type: DisplayString
- labels:
labelname: sysContact
oid: 1.3.6.1.2.1.1.4.0
type: DisplayString
#Interfaces
#Interface ifIndex
- name: ifIndex
oid: 1.3.6.1.2.1.2.2.1.1
type: gauge
indexes:
- labelname: ifIndex
type: Integer
lookups:
- labels:
- ifIndex
labelname: ifDescr
oid: 1.3.6.1.2.1.2.2.1.2
type: DisplayString
- labels:
- ifIndex
labelname: ifName
oid: 1.3.6.1.2.1.31.1.1.1.1
type: DisplayString
- labels:
- ifIndex
labelname: ifAlias
oid: 1.3.6.1.2.1.31.1.1.1.18
type: DisplayString
#Interface Type
- name: ifType
oid: 1.3.6.1.2.1.2.2.1.3
type: gauge
indexes:
- labelname: ifIndex
type: Integer
lookups:
- labels:
- ifIndex
labelname: ifDescr
oid: 1.3.6.1.2.1.2.2.1.2
type: DisplayString
- labels:
- ifIndex
labelname: ifName
oid: 1.3.6.1.2.1.31.1.1.1.1
type: DisplayString
- labels:
- ifIndex
labelname: ifAlias
oid: 1.3.6.1.2.1.31.1.1.1.18
type: DisplayString
Tree structure of Mib
#Interface Speed
- name: ifSpeed
oid: 1.3.6.1.2.1.2.2.1.5
type: gauge
indexes:
- labelname: ifIndex
type: Integer
lookups:
- labels:
- ifIndex
labelname: ifDescr
oid: 1.3.6.1.2.1.2.2.1.2
type: DisplayString
- labels:
- ifIndex
labelname: ifName
oid: 1.3.6.1.2.1.31.1.1.1.1
type: DisplayString

Prometheus fundamentally stores all data as time series: streams of timestamped values belonging to the same metric and the same set of labeled dimensions. Besides stored time series, Prometheus may generate temporary derived time series as the result of queries.

global:
scrape_interval: 15s
evaluation_interval: 15s

rule_files:
# - "first.rules"
# - "second.rules"

scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['localhost:9090']
# Sample config for Prometheus.
global:
scrape_interval: 5m
scrape_timeout: 10s
evaluation_interval: 1m

# A scrape configuration containing exactly one endpoint to scrape:
scrape_configs:
# Cisco
- job_name: 'Cisco'
scrape_interval: 120s
scrape_timeout: 120s
file_sd_configs:
- files :
- /etc/prometheus/targetCisco.yml
# SNMP device.
metrics_path: /snmp
params:
module: [Cisco] #which OID's we will be querying in
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- target_label: __address__
replacement: 127.0.0.1:9116 # The SNMP exporter's real hostname:port.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store