snmp configuration on Linux (snmpd.conf) NET-SNMP

Hi All,

I am going to show you how to configure the snmp agent on a Linux based distribution – this example is tested on CentOS and Red Hat Linux

Purpose:

The purpose of installing SNMP (Simple Network Transfer Protocol) is to monitor host resources like CPU, Memory, Network and Disk Utilization etc.

SNMP is a network management protocol used to send and recive
messages between NMS (Network Management Systems). SNMP allows NMS to
manage network devices remotely, by using MIBs .

You might be wondering what are MIB ?
MIB’s are Management Information Base, It can be best described as information in the form of variable that would be useful to manage the specific item. The developer who creates a  MIB has to create a OID  aka Object Identifiers

Now you might be wondering whats OID ?
An object identifier is simply a unique id represented by a series of numbers and point that has a unique corresponding name. The format of OID is a sequence of numbers with periods /dots in between.

example of Print Device OID is like this:
1.3.6.1.2.1.43.10.2.1.4.1.1
This is HP Printer Total Page Count.

To learn more about MIB’s and OID’s please Google it, as I am still learning about it too its a huge topic on its own.

Now that you have a basic understanding of how SNMP works lets start off with the installation of NET-SNMP package ( oh by the way formally it was known as UCD-SNMP)

Installing NET-SNMP on Linux System:

To install the snmp (net-snmp ) I will recommend you to install the other package net-snmp-utils this will be useful for testing as it has handy tools like snmpwalk etc.

You can also watch the snmp installation video created  by me.

 The Video has the full installation process.

 

[youtube=http://youtu.be/BsEzFE_z-UQ]

 

[root@Client ~]# yum install net-snmp net-snmp-utils 
Loaded plugins: downloadonly, fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.coreix.net
* extras: mirrors.coreix.net
* updates: mirror.krystal.co.uk
Setting up Install Process
Package 1:net-snmp-utils-5.5-44.el6_4.1.x86_64 already installed and latest version
Resolving Dependencies
–> Running transaction check
—> Package net-snmp.x86_64 1:5.5-44.el6_4.1 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================
Package Arch Version Repository Size
=========================================================================================
Installing:
net-snmp x86_64 1:5.5-44.el6_4.1 updates 303 k

Transaction Summary
=========================================================================================
Install 1 Package(s)

Total download size: 303 k
Installed size: 816 k
Is this ok [y/N]:Y

Give y

Dependencies Resolved

=========================================================================================
Package Arch Version Repository Size
=========================================================================================
Installing:
net-snmp x86_64 1:5.5-44.el6_4.1 updates 303 k

Transaction Summary
=========================================================================================
Install 1 Package(s)

Total download size: 303 k
Installed size: 816 k
Is this ok [y/N]: y
Downloading Packages:
net-snmp-5.5-44.el6_4.1.x86_64.rpm | 303 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : 1:net-snmp-5.5-44.el6_4.1.x86_64 1/1
Verifying : 1:net-snmp-5.5-44.el6_4.1.x86_64 1/1

Installed:
net-snmp.x86_64 1:5.5-44.el6_4.1

Complete!
[root@Client ~]#

Once the package is installed we can edit the snmpd.conf, before doing that I would suggest you make a copy of the orignal file

#cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak

Edit the snmpd.conf file with vi editor

#vi /etc/snmp/snmp.conf

1. Locate the line

com2sec notConfigUser  default  public

and comment it with #or just change the community name to something secret I have changed it to sizmic

com2sec notConfigUser default sizmic

2. Locate the lines and comment them with #

view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1

add a new line

view                 all                            included                     .1                                   80

3. Locate the line

# group context sec.model sec.level prefix read write notif
access notConfigGroup “” any noauth exact systemview one none

change the systemview to all

access notConfigGroup “” any noauth exact all none none

snmpfile configuration

the same changes are highlighted in the image

Save the file

once the file is configured save it by pressing escape key then : wq!

Start the snmp service 

once you save the file you can give the following command to start the snmp service

#service snmpd start

Note: each time you make any change to the snmpd.conf file make sure to restart the snmpd service service

For restarting the snmpd service the command is

#service snmpd restart

Configure the snmp service to start automatically: 

once the service is started we need to make sure the Linux server knows to keep the service running in an event of reboot.

give the command

#chkconfig snmpd on 

this enable snmpd on the following runlevel 2, 3, 4, 5 ( this is required to make sure the snmpd service is running after a reboot to the linux system)

to make sure the service is running on the above runlevel you can use the following command

#chkconfig –list snmpd

# chkconfig –list snmpd
snmpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Test the snmpd service :

to test it we need to give snmpwalk command.

snmpwalk -v 1 -c sizmic localhost

I have created a Video which can take you through these changes,belive me I had spend a long time to learn about how snmp monitoring works and I will be happy to help if you have any questions

I hope you find this post useful. Don’t forget to leave comments if you find it useful.

32 thoughts on “snmp configuration on Linux (snmpd.conf) NET-SNMP”

  1. My brother suggested I might like this blog. He was entirely right.

    This post truly made my day. You can not imagine
    just how much time I had spent for this info! Thanks!

  2. Hello Ibrahim, thanks for the great post. I can now snmpwalk my server as you described, but I’d like to import some details from a specific MIB file provided from a third party hardware manufacturer. How can I “add” my MIB to the snmp database?
    Thanks!

    1. Hi,
      Thanks for the comment I am glad to know you like the post.
      Please copy the MIB’s from the third pary hardware manufacturer to the location /usr/share/snmp/mibs/
      you can scp or use winscp / filezilla etc to copy it and they should work with out any extra configuration as this is the default mib location on RedHat / CentOS.

      Hope this information is useful and do let me know how you get on 🙂
      Thanks for taking the time to comment!

      Cheers,
      Ibrahim.

  3. Hi,

    I am a new bee n followed the above steps as mentioned by you but stuck to execute my shell script or my c/C++ code using MIB. Will you please mention few more steps were in the config file shall i change to execute my script.

    Thanks in Advance

  4. Any ideas why this would not work with Solarwinds? Specifically Solarwinds is not finding the interfaces on my Redhat machine. It can see CPU/RAM, but not the interfaces. I can do local walks, walks on different machines – all of them show interfaces. But when adding a node in Solarwinds – nothing is listed.

  5. Hello, I do thyink your site could possibly be having internet browser compatibility problems.
    Whenever I look at your website in Safari, it looks
    fine buut hen opening in I.E., it’s got some overlapping issues.

    I simply wanted to provise you with a quick heads up!
    Apart from that, fantastic blog!

  6. I have some error when i type below command
    [root@ta180 /]# snmpwalk -v 1 -c SNMP-Servers localhost
    Timeout: No Response from localhost

  7. How would I go about getting a process monitored in solarwinds? Right now I need to monitor “dsclient” or if is start it from the init.d its “DS-Client” I have tried to get solarwinds via SNMP v2 to monitor it but is “cant find process dsclient”. Do you know of a how to on how to monitor process/services in centos?

  8. Hello, Neat post. There’s an issue with your website in internet explorer, would check this?
    IE nonetheless is the market chief and a large component to other folks will leave out your wonderful writing due
    to this problem.

  9. Hi, Good post and I have implemented in the exact way but snmp is not working still. Polling says request timed out, routing is OK and I can see snmp request coming on the server by tcpdump. Any ideas ?

  10. Hi,
    I have an issue on where in the snmpd.conf file can I add necessary subnets for access as well as enabling acess control.

    thanks,

    Aniekan

  11. Hi,
    This was very useful blog, but I’ve not understood how to configure snmp agent and snmp manager. Also can you please give information about how to make the two communicate?

  12. Unbelievable! I searched and searched trying to find a good example of how to modify the snmpd.conf file. This is exactly what I needed. Now I can run snmpwalk and see all Redhat Mibs. Thank you very much for takign the time to post this.

    Have you also configured trap sending to a server like netcool?

    I haven’t tested yet, but I just added

    authCommunity log,execute,net public

    to my snmptrapd.conf

    and added

    rocommunity public
    trap2sink x.x.x.x public 162

    where x.x.x.x is the netcool server.

    Any ideas whether this is all I need?

    Thanks Again

    1. Hi Ibrahim, Paul

      I am a newbie to SNMP and I am asked to send a test snmp from a linux server to Solaris server. How can I setup that?
      Thanks

  13. Tulisan ini sangat berguna bagi para manusia. Sebab busana adalah kebutuhan penting yang selalu ada dari keseharian kita.

    Semua orang niscaya ingin terlihat menarik. Sedangkan cara yang tersering dijalani adalah dengan memperhatikan pakaian kita.
    Bagi seorang muslim, ada peraturan dasar yang wajib dijalankan saat
    memilih baju kita. Karena dengan pakaian yang sesuai,
    kita tidak cuma tampil menawan, tapi juga mendapat balasan pahala.
    Toko online Baju Muslim Murah akan menolong Sis supaya memiliki baju muslim
    yang benar.

  14. it exists and you can live it with one of the beautiful Brazilian girls.
    However, while the image is formed of dark-coloured
    dyes, the final image does not reproduce colour.
    I was a little thrown off that he called me four times in two hours,
    but I figured that since he was trying to set up a date, maybe that
    was normal.

  15. ulasan keren tentang besi bangunan ini sangat menarik
    sekali. bagus sekali & diketahui. tiap orang yg pakai ataupun lagi mencari tulisan tentang baja bangunanan harus baca
    informasi ini. mampir juga web aku ya saudara ada ulasan manarik yang pasti bermanfaat buat siapa saja user
    ingin penjelasan kian banyak mengenai mutu besi wassalam

  16. C’est vrai que t’es allé un peu fort Moussaillon, ce
    que tes lectrices n’ont pas vu c’est l’amour que tu portes à cette femme, en la
    laissant partir, en la laissant revenir. Et
    c’est bien là tout le problème de ces voyageuses, aucune ne voit l’amour de l’homme qu’elles quittent, et encore moins ne comprennent
    sa souffrance… c’est assez clair dans ce débat, et
    le serait également s’il avait été au sujet des hommes qui voyagent.

  17. I do not even know the way I ended up here, however I assumed this submit
    was once good. I do not recognize who you’re but definitely
    you’re going to a famous blogger should you aren’t already.
    Cheers!

  18. VERY USEFUL! At first it did not work but this was because firewall was blocking udp request. If anyone is experiencing this just run these commands
    iptables -I INPUT -p udp -m udp –dport 161 -j ACCEPT
    iptables -I INPUT -p udp -m udp –dport 162 -j ACCEPT
    iptables-save > /etc/sysconfig/iptables

  19. Hi ibrahim,

    thanks for your helpful article,

    i’m having a problem when i start snmp

    errror : Error opening specified endpoint “”
    Server Exiting with code 1

    can you please help

    BR
    Amine

Leave a Reply

Your email address will not be published. Required fields are marked *