Welcome to It-Slav.Net blog
Peter Andersson
peter@it-slav.net

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.

 

 

1.Installation

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:
  lm-sensors
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 127.0.0.1'

To:

# snmpd options (use syslog, close stdin/out/err).
#SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'
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.3 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORID.4 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.5 = OID: TCP-MIB::tcpMIB
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

 

Share

82 Responses to “Install and configure SNMP on Ubuntu”

  1. mAd-1 Says:

    Thanks sooooo very much. I’ve been battling snmp for a few days going through a ton of guides nad forums and your insturctions were spot on to getting it up and running. You’ve managed to stop me from going bald!

    .:tup tup:.

  2. peter Says:

    M.Ram Murthy, my recommendation is to to either get the knowledge or buy it. Contact op5 at http://www.op5.com to get some help

  3. fixer Says:

    Bout damn time someone with common sense published a tut people can understand, thanks, now I have snmpd working, how secure is this anyway?

  4. peter Says:

    Well, SNMP=Security Not My Problem
    Depending on which version it is very unsafe up to rather safe. However if you followed my tutorial it is read-only and rather insensitive data. But if security concern you, do not use SNMP.

  5. chris Says:

    This works just as fine as it is easy to use. Although for those who are not familiar with editing such files, vim or vi are useful tools to edit them. Thanks once more.

  6. B Khuwera Says:

    Works fine in ubuntu EBox 1 in my old client ..
    thx ..

    Rgds

  7. Sanjay Says:

    Hi Peter,
    I am new to linux.Please leme know how to install SNMP services in rehel 5.7.
    Sanjay

  8. peter Says:

    http://www.it-slav.net/blogs/2008/11/11/install-and-configure-snmp-on-rhel-or-centos/

  9. alvin Says:

    it’s working.

    but when i add this machine to Orion Network Performance Monitor (NPM) not working.

    what do i need to change.

    Thanks for reaply.

    Alvin

  10. peter Says:

    I need more info to be able to answer this question.

    What works?
    Have you tried snmpwalk?

  11. frostie Says:

    Nice post — I’ve come back to it many times, but…

    SNMPDOPTS=’-LS5d -Lf /dev/null -u snmp -g snmp -p /var/run/snmpd.pid -c /etc/snmp/snmpd.conf’

    This works much better. The daemon syslog doesn’t get hammered by debug and info messages from snmpd and this allows smux to work.

  12. Rachid Says:

    it does not work with monitoring switches?

  13. Rachid Says:

    If my readonly password for de switches = test, shuld i use “rocommunity test”?

  14. 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?

  15. 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.

  16. 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.
     

  17. 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 1.3.6.1.4.1.15291.1.3.3.1.1.31
     
    I get this failing response:
    SNMPv2-SMI::enterprises.15291.1.3.3.1.1.31 = 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???
     
    Thanks,

  18. 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

  19. 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?

  20. jonathan Says:

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

  21. peter Says:

    Of course it depends on what you want todo.

  22. Khalid Says:

    Hi,
    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.
    Thanks,

  23. Pavan G Jakati Says:

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

  24. Mike Maki Says:

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

  25. Darin Hess Says:

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

  26. Serge Says:

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

  27. 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.

  28. Tyo Says:

    Thank you very much!

  29. 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!!!

  30. Ednawan Says:

    Thx u soo much its work for me… :

  31. Seth S Says:

    I looked at over configuration guides for this. your configuration was the only one that worked. Thank you!

  32. Frank Says:

    Works, thanks!

Leave a Reply


− eight = 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!