Computer Scientist, Graduate Student, and Geek

Tag: snmp

Install SNMP on Ubuntu

May 06, 2011

To install SNMP on Ubuntu, run the commands below (as root):

apt-get install -y snmpd

CONFIG="/etc/snmp/snmpd.conf"
mv $CONFIG $CONFIG.bak
echo rocommunity  public > $CONFIG
echo syslocation  "put location here" >> $CONFIG
echo syscontact   youremail@yourdomain.com >> $CONFIG

CONFIG="/etc/default/snmpd"
mv $CONFIG $CONFIG.bak
cat $CONFIG.bak | grep -v SNMPDOPTS > $CONFIG
echo "SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid \
        -c /etc/snmp/snmpd.conf'" >> $CONFIG

service snmpd restart

echo "Installed snmpd"

If you have a firewall, you will also need to allow UDP traffic on port 161. If you use iptables this can be accomplished with

iptables -A INPUT -p udp -m state --state NEW -m udp --dport 161 -j ACCEPT

You can test if SNMP is working by running snmpwalk from another machine:

snmpwalk -v 1 -c public -O e hostname

This blog posted is based on documentation at http://www.it-slav.net/blogs/2009/02/05/install-and-configure-snmp-on-ubuntu.

Categories: Linux, Networking

Tags: snmp, ubuntu