Welcome to It-Slav.Net blog
Peter Andersson

I've already got a female to worry about. Her name is the Enterprise.
-- Kirk, "The Corbomite Maneuver", stardate 1514.0

This guide describe howto install and configure SNMP on Ubuntu.

In an earlier article I have described howto set it up on RHES or CentOS, it is slightly different in Ubuntu.




root@ibsen:~# sudo apt-get install snmpd
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libmpich1.0gf libdc1394-22 genisoimage linux-headers-2.6.27-7 libgfortran2 dvd+rw-tools linux-headers-2.6.27-7-generic libcarp-clan-perl libxml-xql-perl libparse-yapp-perl
  rdate python-xml localechooser-data gcc-4.2-base libimage-size-perl libdebconfclient0 libvisual-0.4-0 libmyth-python perlmagick libvisual-0.4-plugins libavdevice52
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  libperl5.10 libsensors3 libsnmp-base libsnmp15
Suggested packages:
The following NEW packages will be installed:
  libperl5.10 libsensors3 libsnmp-base libsnmp15 snmpd
0 upgraded, 5 newly installed, 0 to remove and 3 not upgraded.
Need to get 2463kB of archives.
After this operation, 7987kB of additional disk space will be used.
Do you want to continue [Y/n]? 

answer y


2. Configuration

Move existing /etc/snmp/snmpd.conf configuration file to /etc/snmp/snmpd.conf.org

mv /etc/snmp/snmpd.conf  /etc/snmp/snmpd.conf.org

Create a new /etc/snmp/snmpd.conf file:

rocommunity  public
syslocation  "PDC, Peters DataCenter"
syscontact  peter@it-slav.net

Make snmpd use the newly created file and make it listen to all interfaces:

Edit /etc/default/snmpd

Change from:

# snmpd options (use syslog, close stdin/out/err).
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid'


# snmpd options (use syslog, close stdin/out/err).
#SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid'
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid -c /etc/snmp/snmpd.conf'

and restart snmpd

/etc/init.d/snmpd restart



3. Test

Do a snmpwalk from another host against your newly configured host.

[root@op5 ~]# snmpwalk -v 1 -c public -O e ibsen
SNMPv2-MIB::sysDescr.0 = STRING: Linux ibsen 2.6.27-9-generic #1 SMP Thu Nov 20 21:57:00 UTC 2008 i686
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (68869) 0:11:28.69
SNMPv2-MIB::sysContact.0 = STRING: peter@it-slav.net
SNMPv2-MIB::sysName.0 = STRING: ibsen
SNMPv2-MIB::sysLocation.0 = STRING: "PDC, Peters DataCenter"
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (1) 0:00:00.01
SNMPv2-MIB::sysORID.1 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.2 = OID: SNMP-MPD-MIB::snmpMPDCompliance
SNMPv2-MIB::sysORID.4 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.6 = OID: IP-MIB::ip

Yes it works!!


4. Monitor example

Below is an example of how it looks using op5 Monitor a Nagios based Enterprise Monitor solution.



5. Useful links

  • op5 Statistics, a cacti based graph tool
  • op5 Monitor, an Enterprise Class Monitoring system based on Nagios
  • Net-SNMP, an open source implementation of SNMP
  • Cacti, an open source graph tool
  • Nagios, the number 1 monitor tool



79 Responses to “Install and configure SNMP on Ubuntu”

  1. Rachid Says:

    if my read-only password of the switch = “test”,
    then I should use for ewample:
    rocommunity test
    syslocation “PDC, Peters DataCenter”
    syscontact peter@it-slav.net

    Is this correct?

  2. peter Says:

    You have missunderstod the article, it describes howto setup SNMP on Ubuntu.
    So the answer is NO!
    In your monitor software, point it to your switch ip and use the community string you have in your switch.

  3. giri Says:

    Superbe, it is working.
    What configuration changes i need to do to configure the SNMPv3 user.
    I just created the following on /etc/snmpd/snmpd.conf 
    createUser myuser MD5 "pass" DES "pass"
    and restarted the service, but when i used in the snmpwalk like shown below
    snmpwalk -v 3 -u mysuer -a SHA -A "pass" -x DES -X "pass" -l authPriv <ip>
    getting the following error:
    Error in packet.
    Reason: authorizationError (access denied to that object)
    What configuration i am missing here.

  4. Dan Says:

    Get writeup:

    I am running Ubuntu 11.04 and I just have one configuration issue to overcome.
    If I run:
    snmpwalk -c public -v2c xxx.xxx.xxx.xxx system
    I get a good response like this:
    SNMPv2-MIB::sysDescr.0 = STRING: ModuleLite1000 Agt.6.04 SC-450
    SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::zeroDotZero
    DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (68246112) 7 days, 21:34:21.12
    SNMPv2-MIB::sysContact.0 = STRING: default contact name
    SNMPv2-MIB::sysName.0 = STRING: defaultName
    SNMPv2-MIB::sysLocation.0 = STRING: defaultLocation
    SNMPv2-MIB::sysServices.0 = INTEGER: 79
    If I try to access a single OIU value like this
    snmpwalk -c public -v2c xxx.xxx.xxx.xxx
    I get this failing response:
    SNMPv2-SMI::enterprises.15291. = No Such Object available on this agent at this OID
    *** However, the same command works on my MacBook Pro (Snow Leopard) without any issues, so I know the remote devices are ok, but my Ubuntu configuration is not.
    What is missing/Where do I look in my Ubuntu server to fix this???

  5. jbpandit Says:

    hi Mr peter
    I have come here through google search and hope will get solution of my problem. I have installed net-snmp 5.7.1 on ubuntu 11.10. my installation folder is /home/jbpandit/snmp_projects/net-snmp and snmpd.conf file location is /usr/local/share/snmp.  and i have not installed snmpd package from debian which you describe here. after successfull installation of snmp i have run snmpconf tool and created snmpd.conf file and is located in above folder. after that i start  agent from  /etc/init.d/snmpd start and it work fine, but problem is that after shut down the system and on next system boot  i am not able to start agent. so what went wrong here? do i need to install snmpd package?. help please……jbpandit

  6. srinija Says:

    hi am not able to configure snmptrap can anyone pls help?
    root@newuser-desktop:/usr/local/sbin# snmptrapd -f -Le
    NET-SNMP version 5.6.2.pre1 AgentX subagent connected
    Warning: no access control information configured.
      (Config search path: /usr/local/etc/snmp:/usr/local/share/snmp:/usr/local/lib/snmp:/root/.snmp)
    This receiver will *NOT* accept any incoming notifications.
    couldn't open udp:162 — errno 98 ("Address already in use")

    can anyone pls help where i went wrong?

  7. jonathan Says:

    if you have two nic cards whats the best way to do it?

  8. peter Says:

    Of course it depends on what you want todo.

  9. Khalid Says:

    I have installed snmp on a VM running on LINUX. And it works absolutely fine and sends the traps to the SNMP server. Now I want to move the VM to a different subnet or network. Is there any way that I can do a dynamic configuration on snmp agent that it sends traps to a local SNMP server in new network.

  10. Pavan G Jakati Says:

    Thanks a ton for such a valuable information . It has helped a lot . Keep up the good work

  11. Mike Maki Says:

    You rock, Peter. Couldn't get this from the man page and I tried a few times.

  12. Darin Hess Says:

    Nice work!  I am fairly new to SNMP and this helped a lot!
    Thanks Peter!

  13. Serge Says:

    I've installed snmpd via apt-get, but there's no script /etc/init.d/snmpd after installation. Help!

  14. OMSPL Says:

    January 2014 and this still works. (Tested on ubuntu 12.04)
    Changed this line : SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid'
    to : SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid -c /etc/snmp/snmpd.conf'
    in the conf file.

  15. Tyo Says:

    Thank you very much!

  16. Adnan Says:

    This is an excellent tutorial. I was having problem with “No response” even though my snmp agent and server are at the same server. The step 2 mentioned here has solved my problem.

    Thank you very much!!!

Leave a Reply

five × 1 =

Book reviews
FreePBX 2.5
Powerful Telephony Solutions

Asterisk 1.6
Build a feature rich telephony system with Asterisk

Learning NAGIOS 3.0

Cacti 0.8 Network Monitoring,
Monitor your network with ease!