cbrake
1
SNMP (Simple Network Management Protocol) is an old standard for managing devices on networks.
SNMP Versions
- SNMPv1
- SNMPv2c
- underlying query format differs from SNMPv1
- SNMPv3
- query format is same as SNMPv2C
Terminology
- MIB (Management Information Base) (Ex dashboard)
- HOST-RESOURCES-MIB
- IF-MIB
- IP-MIB
- Written using SMI (Structure of Management Information)
- structures data as a tree
- Object (entry in MIB) (Ex speedometer)
- OID (Object identifier) Identifies Object
- Value (Ex 250KM/hr)
Protocol
- GET
- GETBULK
- GETNEXT
- A manager can “walk” the MIB by presenting a low-numbered object and asking for the first one after it, then repeating the request for each response.
- SET
- TRAP
- Most often used for log messages and alerts.
- INFORM
- RESPONSE
Net-SNMP
Net-SNMP is the defacto OSS implementation and comes with a bunch of tools and default MIBs.
To see what MIBs ship in your distribution, you can do:
[cbrake@quark ~]$ net-snmp-config --default-mibdirs
/home/cbrake/.snmp/mibs:/usr/share/snmp/mibs
[cbrake@quark ~]$ net-snmp-config --default-mibs
:SNMPv2-MIB:IF-MIB:IP-MIB:TCP-MIB:UDP-MIB:HOST-RESOURCES-MIB:NOTIFICATION-LOG-MIB:DISMAN-EVENT-MIB:DISMAN-SCHEDULE-MIB:HOST-RESOURCES-TYPES:UCD-IPFWACC-MIB:TUNNEL-MIB:IPV6-FLOW-LABEL-MIB:UCD-DISKIO-MIB:UCD-DLMOD-MIB:LM-SENSORS-MIB:UCD-SNMP-MIB:UCD-DEMO-MIB:SNMP-TARGET-MIB:NET-SNMP-AGENT-MIB:SNMP-FRAMEWORK-MIB:SNMP-MPD-MIB:SNMP-USER-BASED-SM-MIB:SNMP-VIEW-BASED-ACM-MIB:SNMP-COMMUNITY-MIB:IPV6-ICMP-MIB:IPV6-MIB:IPV6-TCP-MIB:IPV6-UDP-MIB:IP-FORWARD-MIB:NET-SNMP-PASS-MIB:NET-SNMP-EXTEND-MIB:SNMP-NOTIFICATION-MIB:SNMPv2-TM:NET-SNMP-VACM-MIB
cbrake
2
Experiments with a Mikrotik router
After enabling SNMP on a Mikrotik router, you can do things like:
snmpbulkwalk -v2c -c public 10.0.0.1 1.3.6.1
This retrieves 954 lines of information. Samples are included below:
SNMPv2-MIB::sysDescr.0 = STRING: RouterOS RBD52G-5HacD2HnD
SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::enterprises.14988.1
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (24470700) 2 days, 19:58:27.00
SNMPv2-MIB::sysContact.0 = STRING: cbrake
SNMPv2-MIB::sysName.0 = STRING: MikroTik
SNMPv2-MIB::sysLocation.0 = STRING: office
SNMPv2-MIB::sysServices.0 = INTEGER: 78
...
IF-MIB::ifInUcastPkts.1 = Counter32: 32509139
IF-MIB::ifInUcastPkts.2 = Counter32: 0
IF-MIB::ifInUcastPkts.3 = Counter32: 0
IF-MIB::ifInUcastPkts.4 = Counter32: 6428
IF-MIB::ifInUcastPkts.5 = Counter32: 15888099
IF-MIB::ifInUcastPkts.6 = Counter32: 6949139
IF-MIB::ifInUcastPkts.7 = Counter32: 27407093
IF-MIB::ifInUcastPkts.8 = Counter32: 36529705
...
SNMPv2-SMI::mib-2.17.4.3.1.3.0.216.97.251.145.190 = INTEGER: 3
SNMPv2-SMI::mib-2.17.4.3.1.3.8.85.49.109.228.236 = INTEGER: 4
SNMPv2-SMI::mib-2.17.4.3.1.3.8.85.49.109.228.238 = INTEGER: 4
...
HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (24470800) 2 days, 19:58:28.00
HOST-RESOURCES-MIB::hrSystemDate.0 = STRING: 2024-10-9,14:48:55.0,-4:0
HOST-RESOURCES-MIB::hrMemorySize.0 = INTEGER: 131072 KBytes
HOST-RESOURCES-MIB::hrStorageIndex.65536 = INTEGER: 65536
HOST-RESOURCES-MIB::hrStorageIndex.131072 = INTEGER: 131072
HOST-RESOURCES-MIB::hrStorageType.65536 = OID: HOST-RESOURCES-TYPES::hrStorageRam
HOST-RESOURCES-MIB::hrStorageType.131072 = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk
HOST-RESOURCES-MIB::hrStorageDescr.65536 = STRING: main memory
HOST-RESOURCES-MIB::hrStorageDescr.131072 = STRING: system disk
HOST-RESOURCES-MIB::hrStorageAllocationUnits.65536 = INTEGER: 1024 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.131072 = INTEGER: 1024 Bytes
HOST-RESOURCES-MIB::hrStorageSize.65536 = INTEGER: 131072
HOST-RESOURCES-MIB::hrStorageSize.131072 = INTEGER: 15616
HOST-RESOURCES-MIB::hrStorageUsed.65536 = INTEGER: 55216
HOST-RESOURCES-MIB::hrStorageUsed.131072 = INTEGER: 13716
...
IF-MIB::ifName.1 = STRING: ether1
IF-MIB::ifName.2 = STRING: ether2
IF-MIB::ifName.3 = STRING: ether3
IF-MIB::ifName.4 = STRING: ether4
IF-MIB::ifName.5 = STRING: ether5
IF-MIB::ifName.6 = STRING: bec2g
IF-MIB::ifName.7 = STRING: bec5g
IF-MIB::ifName.8 = STRING: bridge
...
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.5.10.0.0.104 = Gauge32: 497
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.5.10.0.0.106 = Gauge32: 596