|
Check hddtemp dans Nagios Petit script utilisant la commande hddtemp et les fonctionnalites SMART de nos disque IDE, pour monitorer la temperature de nos disques dur :
#!/usr/bin/perl
#
# check_hddtemp.pl [device] [warn] [critical]
# Nagios script to get the temperatue of HDD from hddtemp
# author: Benjamin Jakubowski
# license: GPL - http://www.fsf.org/licenses/gpl.txt
#
# Changes and Modification
# ========================
# 09-Oct-2003 - Benjamin Jakubowski
# Created from check_hddtemp.pl
# using sudo to have root authentification with hddtemp
#
# /etc/sudoers
# =======================
#Cmnd_Alias HHDTEMP=/usr/local/sbin/hddtemp
#user-nagios ALL=NOPASSWD:HHDTEMP
sub print_help ();
sub print_usage ();
$PROGNAME = "check_hddtemp";
$STATE_CRITICAL = 2;
$STATE_OK = 0;
$STATE_WARNING = 1;
$commande_hddtemp=1;
##Définition de l'emplacement du fichier base de données de hddtemp
$conffile = "/etc/hddtemp.db";
if ( @ARGV[0] eq "" || @ARGV[1] eq "" || @ARGV[2] eq "" )
{
print_usage ();
exit 0;
}
@disque = @ARGV[0];
if ( @ARGV[0] eq "" || @ARGV[1] eq "" || @ARGV[2] eq "" )
{
print_usage ();
exit 0;
}
$warning = @ARGV[1];
$critik = @ARGV[2];
@temp = `sudo /usr/locl/sbin/hddtemp -n @disque -f $conffile`;
if ( $temp[0] >= $critik )
{
printf ("CRITICAL : Temperature °C du @disque : @temp");
exit $STATE_CRITICAL
;;
}
if (($temp[0] < $critik)&&($temp[0] < $warning))
{
printf ("OK : Temperature °C du @disque : @temp ");
exit $STATE_OK
;;
}
if (($temp[0] >= $warning)&&($temp[0] < $critik)))
{
printf ("OK : Temperature °C du @disque : @temp ");
exit $STATE_OK
;;
}
if (($temp[0] >= $warning)&&($temp[0] < $critik))
{
printf ("WARNING : Temperature °C du @disque : @temp ");
exit $STATE_WARNING
;;
}
sub print_help ()
{
print($PROGNAME,': 1.0');
printf "\n";
print "Copyright (c) 2003 Benjamin Jakubowski \
Perl Check Temperature HDD plugin for Nagios \
";
}
sub print_usage ()
{
print_help();
printf "\n\nUsage : check_hddtemp.pl [device][warn] [critical]\n
device, CHAR
The Hdd device ex : /dev/hda
warn, INTEGER
Number of Temperature HDD at wich a warning will be generated ( No Default )
critical, INTEGER
Number of Temperature HDD at wich a critical will be generated ( No Default )\n";
}
Posté par : Benj le 09/10/2003 ( 0 commentaire )
> Ajouter Votre Astuce
|
|