Category Archives: linux snmp

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.

 

 

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

Advertisements
%d bloggers like this: