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:[email protected]]
Sent: Tuesday, July 28, 2009 9:57 AM
To: [email protected]
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.
------------------------------------------------------------------------------
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
_______________________________________________
Nagios-users mailing list
[email protected]
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