Nagios SNMP Plugin
Ford, Andy
andrew.ford at wachovia.com
Tue Jul 28 17:29:49 CEST 2009
Uptime is pretty easy. CPU and Storage are well handled by these plugins: http://nagios.manubulon.com/
Here's braindead (positional parameters, Oh My!) simple plugin for sysUptime that is useful if you want to know when the uptime crosses some threshold:
#!/usr/local/nagios/bin/perl
use warnings;
use strict;
use Net::SNMP;
my ($session, $error) = Net::SNMP->session(
-hostname => shift || 'localhost',
-community => shift || 'public',
-port => shift || 161
);
my $criticaldays = shift;
if (!defined($session)) {
printf("ERROR: %s.\n", $error);
exit 1;
}
my $sysUpTime = '1.3.6.1.2.1.1.3.0';
my $result = $session->get_request(
-varbindlist => [$sysUpTime]
);
if (!defined($result)) {
printf("ERROR: %s.\n", $session->error);
$session->close;
exit 1;
}
my $uptime = $result->{$sysUpTime};
$session->close;
if ($uptime =~ /(\d+) days/) {
my $daysup = $1;
if (defined $criticaldays and $daysup > $criticaldays) {
print "UPTIME CRITICAL: >$daysup days. Too long, reboot\n";
exit 2;
} else {
print "UPTIME OK: $uptime\n";
}
} else {
print "UPTIME OK: $uptime\n";
}
exit 0;
So your command definition looks like:
/usr/local/nagios/libexec/check_snmp_uptime.pl $HOSTADDRESS$ $USER21$ 161 720
From: Tom Denham [mailto:tdenham735 at gmail.com]
Sent: Tuesday, July 28, 2009 9:57 AM
To: nagios-users at lists.sourceforge.net
Subject: [Nagios-users] Nagios SNMP Plugin
Anyone out there have any examples of using Nagios SNMP plugin to perform simple queries for Cisco Routers and Linux boxes? I'm thinking of basic queries such as uptime, cpu, storage, etc..
I was thinking of using the check_snmp cmd, but syntax is a bit confusing...if you know of a better way that would be helpful too.
Thanks!
--
There's no place like $HOME.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20090728/47f2da3b/attachment.html>
-------------- next part --------------
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
-------------- next part --------------
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list