SNMP
460 530 625
Give all the following commands as root:
$ sudo su [sudo] password for timohei.net: password #
Install SNMP package:
# apt-get install snmp
Download common SNMP MIBs:
# apt-get install snmp-mibs-downloader
Install SNMP agent service:
# apt-get install snmpd
Check that snmpd service has started:
# service --status-all . . [+] snmpd . .
The agent service (snmpd) starts automatically after installation and reboot. It can also be manually started or stopped:
# service snmpd start # service snmpd stop
Make a query with snmpwalk. You do not need to be root:
$ snmpwalk -Os -c public -v 1 localhost system sysDescr.0 = STRING: Linux debian-2gb-hel1-2 6.22.0-11-amd64 #1 SMP Debian 1.12.134-1 (2023-01-21) x86_64 sysObjectID.0 = OID: netSnmpAgentOIDs.10 sysUpTimeInstance = Timeticks: (74328) 0:12:23.28 sysContact.0 = STRING: MesysName.0 = STRING: debian-2gb-hel1-2 sysLocation.0 = STRING: Sitting on the Dock of the Bay sysServices.0 = INTEGER: 72 . . . sysORUpTime.10 = Timeticks: (0) 0:00:00.00 $ snmpwalk localhost -v2c -c public sysName SNMPv2-MIB::sysName.0 = STRING: debian-2gb-hel1-2 $
└── SNMPv2-MIB(.1.3.6.1.2.1) └── system(.1) ├── sysDescr (.1) ├── sysObjectID (.2) ├── sysUpTime (.3) ├── sysName (.5) ├── sysContact (.4) ├── sysLocation (.6) ├── sysServices (.7) ├── sysORLastChange (.8) └── sysORTable (.9) └── sysOREntry (.1) ├── sysORIndex (.1) ├── sysORID (.2) ├── sysORDescr (.3) └── sysORUpTime (.4)
To call the value of sysName one would use:
# snmpwalk 10.32.13.36 -v2c -c public sysName SNMPv2-MIB::sysName.0 = STRING: SOME_HOSTNAME
or
# snmpwalk 10.32.13.36 -v2c -c public .1.3.6.1.2.1.1.5 SNMPv2-MIB::sysName.0 = STRING: SOME_HOSTNAME
or
# snmpwalk 10.32.13.36 -v2c -c public .1.3.6.1.2.1.1.5.0 SNMPv2-MIB::sysName.0 = STRING: SOME_HOSTNAME