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
82 Responses to “Install and configure SNMP on Ubuntu”
Leave a Reply
You must be logged in to post a comment.
April 24th, 2009 at 2:41 pm
Superb work. It works for me.
May 27th, 2009 at 8:09 am
This is bullshit way , i dont know how its works
the hell is not working here
May 27th, 2009 at 11:38 am
Totally awesome 🙂
Worked the first time I tried it, and I have to admit, I don’t have a clue as to what I’m doing when it comes to Linux…
Have Cacti running on a windows machine for testing purposes, was trying to get a couple of graphs formed from a remote Linux machine, and this guide is easy to follow, and works perfectly 😉
May 28th, 2009 at 10:55 pm
Good job it works well. It worked the first time I tired it. Ishtiaq you may want to make sure that the computer name on your command line matche with the one you’re using…
May 29th, 2009 at 1:10 pm
Exactly what I have been looking for. I was trying to set up my ubuntu box the same way I did my CentOS server. Completely missed the /etc/default/snmpd changes.
Thanks for the help.
June 3rd, 2009 at 11:32 am
Just for the sake of completion, just used the same settings for my Windows machine running Net-SNMP, and it appears to work. Except for the fact that the files are in different locations 🙂
Although with a little thinking and searching, it’s not that hard to adapt it for a Windows environment.
Now all my machines work the way I want them with Cacti, awesome 😉
June 22nd, 2009 at 7:29 am
Superba work……… Thanks
August 28th, 2009 at 7:20 pm
How to enable wireless parameters?
August 30th, 2009 at 11:19 am
I do not understand the question?
September 16th, 2009 at 4:48 am
This work perfectly for me and I am an absolute novice when it comes to Unix based systems.
I am currently working with Ubuntu Server 9.04
No problems!
Many thanks!!!!!
September 30th, 2009 at 9:31 am
This worked to me as well . i had to poll in the squid server into Solar winds Orion monitoring . Which was successfull .
The document to very much useful .
Many Thanks
October 8th, 2009 at 11:07 pm
I’m trying to set up a Citadel mail server on Ubuntu for the singular purpose of having network devices (in this case, copier/printer/scanners) report status via email. They use snmp relay to do it. When I follow the steps above, all goes well until I get to the file move. I get a “cannot stat … no such file or directory”. Any thoughts?
October 9th, 2009 at 4:14 pm
Does the file exist?
October 29th, 2009 at 6:01 pm
this is what I got :S
user@ubuntu904desktop:~$ sudo apt-get install snmpd
[sudo] password for user:
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
open-vm-source zerofree fakeroot module-assistant patchutils dpatch
Use ‘apt-get autoremove’ to remove them.
The following NEW packages will be installed:
snmpd
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 75.4kB of archives.
After this operation, 401kB of additional disk space will be used.
Err http://us.archive.ubuntu.com jaunty/main snmpd 5.4.1~dfsg-12ubuntu3
Could not resolve ‘us.archive.ubuntu.com’
Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/n/net-snmp/snmpd_5.4.1~dfsg-12ubuntu3_i386.deb Could not resolve ‘us.archive.ubuntu.com’
E: Unable to fetch some archives, maybe run apt-get update or try with –fix-missing?
Apparently not working !!! TT
November 2nd, 2009 at 9:05 am
Jul: Could not resolve ‘us.archive.ubuntu.com’ means that you cannot connect to your repositories.
Try apt-get update as your computer suggest.
Golfer: Thanks
November 1st, 2009 at 7:42 pm
With the internet inundated with so much crap, thank you so much for an ACTUAL helpful post. I spent so much time scouring the web for walkthroughs. I applaud you, good sir.
November 5th, 2009 at 4:20 pm
thanks for the help !
November 14th, 2009 at 2:41 am
Very use full.
Thanks a ton.
November 20th, 2009 at 7:59 am
Works perfect 🙂 great job
November 21st, 2009 at 9:45 pm
Thank you for this. It’s far more simple and straightforward than the snmpconf or manpage for simple, no-frills SNMP monitoring.
Jim
November 28th, 2009 at 5:24 am
Thanks a lot man I really appreciate the help, your guide was simple and easy to use and I got it up in minutes.
December 9th, 2009 at 3:28 pm
Great walkthrough.. not a problem encountered on Ubuntu 9.10
January 7th, 2010 at 8:46 pm
Thanks for the information. Helped me a lot.
March 19th, 2010 at 7:17 pm
Thank you so m,much it worked i needed SNMP for cacti system
http://www.cacti.net and i can monitor now the applications on my windows network
So cool
Thank you so much
April 12th, 2010 at 3:31 am
[…] Originally Posted by rahimrh Dear Forum, I am using Ubuntu Linux 9.0.4 and Nagios 3.2.0. Snmp is installed at my machine and configured and its seems its working fine to check the uptime of a switch 'Uptime' it shows the right status and displays SNMP OK…..); it's has configured as below: service_description Uptime check_command check_snmp!-C public -o sysUpTime.0 However if I use another service (for port status) as below, it show SNMP Critical (down 2) always AND I need help for troublehsooting this: service_description Port 1 Link Status check_command check_snmp!-C public -o ifOperStatus.1 -r 1 -m RFC1213-MIB Thanks Does this help? http://www.it-slav.net/blogs/2009/02…nmp-on-ubuntu/ […]
April 19th, 2010 at 6:50 am
Thank you very much for nice tutorial. Thank you for easy tutorial.
August 3rd, 2010 at 3:39 pm
Works for me! many thanks
September 3rd, 2010 at 10:01 am
Brilliant. Even my windows friends understood this easy enough. Thanks.
September 18th, 2010 at 10:01 am
[…] Install and configure SNMP on Ubuntu Posted: September 18, 2010 by dharsankumaran3 in Uncategorized 0 Install and configure SNMP on Ubuntu […]
October 24th, 2010 at 7:32 am
i have installed net-SNMP on my ubuntu system which is running on a virtual box and i dont know how to access the SNMP,, could u pls help with this
October 24th, 2010 at 8:40 am
Follow my guide and you will be up and running.
November 8th, 2010 at 2:50 pm
It works perfectly!!! thanks….
November 19th, 2010 at 8:24 am
HI peter, I did follow your instructions, but sadly I could not get any output.
#—————————————————-#
root@ravichandra-Inspiron-1525:/etc/snmp# snmpwalk -v 1 -c mycommunityro -O e ravichandra-Inspiron-1525
End of MIB
#—————————————————-#
Something Wrong?
November 21st, 2010 at 4:41 pm
Is the snmpd started?
December 10th, 2010 at 5:50 pm
Works great! It took less than 2 minutes to have SNMP up and running!
Many many thanks!!!
December 22nd, 2010 at 7:10 am
I’m working on snmp.while im trying to configure net-snmp-5.5 i’m getting the error like this.
root#snmpset -v 2c -c readwrite localhost NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject.0 = 1
Error in packet. Reason: notWritable (That object does not support modification) Failed object: NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject.0
can anyone please help me
December 29th, 2010 at 8:56 am
Well, my guess is that you you try to modify a SNMP variable that cannot be changed.
January 13th, 2011 at 3:03 am
Worked fine for me, thanks.
February 2nd, 2011 at 7:05 pm
hi friends
i am new to the linux….and i want to install the snmp on my local system.But while installing i had some problem regarding snmp.conf file.When install snmp package snmp.conf file is not created in /etc/snmp folder..So plz suggest me the solution….
February 3rd, 2011 at 9:18 am
It is snmpd.conf, not snmp.conf
To find it run:
locate snmpd.conf
February 3rd, 2011 at 6:24 pm
when i type the locate snmpd.conf it shows that the file is existing but when i go to the actual snmp dir and then try to find snmpd.conf file through ls command it doesn’t show any file.
February 3rd, 2011 at 7:53 pm
i deinstall all the snmpd packages and again made a free installation of snmp but at this time i don’t get the snmpd.conf, snmptrapd.conf.i don’t know why this happens.Plz give me solution
February 4th, 2011 at 8:32 am
You give me to little information of what you have done to be able to help you.
What is free installation of snmp?
How did you uninstall? and why?
February 9th, 2011 at 9:17 pm
Thanks!
it works great;
configured on Ubuntu Desktop; 8.x, 10.x and Server 10.x 🙂
February 23rd, 2011 at 7:58 pm
I am trying to install mrtg….i am in the last step in completing the process but when i entered the command..
indexmaker –output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg
it gives the following error.
Use of uninitialized value $first in hash element at /usr/bin/indexmaker line 353.
I searched it on google but i don’t get the proper answer..plz help me out..
February 23rd, 2011 at 8:32 pm
I have no clue. I have not used mrtg, only cacti.
March 17th, 2011 at 10:50 pm
i had to apt-get install snmp to make snmpwalk work
ubuntu 10.04 server i386
tnx helped alot
April 19th, 2011 at 9:15 am
[…] the number 1 monitor tool Source:Â http://www.it-slav.net/blogs/2009/02/05/install-and-configure-snmp-on-ubuntu/ GA_googleAddAttr("AdOpt", "1"); GA_googleAddAttr("Origin", "other"); […]
April 19th, 2011 at 1:04 pm
I have installed snmp successfully,but i request you to please give some info about monitoring in the LAN network using snmp.
And i presently using nagios tool for monitoring the systems.
April 21st, 2011 at 9:12 pm
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
April 21st, 2011 at 4:07 pm
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:.
June 11th, 2011 at 7:59 am
Bout damn time someone with common sense published a tut people can understand, thanks, now I have snmpd working, how secure is this anyway?
June 11th, 2011 at 8:45 pm
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.
June 21st, 2011 at 8:40 pm
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.
June 30th, 2011 at 11:20 am
Works fine in ubuntu EBox 1 in my old client ..
thx ..
Rgds
July 8th, 2011 at 4:19 pm
Hi Peter,
I am new to linux.Please leme know how to install SNMP services in rehel 5.7.
Sanjay
July 8th, 2011 at 8:18 pm
http://www.it-slav.net/blogs/2008/11/11/install-and-configure-snmp-on-rhel-or-centos/
September 7th, 2011 at 9:30 am
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
September 7th, 2011 at 9:32 am
I need more info to be able to answer this question.
What works?
Have you tried snmpwalk?
September 22nd, 2011 at 11:09 pm
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.
September 27th, 2011 at 11:25 am
it does not work with monitoring switches?
September 27th, 2011 at 11:26 am
If my readonly password for de switches = test, shuld i use “rocommunity test”?
September 27th, 2011 at 11:29 am
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?
September 27th, 2011 at 11:46 am
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.
February 27th, 2012 at 5:08 am
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.
April 11th, 2012 at 9:58 pm
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,
April 21st, 2012 at 8:16 pm
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
April 30th, 2012 at 9:17 am
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?
August 28th, 2012 at 11:53 am
hi,
if you have two nic cards whats the best way to do it?
September 27th, 2012 at 8:33 pm
Of course it depends on what you want todo.
January 24th, 2013 at 8:00 am
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,
March 4th, 2013 at 1:56 pm
Thanks a ton for such a valuable information . It has helped a lot . Keep up the good work
May 8th, 2013 at 7:57 am
You rock, Peter. Couldn't get this from the man page and I tried a few times.
July 12th, 2013 at 2:12 pm
Nice work! I am fairly new to SNMP and this helped a lot!
Thanks Peter!
September 12th, 2013 at 3:53 am
I've installed snmpd via apt-get, but there's no script /etc/init.d/snmpd after installation. Help!
January 10th, 2014 at 11:11 am
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.
June 13th, 2014 at 3:23 am
Thank you very much!
March 25th, 2015 at 11:13 pm
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!!!
November 9th, 2015 at 8:45 am
Thx u soo much its work for me… :
March 1st, 2016 at 7:31 pm
I looked at over configuration guides for this. your configuration was the only one that worked. Thank you!
March 14th, 2016 at 3:38 pm
Works, thanks!