diff -r 5f67fdc48747 -r 21b771e60058 check_hddtemp.pl --- a/check_hddtemp.pl Thu Aug 02 11:03:44 2012 +0200 +++ b/check_hddtemp.pl Mon Jun 08 13:54:30 2015 +0200 @@ -1,6 +1,7 @@ #! /usr/bin/perl -w # Copyright (C) 2012 Christian Arnold +# Copyright (C) 2015 Matthias Förste # # 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 @@ -27,7 +28,7 @@ $ENV{LC_ALL} = "C"; sub version($$); -sub hddtemp($$$$); +sub hddtemp($$$$$); my %ERRORS = ( OK => 0, @@ -39,14 +40,15 @@ my $ME = basename $0; my $NAME = "HDDTEMP"; -my $VERSION = "1.6"; +my $VERSION = "1.7"; my ( @devices, @output ); my %opt = ( "warning" => 55, "critical" => 65, - "devices" => "/dev/sda,/dev/sdb", + "devices" => 'all', + "exclude" => '/dev/sg', "binary" => "/usr/sbin/hddtemp" ); @@ -55,6 +57,7 @@ GetOptions( "b|binary=s" => \$opt{binary}, "d|devices=s" => \$opt{devices}, + "x|exclude=s" => \$opt{exclude}, "w|warning=i" => \$opt{warning}, "c|critical=i" => \$opt{critical}, "h|help" => sub { pod2usage( -verbose => 1, -exitval => $ERRORS{OK} ) }, @@ -62,11 +65,11 @@ "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} ); + hddtemp( $opt{binary}, $opt{devices}, $opt{warning}, $opt{critical}, $opt{exclude} ); } -sub hddtemp($$$$) { - my ( $binary, $devices, $warning, $critical ) = @_; +sub hddtemp($$$$$) { + my ( $binary, $devices, $warning, $critical, $exclude ) = @_; my $rc; my %temp; @@ -75,7 +78,12 @@ exit $ERRORS{CRITICAL}; } - my @devices = split( /,/, $devices ); + my @devices; + if ($devices eq 'all') { + @devices = grep { not /$exclude/; } glob "/dev/[hs]d? /dev/cciss/c[0-9]d[0-9] /dev/tw[ael][0-9] /dev/sg*"; + } elsif (defined $devices) { + @devices = split( /,/, $devices ); + } foreach my $dev (@devices) { if ( !-r $dev ) { @@ -186,7 +194,12 @@ =item B<-d>|B<--devices> -Device drive path (default: /dev/sda,/dev/sdb) +Device drive path (default: all we can find) + +=item B<-x>|B<--exclude> + +A regular expression matching all devices we do not want to check (default: +'/dev/sg') =item B<-h>|B<--help> @@ -208,15 +221,16 @@ =head1 VERSION -This man page is current for version 1.6 of B. +This man page is current for version 1.7 of B. =head1 AUTHOR -Written by Christian Arnold L +Written by Christian Arnold L, Matthias Förste L =head1 COPYRIGHT -Copyright (C) 2012 by Christian Arnold and Schlittermann internet & unix support. +Copyright (C) 2012 by Christian Arnold and Schlittermann internet & unix +support, (C) 2015 by Matthias Förste 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.