Wednesday, June 3, 2009

Nagios Temperature Monitoring

I have written a short nagios plugin for Nagios Temperature Monitoring .
This plugin will work on linux and it will use "mbmon" system utility to trace the system temperature.

Please check that "/usr/bin/mbmon" commad runs successfully in your system.
else install mobmon utility 
-------------Perl Script for Nagios Temperature Monitoring----
#! /usr/bin/perl -w
## Nagios-NRPE check Temperature Status
# Developed by Polo


$result="";
$error=0;
if ($status = `sudo /usr/bin/mbmon -c1 -T 7`)
{
@status = split(/\n/,$status);
$numlines = @status;
$count=0;
while ( $count < $numlines )
{
if ( $status[$count] > 60 )
{
$error = $error +1;
#$result=$result.','.$status[$count];
}
$result=$result.','.$status[$count];
$count++;
}
if ($error > 0)
{
$output= 'TEMPRATURE CRITICAL Status:'.$result."\n";
print $output;
exit 2;
}
else
{
$output= 'TEMPRATURE OK Status:'.$result."\n";
print $output;
exit 0;
}
}
else
{
exit 3;
}

No comments: