mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-04-01 23:25:19 -04:00
commit
a7b3bb968a
4 changed files with 76 additions and 53 deletions
50
opttest.pl
50
opttest.pl
|
|
@ -1,50 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
use strict;
|
||||
use Test;
|
||||
|
||||
use vars qw($dir $file $prog $idx $state $output %progs @dirs);
|
||||
|
||||
my $tests = 0;
|
||||
|
||||
@dirs = qw(plugins plugins-scripts);
|
||||
|
||||
foreach $dir (@dirs) {
|
||||
opendir(DIR, $dir) || die "can't opendir $dir: $!";
|
||||
while ($file = readdir(DIR)) {
|
||||
if (-x "$dir/$file" && -f "$dir/$file") {
|
||||
$tests++;
|
||||
$progs{"$dir/$file"} = $file;
|
||||
}
|
||||
}
|
||||
closedir DIR;
|
||||
}
|
||||
|
||||
plan tests => $tests;
|
||||
|
||||
for $prog (keys %progs) {
|
||||
$state = 0;
|
||||
$file = `basename $prog`;
|
||||
|
||||
$idx = 1;
|
||||
$output = `$prog -h 2>&1`;
|
||||
if($?) {$state++;print "$prog failed test $idx\n";}
|
||||
unless ($output =~ m/$progs{$prog}/ms) {
|
||||
$idx++; $state++;print "$output\n$prog failed test $idx\n";
|
||||
}
|
||||
|
||||
$idx++;
|
||||
`$prog --help 2>&1 > /dev/null`;
|
||||
if($?) {$state++;print "$prog failed test $idx\n";}
|
||||
|
||||
$idx++;
|
||||
`$prog -V 2>&1 > /dev/null`;
|
||||
if($?) {$state++;print "$prog failed test $idx\n";}
|
||||
|
||||
$idx++;
|
||||
`$prog --version 2>&1 > /dev/null`;
|
||||
if($?) {$state++;print "$prog failed test $idx\n";}
|
||||
|
||||
print "$prog ($idx tests) ";
|
||||
ok $state,0;
|
||||
}
|
||||
|
||||
1
plugins-scripts/check_sensors.sh
Executable file → Normal file
1
plugins-scripts/check_sensors.sh
Executable file → Normal file
|
|
@ -20,7 +20,6 @@ print_help() {
|
|||
echo "This plugin checks hardware status using the lm_sensors package."
|
||||
echo ""
|
||||
support
|
||||
exit "$STATE_OK"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
|
|
|
|||
|
|
@ -133,11 +133,11 @@ static const char **process_arguments(int argc, char **argv) {
|
|||
break;
|
||||
case 'h': /* help */
|
||||
print_help();
|
||||
exit(EXIT_SUCCESS);
|
||||
exit(STATE_UNKNOWN);
|
||||
break;
|
||||
case 'V': /* version */
|
||||
print_revision(progname, NP_VERSION);
|
||||
exit(EXIT_SUCCESS);
|
||||
exit(STATE_UNKNOWN);
|
||||
case 't': /* timeout period */
|
||||
if (!is_integer(optarg))
|
||||
usage2(_("Timeout interval must be a positive integer"), optarg);
|
||||
|
|
|
|||
74
tools/opttest.pl
Executable file
74
tools/opttest.pl
Executable file
|
|
@ -0,0 +1,74 @@
|
|||
#!/usr/bin/perl -w
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test;
|
||||
|
||||
# This script (when executed from the monitoring plugins top level directory)
|
||||
# executes all the plugins with -h, --help, -V and --version to verify that
|
||||
# all of them exit properly with the state UNKNOWN (3)
|
||||
|
||||
use vars qw($dir $file $prog $idx $state $output %progs @dirs);
|
||||
|
||||
my $tests = 0;
|
||||
|
||||
@dirs = qw(plugins plugins-scripts);
|
||||
|
||||
foreach my $dir (@dirs) {
|
||||
opendir(DIR, $dir) || die "can't opendir $dir: $!";
|
||||
while ($file = readdir(DIR)) {
|
||||
if (-x "$dir/$file" && -f "$dir/$file") {
|
||||
$tests++;
|
||||
$progs{"$dir/$file"} = $file;
|
||||
}
|
||||
}
|
||||
closedir DIR;
|
||||
}
|
||||
|
||||
plan tests => $tests;
|
||||
|
||||
for my $prog (keys %progs) {
|
||||
$state = 0;
|
||||
$file = `basename $prog`;
|
||||
|
||||
$idx = 1;
|
||||
$output = `$prog -h 2>&1`;
|
||||
if(($? >> 8) != 3) {
|
||||
$state++;
|
||||
print "$prog failed test $idx (help exit code (short form))\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
unless ($output =~ m/$progs{$prog}/ms) {
|
||||
$idx++;
|
||||
$state++;
|
||||
print "$output\n$prog failed test $idx\n";
|
||||
}
|
||||
|
||||
$idx++;
|
||||
`$prog --help 2>&1 > /dev/null`;
|
||||
if(($? >> 8) != 3) {
|
||||
$state++;
|
||||
print "$prog failed test $idx (help exit code (long form))\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$idx++;
|
||||
`$prog -V 2>&1 > /dev/null`;
|
||||
if(($? >> 8) != 3) {
|
||||
$state++;
|
||||
print "$prog failed test $idx (version exit code (short form))\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$idx++;
|
||||
`$prog --version 2>&1 > /dev/null`;
|
||||
if(($? >> 8) != 3) {
|
||||
$state++;
|
||||
print "$prog failed test $idx (version exit code (long form))\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
print "$prog ($idx tests) ";
|
||||
ok $state,0;
|
||||
}
|
||||
|
||||
Loading…
Reference in a new issue