Packetwatch.net

SNMP in Red Hat Enterprise Linux



Last modified: Nov. 5, 2010

Contents
1 - Summary
2 - Net-SNMP installation
3 - Service configuration
4 - Snmpget example
5 - Service check


1 - Summary

This guide will show how to install SNMP in Red Hat Enterprise Linux. SNMP is a
network protocol used to monitor network devices. We will install Net-SNMP.
This has been test in Red Hat Enterprise Linux 4 and 5.


2 - Net-SNMP installation

Install the net-snmp package.
# sudo yum install net-snmp
Password:


3 - Service configuration

Find where the net-snmp daemon was installed to.
# rpm -ql net-snmp-* | grep sbin
/usr/sbin/snmpd
/usr/sbin/snmptrapd
# rpm -ql net-snmp-* | grep rc.d
/etc/rc.d/init.d/snmpd
/etc/rc.d/init.d/snmptrapd

Enable the net-snmp service so that it will start when the system starts up.
# sudo /sbin/chkconfig snmpd on
Password:
# sudo /sbin/chkconfig --list snmpd
Password:
snmpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off

Find where the configuration file should be put.
# grep .conf /etc/rc.d/init.d/snmpd
# chkconfig: - 50 50
# config: /etc/snmp/snmpd.conf
# config: /usr/share/snmp/snmpd.conf
if [ -e /etc/sysconfig/snmpd.options ]; then
  . /etc/sysconfig/snmpd.options
# strings /usr/sbin/snmpd | grep .conf
update_config
read_config_print_usage
SnmpdReconfig
reconfig
Reconfiguring daemon
  -c FILE[,...]         read FILE(s) as configuration file(s)
  -C                    do not read the default configuration files
  -H                    display configuration file directives understood

You can create your own configuration file. For this example, we will use a
read only community name of public.
  rocommunity public
  syslocation "Test"
  syscontact "John Doe"
# rpm -ql net-snmp-* | grep snmpd.conf
/etc/snmp/snmpd.conf
/usr/share/man/man5/snmpd.conf.5.gz
# sudo cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.example
Password:
# sudo vi /etc/snmp/snmpd.conf
Password:

You will need to configure SELinux appropriately. SELinux status can be
found by running sestatus.
# sudo /usr/sbin/sestatus | grep status:
Password:
SELinux status:                 enabled

Before starting the service, make sure that udp port 161 is open in case you
are running firewall software. Here is a sample rule.
  -A RH-Firewall-1-INPUT -p udp -m udp --dport 161 -j ACCEPT
# sudo /sbin/service iptables stop
Password:
Flushing firewall rules:                                   [  OK  ]
Setting chains to policy ACCEPT: filter                    [  OK  ]
Unloading iptables modules:                                [  OK  ]
# sudo cp /etc/sysconfig/iptables /etc/sysconfig/iptables.previous
Password:
# sudo vi /etc/sysconfig/iptables
Password:
# sudo /sbin/service iptables start
Password:
Applying iptables firewall rules:                          [  OK  ]
Loading additional iptables modules: ip_conntrack_netbios_n[  OK  ]

If you installing this on a Dell PowerEdge server that already has Dell
OpenMange Server Administrator installed, run the following to enable SNMP in
OpenManage Server Administrator. This will add a line in the net-snmp config
file to allow more information to be monitored.
# sudo /etc/init.d/dataeng enablesnmp
Password:
Data Engine SNMP enabled

Start the net-snmp service.
# sudo /sbin/service snmpd start
Password:
Starting snmpd:                                            [  OK  ]
# sudo /sbin/service snmpd status
Password:
snmpd (pid  3280) is running...

If you are on a Dell PowerEdge server that already has Dell OpenManage Server
Administrator installed, restart the OpenManage sevices. It will complain about
the dsm_sa_snmpd service because it wasn't already running.
# sudo /etc/init.d/dataeng restart
Password:
Stopping Systems Management Data Engine:
Stopping dsm_sa_snmpd: Not started                         [FAILED]
Stopping dsm_sa_eventmgrd:                                 [  OK  ]
Stopping dsm_sa_datamgrd:                                  [  OK  ]
Starting Systems Management Data Engine:
Starting dsm_sa_datamgrd:                                  [  OK  ]
Starting dsm_sa_eventmgrd:                                 [  OK  ]
Starting dsm_sa_snmpd:                                     [  OK  ]
# sudo /opt/dell/srvadmin/sbin/srvadmin-services.sh status
Password:
Remote Access Controller (RAC4) is stopped                 [  OK  ]
dell_rbu (module) is running
ipmi driver is running
dsm_sa_datamgrd (pid 3677) is running
dsm_sa_eventmgrd (pid 3953) is running
dsm_sa_snmpd (pid 4013) is running
dsm_om_shrsvcd (pid 3210) is running
dsm_om_connsvcd (pid 4444 4443) is running


4 - Snmpget example

If you are running this against a Dell PowerEdge server you can get more
information if you download the MIBs for PowerEdge servers at the Dell
website. You have to go to http://support.dell.com/ and go under the Systems
Management section. Download the file that says MIBs for PowerEdge. The MIB
files will need to be moved to the computer that is running snmpget. In our
example, we are running snmpget from a FreeBSD computer. Find where MIB files
are stored and copy the files to that directory. Afterwards, run snmpget.
# pkg_info -L net-snmp-* | grep /mibs/
/usr/local/share/snmp/mibs/AGENTX-MIB.txt
...
# sudo chown root:wheel ~/dell_mib/mibs63/*
Password:
# sudo cp ~/dell_mib/mibs63/* /usr/local/share/snmp/mibs/
Password:

From another computer, run snmpget to view some SNMP information.
# sudo snmpget -Os -c public -v 2c server.test.com sysName.0 sysLocation.0 sysContact.0
Password:
sysName.0 = STRING: server.test.com
sysLocation.0 = STRING: "Test"
sysContact.0 = STRING: "John Doe"


5 - Service check

Reboot your computer. Log in like normal and check to see that the net-snmp
service is running. That's it, now you have snmp running in Red Hat Enterprise
Linux.
# sudo /sbin/shutdown -r now
Password:
# sudo /sbin/service snmpd status
Password:
snmpd (pid  2339) is running...


Last modified: Thu Jan 1 00:00:00 1970 UTC
Packetwatch Research 2002-2024.