SNMP with Nagios

I thought I would jot down a few notes about today’s adventures with SNMP. Specifically using SNMP with Nagios mostly on Red Hat/CentOS. I have an appliance from a third-party from which I would like to monitor and graph performance. So view this as a beginner howto for future reference.
There is good info here for beginning SNMP.
1. Install SNMP daemon and Utilities

yum install net-snmp-utils net-snmp

2. Configure the SNMP service

mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.org
vi /etc/snmp/snmpd.conf

Enter the following:

rocommunity somepassword
syslocation “DataCenter”
syscontact jonny@domain.uk

Start the service:

/etc/init.d/snmpd start
chkconfig snmpd on

3. Test with SNMPwalk

snmpwalk -v 1 -c somepassword -O e 127.0.0.1

4. Firewall

vi /etc/sysconfig/iptables

Add

-A RH-Firewall-1-INPUT -m state –state NEW -m udp -p udp –dport 161  –source 143.117.0.0/16 -j ACCEPT

Restart:

/etc/init.d/iptables restart

5. Test
Test it from another machine:

snmpwalk -Os -c sidewinder -v 1 targetmachine.domain.com sysContact.0

Test it using the Nagios plugin:

/usr/lib64/nagios/plugins/check_snmp -H 143.117.143.59 -C somepassword -o sysContact.0

6. IOD Numbers
OK so I got a bit stuck at this point wondering which OIDs I could use to retrieve info from the target machine. I found this list:
Load
1 minute Load: .1.3.6.1.4.1.2021.10.1.3.1
5 minute Load: .1.3.6.1.4.1.2021.10.1.3.2
15 minute Load: .1.3.6.1.4.1.2021.10.1.3.3
CPU
percentage of user CPU time:  .1.3.6.1.4.1.2021.11.9.0
raw user cpu time: .1.3.6.1.4.1.2021.11.50.0
percentages of system CPU time: .1.3.6.1.4.1.2021.11.10.0
raw system cpu time: .1.3.6.1.4.1.2021.11.52.0
percentages of idle CPU time: .1.3.6.1.4.1.2021.11.11.0
raw idle cpu time: .1.3.6.1.4.1.2021.11.53.0
raw nice cpu time: .1.3.6.1.4.1.2021.11.51.0

Total Swap Size:  .1.3.6.1.4.1.2021.4.3.0
Available Swap Space: .1.3.6.1.4.1.2021.4.4.0
Total RAM in machine: .1.3.6.1.4.1.2021.4.5.0
Total RAM used: .1.3.6.1.4.1.2021.4.6.0
Total RAM Free: .1.3.6.1.4.1.2021.4.11.0
Total RAM Shared: .1.3.6.1.4.1.2021.4.13.0
Total RAM Buffered: .1.3.6.1.4.1.2021.4.14.0
Total Cached Memory: .1.3.6.1.4.1.2021.4.15.0

Example:

/usr/lib64/nagios/plugins/check_snmp -H targetserver.com -C sidewinder -o .1.3.6.1.4.1.2021.4.4.0

But I wanted to know more. So I installed across-platform Mib Browser from iReasoning. Now to make good use of this you need the Mib definitions file available at /usr/share/snmp/mibs/UCD-SNMP-MIB.txt in case you are using another Mib/SNMP browser (but UCD-SNMP-MIB.txt is included with the iReasoning browser). This MIB file contains information about the OIDs used in Red Hat/CentOS. So right-click on ‘MIB Tree’ and ‘Load MIB’ choose the UCD-SNMP-MIB.txt file. You should now be able to expand this part of the tree to get explanations of the various OIDs and their numbers which you can then use in your SNMP commands or in Nagios.
So ssCpuIdle is OID number .1.3.6.1.4.1.2021.11.11.0
and can be tested on the Nagios system with:
/usr/lib64/nagios/plugins/check_snmp -H targetserver.com -C somepassword -o .1.3.6.1.4.1.2021.11.11.0
As a service definition in /etc/nagios/objects/services.cfg it would be:

define service{
use                 generic-service
host_name           bloxx2
service_description SNMP_CPUIDLE
check_command       check_snmp!.1.3.6.1.4.1.2021.11.11.0
contact_groups      webadmins
}

Where /etc/nagios/objects/commands.cfg includes:

define command{
command_name    check_snmp
command_line    $USER1$/check_snmp -H $HOSTADDRESS$ -C sidewinder -o $ARG1$ -w $ARG2$ -c $ARG3$
}

You can then also add -w -c warning and critical values too and graph the results with something like NagiosGrapher.

I also found this list with IODs for the Google Search Appliance.

That should be enough to get started.

One Response to “SNMP with Nagios”

  1. ravi

    plz provide the document of custom MIB file import in nagios.(like sonicwall,cyberoam or the devices)>

    Thanks for this docs,……..

    Reply

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>