SNMP on Debian
April 20, 2010 · Print This Article
If you want to monitor your servers from a central management station, you’ll probably need to configure an SNMP daemon on your servers. Here is a quick note to show you how easy it is to get started with SNMP on Linux machine (examples are for Debian but should be easy to adapt for other distribution).
1) install snmpd package
# aptitude install snmpd
2) edit /etc/default/snmpd to remove restriction or replace the default listening address (127.0.0.1 by default). the line to modify is
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'
or you can simply remove it with sed
# sed -i "s/.pid 127.0.0.1'/.pid'/" /etc/default/snmpd
3) add snmpd: 192.168.1.1 in /etc/hosts.allow to allow 192.168.1.1 to poll the server
# echo snmpd: 192.168.1.1 >> /etc/hosts.allow
4) edit /etc/snmp/snmpd.conf to define your community string(s), view(s) and allowed hosts (yes, again)
#### # First, map the community name (COMMUNITY) into a security name: # sec.name source community com2sec readonly 192.168.1.1/32 somecommunity #### # Second, map the security names into group names: # sec.model sec.name group MyROGroup v2c readonly #### # Third, create a view for us to let the groups have rights to: # incl/excl subtree mask view all included .1 80 #### # Finally, grant the groups access to the view with different # read/write permissions: # context sec.model sec.level match read write notif access MyROGroup "" any noauth exact all none none
Once configured, start (or restart) the snmpd daemon.
# /etc/init.d/snmpd restart
And then test from the management station (here 192.168.1.1). We will try to get the hostname of the monitored device :
# snmpget -v 2c -c somecommunity 192.168.1.254 SNMPv2-MIB::sysName.0 SNMPv2-MIB::sysName.0 = STRING: gandalf



Comments
Got something to say?