# HG changeset patch # User arnold # Date 1343897319 -7200 # Node ID 2fde8823787b7a5cdfa83a6c24d05ea838cd6ad3 import to mercurial diff -r 000000000000 -r 2fde8823787b .hgignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Thu Aug 02 10:48:39 2012 +0200 @@ -0,0 +1,8 @@ +syntax: glob +*.swp +debian/files +check_hddtemp + +syntax: regexp +(build|configure)-stamp$ +debian/nagios-plugin-hddtemp[./] diff -r 000000000000 -r 2fde8823787b .perltitdy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.perltitdy Thu Aug 02 10:48:39 2012 +0200 @@ -0,0 +1,2 @@ +--paren-tightness=2 +--square-bracket-tightness=2 diff -r 000000000000 -r 2fde8823787b Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile Thu Aug 02 10:48:39 2012 +0200 @@ -0,0 +1,22 @@ +SCRIPTS = check_hddtemp +CLEANFILES = ${SCRIPTS} +DESTDIR = +prefix = /usr + +plugindir = ${prefix}/lib/nagios/plugins/ius + +.PHONY: all clean install + +all: ${SCRIPTS} + +clean: + -rm -f ${CLEANFILES} + +install: all + install -d -m 0755 ${DESTDIR}/${plugindir} + install -m 0755 $(SCRIPTS) ${DESTDIR}/${plugindir}/ + +%: %.pl + @perl -c $< + @cp -f $< $@ + @chmod +x $@ diff -r 000000000000 -r 2fde8823787b check_hddtemp.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/check_hddtemp.pl Thu Aug 02 10:48:39 2012 +0200 @@ -0,0 +1,224 @@ +#! /usr/bin/perl -w + +# Copyright (C) 2012 Christian Arnold +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Christian Arnold + +use 5.010; +use strict; +use File::Basename; +use Getopt::Long; +use Pod::Usage; + +delete @ENV{ grep /^LC_/ => keys %ENV }; +$ENV{LANG} = "C"; +$ENV{LC_ALL} = "C"; + +sub version($$); +sub hddtemp($$$$); + +my %ERRORS = ( + OK => 0, + WARNING => 1, + CRITICAL => 2, + UNKNOWN => 3, + DEPENDENT => 4 +); + +my $ME = basename $0; +my $NAME = "HDDTEMP"; +my $VERSION = "1.5"; + +my ( @devices, @output ); + +my %opt = ( + "warning" => 55, + "critical" => 65, + "devices" => "/dev/sda,/dev/sdb", + "binary" => "/usr/sbin/hddtemp" +); + +MAIN: { + Getopt::Long::Configure('bundling'); + GetOptions( + "b|binary=s" => \$opt{binary}, + "d|devices=s" => \$opt{devices}, + "w|warning=i" => \$opt{warning}, + "c|critical=i" => \$opt{critical}, + "h|help" => sub { pod2usage( -verbose => 1, -exitval => $ERRORS{OK} ) }, + "m|man" => sub { pod2usage( -verbose => 2, -exitval => $ERRORS{OK} ) }, + "V|version" => sub { version( $ME, $VERSION ); exit $ERRORS{OK}; } + ) or pod2usage( -verbose => 1, -exitval => $ERRORS{CRITICAL} ); + + hddtemp( $opt{binary}, $opt{devices}, $opt{warning}, $opt{critical} ); +} + +sub hddtemp($$$$) { + my ( $binary, $devices, $warning, $critical ) = @_; + my $rc; + my %temp; + + if ( !-x $binary ) { + say "$NAME CRITICAL: $binary - not found or not executable"; + exit $ERRORS{CRITICAL}; + } + + my @devices = split( /,/, $devices ); + + foreach my $dev (@devices) { + if ( !-r $dev ) { + say +"$NAME CRITICAL: $dev - not exists or not read permission is granted"; + exit $ERRORS{CRITICAL}; + } + my @line = grep { /^$dev/ } `$binary $dev`; + + if ( $line[0] ) { + $line[0] =~ /^.*:\s.*:\s+(\d+)/; + if ( !$1 ) { + print "$NAME CRITICAL: $line[0]"; + exit $ERRORS{CRITICAL}; + } + + if ( $1 < $warning ) { $rc = $ERRORS{OK}; } + elsif ( ( $1 >= $warning ) and ( $1 < $critical ) ) { + $rc = $ERRORS{WARNING}; + } + else { $rc = $ERRORS{CRITICAL}; } + ${temp}{$dev}{"rc"}{$rc} = $1; + } + } + + my ( $ok, $warn, $crit ) = (0) x 4; + my @output = (); + my @perf = (); + foreach my $dev ( sort keys %temp ) { + if ( $temp{$dev}{'rc'}{'0'} ) { + $ok = 1; + push @output, "$dev $temp{$dev}{'rc'}{'0'} C"; + push @perf, "$dev=$temp{$dev}{'rc'}{'0'};$warning;$critical"; + } + if ( $temp{$dev}{'rc'}{'1'} ) { + $warn = 1; + push @output, "$dev $temp{$dev}{'rc'}{'1'} C"; + push @perf, "$dev=$temp{$dev}{'rc'}{'1'};$warning;$critical"; + } + if ( $temp{$dev}{'rc'}{'2'} ) { + $crit = 1; + push @output, "$dev $temp{$dev}{'rc'}{'2'} C"; + push @perf, "$dev=$temp{$dev}{'rc'}{'2'};$warning;$critical"; + } + } + + if ($crit) { + say "$NAME CRITICAL: " + . join( ' ', @output ) . " | " + . join( ' ', @perf ); + exit $ERRORS{CRITICAL}; + } + elsif ($warn) { + say "$NAME WARNING: " + . join( ' ', @output ) . " | " + . join( ' ', @perf ); + exit $ERRORS{WARNING}; + } + + say "$NAME OK: " . join( ' ', @output ) . " | " . join( ' ', @perf ); + exit $ERRORS{OK}; +} + +sub version($$) { + my ( $progname, $version ) = @_; + + say <<_VERSION; +$progname version $version +Copyright (C) 2012 by Christian Arnold and Schlittermann internet & unix support. + +$ME comes with ABSOLUTELY NO WARRANTY. This is free software, +and you are welcome to redistribute it under certain conditions. +See the GNU General Public Licence for details. +_VERSION +} + +__END__ + +=head1 NAME + +check_hddtemp - nagios plugin to check hard drive temperature + +=head1 SYNOPSIS + +check_hddtemp [B<-b>|B<--binary>] + +check_hddtemp [B<-w>|B<--warning>] + +check_hddtemp [B<-c>|B<--critical>] + +check_hddtemp [B<-d>|B<--devices>] + +=head1 OPTIONS + +=over + +=item B<-b>|B<--binary> + +Path to hddtemp binary (default: /usr/sbin/hddtemp) + +=item B<-w>|B<--warning> + +Temperature of your hard drive to generate warning alert (default: 55) + +=item B<-c>|B<--critical> + +Temperature of your hard drive to generate critical alert (default: 65) + +=item B<-d>|B<--devices> + +Device drive path (default: /dev/sda,/dev/sdb) + +=item B<-h>|B<--help> + +Print detailed help screen. + +=item B<-m>|B<--man> + +Print manual page. + +=item B<-V>|B<--version> + +Print version information. + +=back + +=head1 DESCRIPTION + +This plugin checks the hard drive temperature. + +=head1 VERSION + +This man page is current for version 1.5 of B. + +=head1 AUTHOR + +Written by Christian Arnold L + +=head1 COPYRIGHT + +Copyright (C) 2012 by Christian Arnold and Schlittermann internet & unix support. +This is free software, and you are welcome to redistribute it under certain conditions. +See the GNU General Public Licence for details. + +=cut diff -r 000000000000 -r 2fde8823787b debian/changelog --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/changelog Thu Aug 02 10:48:39 2012 +0200 @@ -0,0 +1,17 @@ +nagios-plugin-hddtemp (1.5) stable; urgency=low + + * change version string to 1.5 + + -- Christian Arnold Thu, 02 Aug 2012 10:40:28 +0200 + +nagios-plugin-hddtemp (1.4) stable; urgency=low + + * build for stable + + -- Christian Arnold Thu, 02 Aug 2012 10:31:41 +0200 + +nagios-plugin-hddtemp (1.3) unstable; urgency=low + + * Initial Release. + + -- Christian Arnold Thu, 02 Aug 2012 09:57:24 +0200 diff -r 000000000000 -r 2fde8823787b debian/compat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/compat Thu Aug 02 10:48:39 2012 +0200 @@ -0,0 +1,1 @@ +7 diff -r 000000000000 -r 2fde8823787b debian/control --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/control Thu Aug 02 10:48:39 2012 +0200 @@ -0,0 +1,13 @@ +Source: nagios-plugin-hddtemp +Section: net +Priority: extra +Maintainer: Christian Arnold +Build-Depends: debhelper (>= 7.0.50~) +Standards-Version: 3.9.1 +Homepage: https://keller.schlittermann.de/hg/ius/nagios/nagios-plugin-hddtemp/ + +Package: nagios-plugin-hddtemp +Architecture: all +Depends: ${misc:Depends}, hddtemp +Description: nagios plugin to check hard drive temperature + This is a nagios plugin to monitor hard drive temperature. diff -r 000000000000 -r 2fde8823787b debian/copyright --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/copyright Thu Aug 02 10:48:39 2012 +0200 @@ -0,0 +1,39 @@ +This work was packaged for Debian by: + + Christian Arnold on Thu, 02 Aug 2012 09:57:24 +0200 + +It was downloaded from: + + https://keller.schlittermann.de/hg/ius/nagios/nagios-plugin-hddtemp/ + +Upstream Author(s): + + Christian Arnold + +Copyright: + + Copyright (C) 2011 Schlittermann internet & unix support + +License: + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +On Debian systems, the complete text of the GNU General +Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". + +The Debian packaging is: + + Copyright (C) 2012 Christian Arnold + +and is licensed under the GPL version 3, see above. diff -r 000000000000 -r 2fde8823787b debian/rules --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/rules Thu Aug 02 10:48:39 2012 +0200 @@ -0,0 +1,13 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +%: + dh $@ diff -r 000000000000 -r 2fde8823787b debian/source/format --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/source/format Thu Aug 02 10:48:39 2012 +0200 @@ -0,0 +1,1 @@ +3.0 (native)