diff options
| -rw-r--r-- | ROADMAP | 117 | ||||
| -rw-r--r-- | configure.ac | 29 | ||||
| -rwxr-xr-x | opttest.pl | 50 | ||||
| -rw-r--r--[-rwxr-xr-x] | plugins-scripts/check_sensors.sh | 1 | ||||
| -rw-r--r-- | plugins/negate.c | 4 | ||||
| -rwxr-xr-x | tools/opttest.pl | 74 | 
6 files changed, 94 insertions, 181 deletions
| diff --git a/ROADMAP b/ROADMAP deleted file mode 100644 index 6378ec74..00000000 --- a/ROADMAP +++ /dev/null | |||
| @@ -1,117 +0,0 @@ | |||
| 1 | |||
| 2 | Releases in the 1.3 series will be for development. Version 1.4.0 will | ||
| 3 | be the next full production release. I am not planning on dates right now, | ||
| 4 | but you can expect maintennence releases for 1.2.9 as well. | ||
| 5 | |||
| 6 | With that done, it's time to figure out what we are doing for release | ||
| 7 | 1.3 development. I have a few ideas. Maybe others do as well. | ||
| 8 | |||
| 9 | DOCUMENTATION: | ||
| 10 | We pretty much have decided that we will doing something along | ||
| 11 | the lines of a literate programming model. So far, we have site | ||
| 12 | documentation in DocBook. I have some ideas here, which I will | ||
| 13 | discuss in a separate thread. | ||
| 14 | |||
| 15 | |||
| 16 | |||
| 17 | OPTION PROCESSING: | ||
| 18 | I believe we can remove reverse compatibility for non-Getopt | ||
| 19 | option specifications. For example, 'check_ping 1 2 3 4 -p 2' | ||
| 20 | would not be supported anymore. Support for this is a hack, | ||
| 21 | and making it portable is bug-prone. We should also review | ||
| 22 | standardization of our options -- the current list is a little | ||
| 23 | ad hoc, it should be nailed down. Details in a separate thread. | ||
| 24 | |||
| 25 | Also, | ||
| 26 | |||
| 27 | check_http -p 443 --ssl www.infoplease.com | ||
| 28 | |||
| 29 | should be fine, but if the getopt in use does not natively support it, | ||
| 30 | things like | ||
| 31 | |||
| 32 | check_http www.infoplease.com -p 443 --ssl | ||
| 33 | |||
| 34 | should be trapped and result in a call to one of the usage macros | ||
| 35 | (which print a message and then exit STATE_UNKNOWN). | ||
| 36 | |||
| 37 | This means that the call_getopt() function can go away. It's an | ||
| 38 | inconsistent mess and I'd love to ditch it. I only created it to | ||
| 39 | satisfy people that wanted reverse compatibility and did not have | ||
| 40 | GNU getopt. | ||
| 41 | |||
| 42 | But I would like to urge that all standard plugins contain | ||
| 43 | validate_arguments(). I think this will help convey the idea that | ||
| 44 | validations should be done, even if we don't insist on the specific | ||
| 45 | extent that each plugin must do that validation. | ||
| 46 | |||
| 47 | This is the set of standard options I envision: | ||
| 48 | |||
| 49 | Reserved: | ||
| 50 | |||
| 51 | -h, --help (REQUIRED!!!!!) | ||
| 52 | -V, --version (REQUIRED!!!!!) | ||
| 53 | -v, --verbose | ||
| 54 | -q, --quiet | ||
| 55 | -t, --timeout = INTEGER (senonds) | ||
| 56 | -c, --critical = (INT|FLOAT|RANGE|LIST) | ||
| 57 | -w, --warning = (INT|FLOAT|RANGE|LIST) | ||
| 58 | -H, --hostname = STRING | ||
| 59 | -F, --file = STRING (usually input) | ||
| 60 | -O, --output = STRING (output file) | ||
| 61 | |||
| 62 | Recommended, but not reserved: | ||
| 63 | |||
| 64 | -I, --ipaddress = STRING | ||
| 65 | -C, --community = STRING | ||
| 66 | -a, --auth(info) = STRING (authentication or password) | ||
| 67 | -l, --logname = STRING | ||
| 68 | -p, --password = STRING | ||
| 69 | -P, --port = INT | ||
| 70 | -u, --url = STRING (also --username if --url is not needed) | ||
| 71 | |||
| 72 | I am suggesting that port always be '-P' (uppercase) -- we are | ||
| 73 | currently inconsistent in that regard. | ||
| 74 | |||
| 75 | I am also adding '-q' for silent running. This is totally self | ||
| 76 | centered--I am planning to use a plugin in a cron script, and I | ||
| 77 | don't want nightly emails. | ||
| 78 | |||
| 79 | As has been the case, ranges are specified with colons, like 'i:j' | ||
| 80 | and list are specified with commas like 'i,k' and may contain ranges | ||
| 81 | if it makes sense to do so. Perhaps it would be good to build a | ||
| 82 | standard list/range processing function for this task. | ||
| 83 | |||
| 84 | |||
| 85 | Programming: | ||
| 86 | I would like to follow the GNU guidelines and remove all fixed | ||
| 87 | length character assignments, at least to the extent possible, | ||
| 88 | from the C-based plugins. To that end, I have made strscpy and | ||
| 89 | friends in utils.c -- I'd like to deploy them. I have comments | ||
| 90 | that there is a lot of duplicated code, and techniques used that | ||
| 91 | should be cleaned up. Details in a separate thread. | ||
| 92 | |||
| 93 | Remote checks: | ||
| 94 | I have a proposal in hand to incorporate ssh check into spopen() | ||
| 95 | so that remote machine checks can be seamless. A nice idea, but | ||
| 96 | complex enough to require discussion. Another thread. | ||
| 97 | |||
| 98 | I also have a wish list, and I'm sure I've forgot some items. I'll | ||
| 99 | list mine, please respond with other items that can be put into the | ||
| 100 | sourceforge task manager: | ||
| 101 | |||
| 102 | Indent all code in a GNU-compatible manner (indent -ts 2 -br) | ||
| 103 | Add RAND_seed to check_http for --ssl on systems without /dev/random | ||
| 104 | Add regex filtering to check_procs --args option | ||
| 105 | Add working procs syntax for AIX check_procs | ||
| 106 | Allow check_disk to exclude non-local disks | ||
| 107 | Add md5 checksumming to check_http | ||
| 108 | Complete unification of check_tcp and friends | ||
| 109 | Add SSL in a general way to check_tcp and friends | ||
| 110 | Patches to check_log from Joonas | ||
| 111 | Add calculator engine and snmpwalk to check_snmp | ||
| 112 | Is there a bug in check_oracle | ||
| 113 | Are there outstanding bugs in check_snmp | ||
| 114 | Change check_http --onredirect to default as STATE_UNKNOWN | ||
| 115 | Create plugin to check tftp servers | ||
| 116 | Create plugin wrapper to invert error status | ||
| 117 | |||
| diff --git a/configure.ac b/configure.ac index ef3d26e2..204fc6e3 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -1460,23 +1460,30 @@ AC_ARG_WITH(snmpget_command, | |||
| 1460 | ACX_HELP_STRING([--with-snmpget-command=PATH], | 1460 | ACX_HELP_STRING([--with-snmpget-command=PATH], | 
| 1461 | [Path to snmpget command]), | 1461 | [Path to snmpget command]), | 
| 1462 | PATH_TO_SNMPGET=$withval) | 1462 | PATH_TO_SNMPGET=$withval) | 
| 1463 | if test -n "$PATH_TO_SNMPGET" | ||
| 1464 | then | ||
| 1465 | AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary]) | ||
| 1466 | EXTRAS="$EXTRAS check_hpjd check_snmp\$(EXEEXT)" | ||
| 1467 | else | ||
| 1468 | AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins]) | ||
| 1469 | fi | ||
| 1470 | 1463 | ||
| 1471 | AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext) | 1464 | AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext) | 
| 1472 | AC_ARG_WITH(snmpgetnext_command, | 1465 | AC_ARG_WITH(snmpgetnext_command, | 
| 1473 | ACX_HELP_STRING([--with-snmpgetnext-command=PATH], | 1466 | ACX_HELP_STRING([--with-snmpgetnext-command=PATH], | 
| 1474 | [Path to snmpgetnext command]), | 1467 | [Path to snmpgetnext command]), | 
| 1475 | PATH_TO_SNMPGETNEXT=$withval) | 1468 | PATH_TO_SNMPGETNEXT=$withval) | 
| 1476 | if test -n "$PATH_TO_SNMPGETNEXT" | 1469 | |
| 1477 | then | 1470 | AS_IF([test -n "$PATH_TO_SNMPGET"], [ | 
| 1478 | AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary]) | 1471 | AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary]) | 
| 1479 | fi | 1472 | EXTRAS="$EXTRAS check_hpjd" | 
| 1473 | |||
| 1474 | dnl PATH_TO_SNMPGETNEXT is used unconditionally in check_snmp: | ||
| 1475 | dnl | ||
| 1476 | dnl https://github.com/nagios-plugins/nagios-plugins/issues/788 | ||
| 1477 | dnl | ||
| 1478 | AS_IF([test -n "$PATH_TO_SNMPGETNEXT"], [ | ||
| 1479 | AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary]) | ||
| 1480 | EXTRAS="$EXTRAS check_snmp\$(EXEEXT)" | ||
| 1481 | ], [ | ||
| 1482 | AC_MSG_WARN([Get snmpgetnext from https://net-snmp.sourceforge.io/ to build the check_snmp plugin]) | ||
| 1483 | ]) | ||
| 1484 | ], [ | ||
| 1485 | AC_MSG_WARN([Get snmpget from https://net-snmp.sourceforge.io/ to build the check_hpjd and check_snmp plugins]) | ||
| 1486 | ]) | ||
| 1480 | 1487 | ||
| 1481 | if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null ) | 1488 | if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null ) | 
| 1482 | then | 1489 | then | 
| diff --git a/opttest.pl b/opttest.pl deleted file mode 100755 index 85e3b494..00000000 --- a/opttest.pl +++ /dev/null | |||
| @@ -1,50 +0,0 @@ | |||
| 1 | #!/usr/bin/perl -w | ||
| 2 | use strict; | ||
| 3 | use Test; | ||
| 4 | |||
| 5 | use vars qw($dir $file $prog $idx $state $output %progs @dirs); | ||
| 6 | |||
| 7 | my $tests = 0; | ||
| 8 | |||
| 9 | @dirs = qw(plugins plugins-scripts); | ||
| 10 | |||
| 11 | foreach $dir (@dirs) { | ||
| 12 | opendir(DIR, $dir) || die "can't opendir $dir: $!"; | ||
| 13 | while ($file = readdir(DIR)) { | ||
| 14 | if (-x "$dir/$file" && -f "$dir/$file") { | ||
| 15 | $tests++; | ||
| 16 | $progs{"$dir/$file"} = $file; | ||
| 17 | } | ||
| 18 | } | ||
| 19 | closedir DIR; | ||
| 20 | } | ||
| 21 | |||
| 22 | plan tests => $tests; | ||
| 23 | |||
| 24 | for $prog (keys %progs) { | ||
| 25 | $state = 0; | ||
| 26 | $file = `basename $prog`; | ||
| 27 | |||
| 28 | $idx = 1; | ||
| 29 | $output = `$prog -h 2>&1`; | ||
| 30 | if($?) {$state++;print "$prog failed test $idx\n";} | ||
| 31 | unless ($output =~ m/$progs{$prog}/ms) { | ||
| 32 | $idx++; $state++;print "$output\n$prog failed test $idx\n"; | ||
| 33 | } | ||
| 34 | |||
| 35 | $idx++; | ||
| 36 | `$prog --help 2>&1 > /dev/null`; | ||
| 37 | if($?) {$state++;print "$prog failed test $idx\n";} | ||
| 38 | |||
| 39 | $idx++; | ||
| 40 | `$prog -V 2>&1 > /dev/null`; | ||
| 41 | if($?) {$state++;print "$prog failed test $idx\n";} | ||
| 42 | |||
| 43 | $idx++; | ||
| 44 | `$prog --version 2>&1 > /dev/null`; | ||
| 45 | if($?) {$state++;print "$prog failed test $idx\n";} | ||
| 46 | |||
| 47 | print "$prog ($idx tests) "; | ||
| 48 | ok $state,0; | ||
| 49 | } | ||
| 50 | |||
| diff --git a/plugins-scripts/check_sensors.sh b/plugins-scripts/check_sensors.sh index 866e0e0f..ba3581b1 100755..100644 --- a/plugins-scripts/check_sensors.sh +++ b/plugins-scripts/check_sensors.sh | |||
| @@ -20,7 +20,6 @@ print_help() { | |||
| 20 | echo "This plugin checks hardware status using the lm_sensors package." | 20 | echo "This plugin checks hardware status using the lm_sensors package." | 
| 21 | echo "" | 21 | echo "" | 
| 22 | support | 22 | support | 
| 23 | exit "$STATE_OK" | ||
| 24 | } | 23 | } | 
| 25 | 24 | ||
| 26 | case "$1" in | 25 | case "$1" in | 
| diff --git a/plugins/negate.c b/plugins/negate.c index 7e52fe67..750c0bfb 100644 --- a/plugins/negate.c +++ b/plugins/negate.c | |||
| @@ -133,11 +133,11 @@ static const char **process_arguments(int argc, char **argv) { | |||
| 133 | break; | 133 | break; | 
| 134 | case 'h': /* help */ | 134 | case 'h': /* help */ | 
| 135 | print_help(); | 135 | print_help(); | 
| 136 | exit(EXIT_SUCCESS); | 136 | exit(STATE_UNKNOWN); | 
| 137 | break; | 137 | break; | 
| 138 | case 'V': /* version */ | 138 | case 'V': /* version */ | 
| 139 | print_revision(progname, NP_VERSION); | 139 | print_revision(progname, NP_VERSION); | 
| 140 | exit(EXIT_SUCCESS); | 140 | exit(STATE_UNKNOWN); | 
| 141 | case 't': /* timeout period */ | 141 | case 't': /* timeout period */ | 
| 142 | if (!is_integer(optarg)) | 142 | if (!is_integer(optarg)) | 
| 143 | usage2(_("Timeout interval must be a positive integer"), optarg); | 143 | usage2(_("Timeout interval must be a positive integer"), optarg); | 
| diff --git a/tools/opttest.pl b/tools/opttest.pl new file mode 100755 index 00000000..98213082 --- /dev/null +++ b/tools/opttest.pl | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | #!/usr/bin/perl -w | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use Test; | ||
| 5 | |||
| 6 | # This script (when executed from the monitoring plugins top level directory) | ||
| 7 | # executes all the plugins with -h, --help, -V and --version to verify that | ||
| 8 | # all of them exit properly with the state UNKNOWN (3) | ||
| 9 | |||
| 10 | use vars qw($dir $file $prog $idx $state $output %progs @dirs); | ||
| 11 | |||
| 12 | my $tests = 0; | ||
| 13 | |||
| 14 | @dirs = qw(plugins plugins-scripts); | ||
| 15 | |||
| 16 | foreach my $dir (@dirs) { | ||
| 17 | opendir(DIR, $dir) || die "can't opendir $dir: $!"; | ||
| 18 | while ($file = readdir(DIR)) { | ||
| 19 | if (-x "$dir/$file" && -f "$dir/$file") { | ||
| 20 | $tests++; | ||
| 21 | $progs{"$dir/$file"} = $file; | ||
| 22 | } | ||
| 23 | } | ||
| 24 | closedir DIR; | ||
| 25 | } | ||
| 26 | |||
| 27 | plan tests => $tests; | ||
| 28 | |||
| 29 | for my $prog (keys %progs) { | ||
| 30 | $state = 0; | ||
| 31 | $file = `basename $prog`; | ||
| 32 | |||
| 33 | $idx = 1; | ||
| 34 | $output = `$prog -h 2>&1`; | ||
| 35 | if(($? >> 8) != 3) { | ||
| 36 | $state++; | ||
| 37 | print "$prog failed test $idx (help exit code (short form))\n"; | ||
| 38 | exit(1); | ||
| 39 | } | ||
| 40 | |||
| 41 | unless ($output =~ m/$progs{$prog}/ms) { | ||
| 42 | $idx++; | ||
| 43 | $state++; | ||
| 44 | print "$output\n$prog failed test $idx\n"; | ||
| 45 | } | ||
| 46 | |||
| 47 | $idx++; | ||
| 48 | `$prog --help 2>&1 > /dev/null`; | ||
| 49 | if(($? >> 8) != 3) { | ||
| 50 | $state++; | ||
| 51 | print "$prog failed test $idx (help exit code (long form))\n"; | ||
| 52 | exit(1); | ||
| 53 | } | ||
| 54 | |||
| 55 | $idx++; | ||
| 56 | `$prog -V 2>&1 > /dev/null`; | ||
| 57 | if(($? >> 8) != 3) { | ||
| 58 | $state++; | ||
| 59 | print "$prog failed test $idx (version exit code (short form))\n"; | ||
| 60 | exit(1); | ||
| 61 | } | ||
| 62 | |||
| 63 | $idx++; | ||
| 64 | `$prog --version 2>&1 > /dev/null`; | ||
| 65 | if(($? >> 8) != 3) { | ||
| 66 | $state++; | ||
| 67 | print "$prog failed test $idx (version exit code (long form))\n"; | ||
| 68 | exit(1); | ||
| 69 | } | ||
| 70 | |||
| 71 | print "$prog ($idx tests) "; | ||
| 72 | ok $state,0; | ||
| 73 | } | ||
| 74 | |||
