#! /usr/bin/perl -w # # 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 # Modificado para Debian por David Marti­n :: Suki_ :: # http://sukiweb.net/ # /etc/sudoers # ======================= #Cmnd_Alias HHDTEMP=/usr/local/sbin/hddtemp #user-nagios ALL=NOPASSWD:HHDTEMP sub print_help (); sub print_usage (); my $PROGNAME = "check_hddtemp"; my $STATE_CRITICAL = 2; my $STATE_OK = 0; my $STATE_WARNING = 1; my $commande_hddtemp=1; my $conffile = "/etc/hddtemp.db"; if ( $ARGV[0] eq "" || $ARGV[1] eq "" || $ARGV[2] eq "" ) { print_usage (); exit 0; } my $disco = $ARGV[0]; my $warning = $ARGV[1]; my $critik = $ARGV[2]; my $TEMP = (`sudo /usr/sbin/hddtemp -n $disco -f $conffile`); if ($TEMP ge $critik) { printf ("CRITICAL : Temperatura °C de $disco : $TEMP "); exit $STATE_CRITICAL ;; } if (($TEMP lt $critik)&&($TEMP lt $warning)) { printf ("OK : Temperatura °C de $disco : $TEMP "); exit $STATE_OK ;; } if (($TEMP ge $warning)&&($TEMP lt $critik)) { printf ("OK : Temperatura °C de $disco : $TEMP "); exit $STATE_OK ;; } if (($TEMP ge $warning)&&($TEMP lt $critik)) { printf ("WARNING : Temperatura °C de $disco : $TEMP "); exit $STATE_WARNING ;; } sub print_help () { print($PROGNAME,': 1.0'); printf "\n"; print "Copyright (c) 2003 Benjamin Jakubowski \ Perl Check Temperatura 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/sda warn, INTEGER Number of Temperatura HDD at wich a warning will be generated ( No Default ) critical, INTEGER Number of Temperatura HDD at wich a critical will be generated ( No Default )\n"; }