Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Configure Nagios in Ubuntu

to install nagios:

sudo apt-get install nagios3 nagios-plugins nagios-plugins-standard nagios-plugins-extra

after that you can access nagios in:

 


http://localhost/nagios3


 

in your browser.

Traps on Nagios

Configuring traps on Nagios is not so simple. An agent to handle traps and call Nagios trap handler is needed. This task is done by snmptt and snmptrapd

Trap Handling

This describes the basics of trap handling.  Snmptt increases complexity by adding another layer behind nagios but it also increases the readability of the incoming traps. What do you need is:

  • Snmptrapd,
  • Snmptt,
  • MIB's for any devices you want traps sent for. A MIB basically allows the OID of the trap sent into something more descriptive.


Most hardware manufactuers have MIBs available on their site, or you can check out a site like mibdepot. In the case that the MIB does not exist for the hardware we want to monitor, we will need to develop it.


Configuration

to install snmptrapd and snmptt you can:

sudo apt-get install snmpd snmptt


In your /etc/snmp/snmptrapd.conf file you'll want it to read simply:

traphandle default /usr/local/sbin/snmptt
disableAuthorization yes


In the /etc/snmp/snmptt.ini file I set the following options.

 

mode = standalone

description_mode = 1

unknown_trap_exec = /etc/snmp/traphandle.sh

Convert your MIB to something that can be read by snmptt


Given your MIB file you want one conf file that snmptt can handle. You can convert the MIB to a conf file by running the following command:

snmpttconvertmib --in=/where/your/mib/is/NAME.mib --out=/etc/snmp/myMIB.conf --exec='/etc/snmp/traphandle.sh $r $s "$D"'

We used "--exec" in the MIB convert process. This will give a command that will be executed when that OID is found. This command could be something like a Nagios event handler, or a shell script (which is what I'm using). You can choose the variables you want passed to your traps. There's a a lot in the documentation. In this example I used:

$R, $r  - Trap hostname
$s  - Severity
$D - Description text from SNMPTT.CONF or MIB file

After that you have to change your /etc/snmp/snmptt.ini:

snmptt_conf_files = <<END
/etc/snmp/miMIB.conf



If you make more conf files you can just add new ones on a new line:

snmptt_conf_files = <<END
/etc/snmp/miMIB.conf
/etc/snmp/miMIB2.conf


Handling Traps

The shell script (/etc/snmp/traphandle.sh) used in the --event line during the MIB conversion process could be anything you want:

#!/bin/sh
#
echo "$4

Host: $1
Severity: $2

Description:
$3
" | mail -s "$2 Error from: $1" trap@openwsn.org

This will send a simple e-mail out when a trap is received.

To use the Nagios Handler instead of calling /etc/snmp/the traphandle.sh shell script, we can replace --event entry by:

/usr/share/nagios3/plugins/eventhandlers/submit_check_result

Conclusion

TBD...



  • No labels