Involvement in Icinga / Nagios
The Plugin check_snmptraps.pl
With the plugin, you can be certain traps on the DB and alarmed this. Even the issue of the message from a trap is possible.
Prerequisite:
Installation of Perl-Modul DBI
Installation:
Copy the Plugin in the libexec directory from Icinga or Nagios. Now you musst set follow database parameters in the plugin:
my $dbHost = "localhost"; my $dbName = "snmptt"; my $dbUser = "root"; my $dbPass = ""; my $dbTable = "snmptt";
That's it!
The Plugin in his parameters:
-H (--hostname)
Hostname to query - (required)
-S (--search)
search a expression in the message content
-C (--category)
Category from SNMP-Trap (optional)
-O (--oid)
OID from SNMP-Trap (optional)
-w (--warning)
Check for warning traps in the database
-c (--critical)
Check for critical traps in the database
-u (--unknown)
Check for unknown traps in the database
(Default is set the option -w, -c and -u)
-r (--read)
Read marked traps from database too.
-m (--message)
Print Message from last read trap from database.
This option can only used with -w, -c or -u!
-t (--timeout)
seconds before the plugin times out (default=15)
-V (--version)
Plugin version
-h (--help)
Print this help
A few examples how to call the plugin:
./check_snmptraps.pl -H srv_tes_02 -m -c
Output:
CRITICAL - 1 critical Trap: This was only a test message for NagTrap|'critical trap='1;;;;
or
./check_snmptraps.pl -H srv_tes_02 -m -c -O '.1.3.6.1.4.1.10418.2.1.3.0.27'
Output:
CRITICAL - 1 critical Trap: This was only a test message for NagTrap|'critical trap='1;;;;
etc.
Icinga / Nagios Service Extinfo
A example for the serviceextinfo in Nagios:
define serviceextinfo {
host_name < NAGIOS HOST >
service_description SNMP Alerting
notes SNMP Alerts
notes_url http://<servername>/nagios/nagtrap/index.php?hostname=$HOSTADDRESS$
}
For Icinga:
define serviceextinfo {
host_name < ICINGA HOST >
service_description SNMP Alerting
notes SNMP Alerts
notes_url http://<servername>/icinga/nagtrap/index.php?hostname=$HOSTADDRESS$
}
Integration in Icinga Classic UI
Attention:
You musst change the path to icinga, if /usr/local/icinga not your default path!
Edit follow file, to add a link in the icinga menu:
/usr/local/icinga/share/menu.html
Add here follow lines:
<h2>AddOn's</h2> <ul> <li class="menuli_style1"><a href="/icinga/nagtrap/index.php" target="main">NagTrap</a></li> </ul>
Before:
<h2>Configuration</h2>
<ul>
<li class="menuli_style1"><a href="/icinga/cgi-bin/config.cgi" target="main">View Config</a></li>
</ul>
</div>
</body>
</html>
After:
<h2>Configuration</h2>
<ul>
<li class="menuli_style1"><a href="/icinga/cgi-bin/config.cgi" target="main">View Config</a></li>
</ul>
<h2>AddOn's</h2>
<ul>
<li class="menuli_style1"><a href="/icinga/nagtrap/index.php" target="main">NagTrap</a></li>
</ul>
</div>
</body>
</html>
Integration in Nagios
Attention:
You musst change the path to nagios, if /usr/local/nagios not your default path!
Edit follow file, to add a link in the nagios menu:
/usr/local/nagios/share/side.php
Add here follow lines:
<li><a href="/nagios/nagtrap/index.php" target="<?php echo $link_target;?>">NagTrap</a></li>
Before:
<div class="navsection"> <div class="navsectiontitle">System</div> <div class="navsectionlinks"> <ul class="navsectionlinks"> <li><a href="<?php echo $cfg["cgi_base_url"];?>/extinfo.cgi?type=3" target="<?php echo $link_target;?>">Comments</a></li> <li><a href="<?php echo $cfg["cgi_base_url"];?>/extinfo.cgi?type=6" target="<?php echo $link_target;?>">Downtime</a></li> <li><a href="<?php echo $cfg["cgi_base_url"];?>/extinfo.cgi?type=0" target="<?php echo $link_target;?>">Process Info</a></li> <li><a href="<?php echo $cfg["cgi_base_url"];?>/extinfo.cgi?type=4" target="<?php echo $link_target;?>">Performance Info</a></li> <li><a href="<?php echo $cfg["cgi_base_url"];?>/extinfo.cgi?type=7" target="<?php echo $link_target;?>">Scheduling Queue</a></li> <li><a href="<?php echo $cfg["cgi_base_url"];?>/config.cgi" target="<?php echo $link_target;?>">Configuration</a></li> </ul> </div> </div>
After:
<div class="navsection"> <div class="navsectiontitle">System</div> <div class="navsectionlinks"> <ul class="navsectionlinks"> <li><a href="<?php echo $cfg["cgi_base_url"];?>/extinfo.cgi?type=3" target="<?php echo $link_target;?>">Comments</a></li> <li><a href="<?php echo $cfg["cgi_base_url"];?>/extinfo.cgi?type=6" target="<?php echo $link_target;?>">Downtime</a></li> <li><a href="<?php echo $cfg["cgi_base_url"];?>/extinfo.cgi?type=0" target="<?php echo $link_target;?>">Process Info</a></li> <li><a href="<?php echo $cfg["cgi_base_url"];?>/extinfo.cgi?type=4" target="<?php echo $link_target;?>">Performance Info</a></li> <li><a href="<?php echo $cfg["cgi_base_url"];?>/extinfo.cgi?type=7" target="<?php echo $link_target;?>">Scheduling Queue</a></li> <li><a href="<?php echo $cfg["cgi_base_url"];?>/config.cgi" target="<?php echo $link_target;?>">Configuration</a></li> <li><a href="/nagios/nagtrap/index.php" target="<?php echo $link_target;?>">NagTrap</a></li> </ul> </div> </div>