diff options
80 files changed, 963 insertions, 809 deletions
| @@ -35,6 +35,7 @@ NP-VERSION-FILE | |||
| 35 | /build-aux/install-sh | 35 | /build-aux/install-sh |
| 36 | /build-aux/missing | 36 | /build-aux/missing |
| 37 | /build-aux/mkinstalldirs | 37 | /build-aux/mkinstalldirs |
| 38 | /build-aux/test-driver | ||
| 38 | 39 | ||
| 39 | # /doc/ | 40 | # /doc/ |
| 40 | /doc/developer-guidelines.html | 41 | /doc/developer-guidelines.html |
diff --git a/.travis.yml b/.travis.yml index 21a1713c..6af1feef 100644 --- a/.travis.yml +++ b/.travis.yml | |||
| @@ -11,7 +11,10 @@ install: | |||
| 11 | - sudo apt-get install -qq --no-install-recommends perl autotools-dev libdbi-dev libldap2-dev libpq-dev libmysqlclient-dev libfreeradius-client-dev libkrb5-dev libnet-snmp-perl procps | 11 | - sudo apt-get install -qq --no-install-recommends perl autotools-dev libdbi-dev libldap2-dev libpq-dev libmysqlclient-dev libfreeradius-client-dev libkrb5-dev libnet-snmp-perl procps |
| 12 | - sudo apt-get install -qq --no-install-recommends libdbi0-dev libdbd-sqlite3 libssl-dev dnsutils snmp-mibs-downloader libsnmp-perl snmpd | 12 | - sudo apt-get install -qq --no-install-recommends libdbi0-dev libdbd-sqlite3 libssl-dev dnsutils snmp-mibs-downloader libsnmp-perl snmpd |
| 13 | - sudo apt-get install -qq --no-install-recommends fping snmp netcat smbclient fping pure-ftpd apache2 postfix libhttp-daemon-ssl-perl | 13 | - sudo apt-get install -qq --no-install-recommends fping snmp netcat smbclient fping pure-ftpd apache2 postfix libhttp-daemon-ssl-perl |
| 14 | - sudo apt-get install -qq --no-install-recommends libdbd-sybase-perl libnet-dns-perl | ||
| 15 | - sudo apt-get install -qq --no-install-recommends slapd ldap-utils | ||
| 14 | - sudo apt-get install -qq --no-install-recommends autoconf automake | 16 | - sudo apt-get install -qq --no-install-recommends autoconf automake |
| 17 | - sudo apt-get install -qq --no-install-recommends faketime | ||
| 15 | 18 | ||
| 16 | before_script: | 19 | before_script: |
| 17 | - tools/setup | 20 | - tools/setup |
| @@ -1,10 +0,0 @@ | |||
| 1 | |||
| 2 | All source code, binaries, documentation, and information contained | ||
| 3 | in this distribution are provided AS IS with NO WARRANTY OF ANY KIND, | ||
| 4 | INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY, AND FITNESS FOR | ||
| 5 | A PARTICULAR PURPOSE. | ||
| 6 | |||
| 7 | Nagios and the Nagios logo are trademarks of Ethan Galstad. All | ||
| 8 | other trademarks, servicemarks, registered trademarks, and | ||
| 9 | registered servicemarks are the property of their respective owner(s). | ||
| 10 | |||
diff --git a/Makefile.am b/Makefile.am index 9ee0800e..7e0d4131 100644 --- a/Makefile.am +++ b/Makefile.am | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | SUBDIRS = gl tap lib plugins plugins-scripts plugins-root po @PERLMODS_DIR@ | 3 | SUBDIRS = gl tap lib plugins plugins-scripts plugins-root po @PERLMODS_DIR@ |
| 4 | 4 | ||
| 5 | EXTRA_DIST = config.rpath \ | 5 | EXTRA_DIST = config.rpath \ |
| 6 | ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS CODING ChangeLog FAQ LEGAL NEWS \ | 6 | ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS CODING ChangeLog FAQ NEWS \ |
| 7 | NP-VERSION-GEN REQUIREMENTS SUPPORT THANKS \ | 7 | NP-VERSION-GEN REQUIREMENTS SUPPORT THANKS \ |
| 8 | NPTest.pm pkg \ | 8 | NPTest.pm pkg \ |
| 9 | config_test/Makefile config_test/run_tests config_test/child_test.c \ | 9 | config_test/Makefile config_test/run_tests config_test/child_test.c \ |
| @@ -1,9 +1,35 @@ | |||
| 1 | This file documents the major additions and syntax changes between releases. | 1 | This file documents the major additions and syntax changes between releases. |
| 2 | 2 | ||
| 3 | 2.1.2 ... | 3 | 2.2 [...] |
| 4 | ENHANCEMENTS | ||
| 5 | check_snmp's performance data now also includes warning/critical | ||
| 6 | thresholds | ||
| 7 | New check_snmp "-N" option to specify SNMPv3 context name | ||
| 8 | New check_nt "-l" parameters: seconds|minutes|hours|days | ||
| 9 | Make sure check_disk won't hang on hanging (network) file systems | ||
| 10 | New check_mailq -s option which tells the plugin to use sudo(8) | ||
| 11 | New -W/-C option for check_ldap to check number of entries (Gerhard Lausser) | ||
| 12 | The check_http -S/--ssl option now accepts the arguments "1.1" and "1.2" | ||
| 13 | to force TLSv1.1 and TLSv1.2 connections, respectively | ||
| 14 | The check_http -S/--ssl option now allows for specifying the desired | ||
| 15 | protocol with a "+" suffix to also accept newer versions | ||
| 16 | |||
| 4 | FIXES | 17 | FIXES |
| 18 | Let check_real terminate lines with CRLF when talking to the server, as | ||
| 19 | mandated by 2326 | ||
| 20 | Fix check_procs on HP-UX | ||
| 21 | check_smtp's -e/--expect option can now be combined with -S/--starttls | ||
| 5 | Fix incorrect performance data thresholds emitted by check_ups | 22 | Fix incorrect performance data thresholds emitted by check_ups |
| 6 | 23 | ||
| 24 | WARNINGS | ||
| 25 | The format of the performance data emitted by check_mrtgtraf has been | ||
| 26 | changed to comply with the development guidelines | ||
| 27 | check_ssh now returns CRITICAL for protocol/version errors | ||
| 28 | If a plugin is invoked with -h/--help or -V/--version, the exit status | ||
| 29 | is now UNKNOWN | ||
| 30 | The superseded check_ntp.pl was removed, please use check_ntp_peer or | ||
| 31 | check_ntp_time instead | ||
| 32 | |||
| 7 | 2.1.1 2nd December 2014 | 33 | 2.1.1 2nd December 2014 |
| 8 | FIXES | 34 | FIXES |
| 9 | Fix check_ntp's jitter checking | 35 | Fix check_ntp's jitter checking |
| @@ -334,3 +334,5 @@ Simon Meggle | |||
| 334 | Jonas Genannt | 334 | Jonas Genannt |
| 335 | Nick Peelman | 335 | Nick Peelman |
| 336 | Sebastian Herbszt | 336 | Sebastian Herbszt |
| 337 | Christopher Schultz | ||
| 338 | Matthias Hähnel | ||
diff --git a/configure.ac b/configure.ac index 2429e990..ce1728e3 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -156,6 +156,12 @@ AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket") | |||
| 156 | AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv") | 156 | AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv") |
| 157 | AC_SUBST(SOCKETLIBS) | 157 | AC_SUBST(SOCKETLIBS) |
| 158 | 158 | ||
| 159 | dnl Check for POSIX thread libraries | ||
| 160 | AC_CHECK_HEADERS(pthread.h) | ||
| 161 | AC_CHECK_LIB(pthread,pthread_create,THREADLIBS="-lpthread", | ||
| 162 | AC_CHECK_LIB(pthread,pthread_create,THREADLIBS="-lpthread -lrt",-lrt)) | ||
| 163 | AC_SUBST(THREADLIBS) | ||
| 164 | |||
| 159 | dnl | 165 | dnl |
| 160 | dnl check for math-related functions needing -lm | 166 | dnl check for math-related functions needing -lm |
| 161 | AC_CHECK_HEADERS(math.h) | 167 | AC_CHECK_HEADERS(math.h) |
| @@ -610,6 +616,7 @@ AC_DEFINE_UNQUOTED(SOCKET_SIZE_TYPE, $ac_cv_socket_size_type , | |||
| 610 | dnl #### Process table test | 616 | dnl #### Process table test |
| 611 | 617 | ||
| 612 | AC_PATH_PROG(PATH_TO_PS,ps) | 618 | AC_PATH_PROG(PATH_TO_PS,ps) |
| 619 | AC_PATH_PROG(PATH_TO_ENV,env) | ||
| 613 | 620 | ||
| 614 | AC_MSG_CHECKING(for ps syntax) | 621 | AC_MSG_CHECKING(for ps syntax) |
| 615 | AC_ARG_WITH(ps_command, | 622 | AC_ARG_WITH(ps_command, |
| @@ -931,6 +938,19 @@ then | |||
| 931 | ac_cv_ps_cols=6 | 938 | ac_cv_ps_cols=6 |
| 932 | AC_MSG_RESULT([$ac_cv_ps_command]) | 939 | AC_MSG_RESULT([$ac_cv_ps_command]) |
| 933 | 940 | ||
| 941 | dnl HP-UX: | ||
| 942 | dnl S UID RUID USER RUSER PID PPID VSZ %CPU COMMAND COMMAND | ||
| 943 | dnl S 0 400 root oracle 2805 1 12904 0.00 ora_dism_SEA1X ora_dism_SEA1X | ||
| 944 | dnl S 400 400 oracle oracle 19261 1 126488 0.00 tnslsnr /u01/app/oracle/product/db/11.2.0.3/bin/tnslsnr LISTENER -inherit | ||
| 945 | elif env UNIX95=1 ps -eo 'state uid ruid user ruser pid ppid vsz pcpu comm args' 2>/dev/null | head -n 1 | \ | ||
| 946 | egrep -i ["^ *S +UID +RUID +USER +RUSER +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null | ||
| 947 | then | ||
| 948 | ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]" | ||
| 949 | ac_cv_ps_command="$PATH_TO_ENV UNIX95=1 $PATH_TO_PS -eo 'state uid pid ppid vsz pcpu comm args'" | ||
| 950 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | ||
| 951 | ac_cv_ps_cols=8 | ||
| 952 | AC_MSG_RESULT([$ac_cv_ps_command]) | ||
| 953 | |||
| 934 | dnl AIX 4.1: | 954 | dnl AIX 4.1: |
| 935 | dnl F S UID PID PPID C PRI NI ADDR SZ RSS WCHAN TTY TIME CMD | 955 | dnl F S UID PID PPID C PRI NI ADDR SZ RSS WCHAN TTY TIME CMD |
| 936 | dnl 303 A 0 0 0 120 16 -- 1c07 20 24 - 0:45 swapper | 956 | dnl 303 A 0 0 0 120 16 -- 1c07 20 24 - 0:45 swapper |
| @@ -1464,6 +1484,16 @@ else | |||
| 1464 | AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin]) | 1484 | AC_MSG_WARN([Get ssh in order to make check_by_ssh plugin]) |
| 1465 | fi | 1485 | fi |
| 1466 | 1486 | ||
| 1487 | AC_PATH_PROG(PATH_TO_SUDO,sudo) | ||
| 1488 | AC_ARG_WITH(sudo_command, | ||
| 1489 | ACX_HELP_STRING([--with-sudo-command=PATH], | ||
| 1490 | [sets path to sudo]), PATH_TO_SUDO=$withval) | ||
| 1491 | if test -n "$PATH_TO_SUDO" | ||
| 1492 | then | ||
| 1493 | AC_DEFINE_UNQUOTED(PATH_TO_SUDO,"$PATH_TO_SUDO",[path to sudo]) | ||
| 1494 | else | ||
| 1495 | AC_MSG_WARN([Could not find sudo or eqivalent]) | ||
| 1496 | fi | ||
| 1467 | 1497 | ||
| 1468 | AC_PATH_PROG(PATH_TO_MAILQ,mailq) | 1498 | AC_PATH_PROG(PATH_TO_MAILQ,mailq) |
| 1469 | AC_ARG_WITH(mailq_command, | 1499 | AC_ARG_WITH(mailq_command, |
diff --git a/doc/RELEASING b/doc/RELEASING index 1eaec9de..30c81ccf 100644 --- a/doc/RELEASING +++ b/doc/RELEASING | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | NOTES ON RELEASING NEW VERSION OF NAGIOSPLUG | 1 | NOTES ON RELEASING NEW VERSION OF MONITORING-PLUGINS |
| 2 | 2 | ||
| 3 | *** Pre-release | 3 | *** Pre-release |
| 4 | git pull | 4 | git pull |
| @@ -6,55 +6,33 @@ git pull | |||
| 6 | check compilation, check tinderbox screens | 6 | check compilation, check tinderbox screens |
| 7 | 7 | ||
| 8 | *** Prepare and commit files | 8 | *** Prepare and commit files |
| 9 | Update BUGS, NEWS file | 9 | Update NEWS file |
| 10 | Update AUTHORS if new members | 10 | Update AUTHORS if new members |
| 11 | Update configure.in, package.def and NP-VERSION-GEN with version | 11 | Update configure.ac and NP-VERSION-GEN with version |
| 12 | Run git2cl (get from http://josefsson.org/git2cl/): | 12 | commit NEWS configure.ac NP-VERSION-GEN |
| 13 | git2cl >Changelog | ||
| 14 | commit BUGS NEWS configure.in package.def ChangeLog | ||
| 15 | 13 | ||
| 16 | *** Create new annotated tag | 14 | *** Create new annotated tag |
| 17 | git tag -a release-1.4.14 -m release-1.4.14 | 15 | git tag -a v2.1.1 -m v2.1.1 |
| 18 | 16 | ||
| 19 | *** Push the code and tag to origin | 17 | *** Push the code and tag to origin |
| 20 | git push origin master | 18 | git push origin master |
| 21 | git push origin release-1.4.14 | 19 | git push origin v2.1.1 |
| 22 | 20 | ||
| 23 | *** Checkout new version | 21 | *** Checkout new version |
| 24 | rm -fr /tmp/monitoringlug | 22 | rm -fr /tmp/monitoringplug |
| 25 | # If you need to checkout the tag, don't forget to "checkout master" later to | 23 | # If you need to checkout the tag, don't forget to "checkout master" later to |
| 26 | # get back to your development branch: | 24 | # get back to your development branch: |
| 27 | git checkout tags/release-1.4.14 | 25 | git checkout tags/v2.1.1 |
| 28 | # Beware: the trailing slash of --prefix is REQUIRED | 26 | # Beware: the trailing slash of --prefix is REQUIRED |
| 29 | git checkout-index --prefix=/tmp/monitoringlug/ -a | 27 | git checkout-index --prefix=/tmp/monitoringplug/ -a |
| 30 | 28 | ||
| 31 | *** Build the tarball | 29 | *** Build the tarball |
| 32 | cd /tmp/monitoringlug | 30 | cd /tmp/monitoringplug |
| 33 | tools/setup | 31 | tools/setup |
| 34 | ./configure | 32 | ./configure |
| 35 | make dist | 33 | make dist |
| 36 | 34 | ||
| 37 | *** Upload generated tarball to sourceforge | 35 | *** Upload generated tarball to our Project Site |
| 38 | sftp frs.sourceforge.net | ||
| 39 | SF username and password | ||
| 40 | cd /uploads | ||
| 41 | put file | ||
| 42 | |||
| 43 | SF -> Submit News about release. Make sure it is called "Monitoring Plugins" (with those caps) | ||
| 44 | Link to download at http://sourceforge.net/project/showfiles.php?group_id=29880 | ||
| 45 | Include contents of NEWS for this release | ||
| 46 | List all people on team involved. | ||
| 47 | Add acknowledgement to contributors | ||
| 48 | Submit. Get URL to news item | ||
| 49 | |||
| 50 | SF -> Admin -> File Releases | ||
| 51 | Add a release to nagiosplug and create a file release | ||
| 52 | Name: 1.4.14 | ||
| 53 | Create release | ||
| 54 | Step 1: Add release notes pointing to news item | ||
| 55 | Step 2: add file | ||
| 56 | Step 3: *.tar.gz, Platform Independent, Source .gz | ||
| 57 | Step 4: Send notice | ||
| 58 | 36 | ||
| 59 | *** Announce new release | 37 | *** Announce new release |
| 60 | Send email to help, announce with the news text | 38 | Send email to help, announce with the news text |
diff --git a/doc/developer-guidelines.sgml b/doc/developer-guidelines.sgml index d9340285..228d3fa1 100644 --- a/doc/developer-guidelines.sgml +++ b/doc/developer-guidelines.sgml | |||
| @@ -194,13 +194,15 @@ | |||
| 194 | <row> | 194 | <row> |
| 195 | <entry align="center"><para>3</para></entry> | 195 | <entry align="center"><para>3</para></entry> |
| 196 | <entry valign="middle"><para>Unknown</para></entry> | 196 | <entry valign="middle"><para>Unknown</para></entry> |
| 197 | <entry><para>Invalid command line arguments were supplied to the | 197 | <entry><para>Invalid command line arguments were supplied to the |
| 198 | plugin or low-level failures internal to the plugin (such as unable to fork, | 198 | plugin or low-level failures internal to the plugin (such as unable to fork, |
| 199 | or open a tcp socket) that prevent it from performing the specified | 199 | or open a tcp socket) that prevent it from performing the specified |
| 200 | operation. Higher-level errors (such as name resolution errors, | 200 | operation. Higher-level errors (such as name resolution errors, |
| 201 | socket timeouts, etc) are outside of the control of plugins and should | 201 | socket timeouts, etc) are outside of the control of plugins and should |
| 202 | generally NOT be reported as UNKNOWN states. | 202 | generally NOT be reported as UNKNOWN states. |
| 203 | </para></entry> | 203 | </para> |
| 204 | <para>The --help or --version output should also result in Unknown state.</para> | ||
| 205 | </entry> | ||
| 204 | </row> | 206 | </row> |
| 205 | </tbody> | 207 | </tbody> |
| 206 | </tgroup> | 208 | </tgroup> |
| @@ -610,6 +612,9 @@ | |||
| 610 | <para>The option -v or --verbose should be present in all plugins. | 612 | <para>The option -v or --verbose should be present in all plugins. |
| 611 | The user should be allowed to specify -v multiple times to increase | 613 | The user should be allowed to specify -v multiple times to increase |
| 612 | the verbosity level, as described in <xref linkend="verboselevels">.</para> | 614 | the verbosity level, as described in <xref linkend="verboselevels">.</para> |
| 615 | |||
| 616 | The exit code for version information or help should be UNKNOWN | ||
| 617 | (3).</para> | ||
| 613 | </section> | 618 | </section> |
| 614 | 619 | ||
| 615 | <section> | 620 | <section> |
diff --git a/lib/utils_cmd.c b/lib/utils_cmd.c index 9e214bd4..7eb9a3a0 100644 --- a/lib/utils_cmd.c +++ b/lib/utils_cmd.c | |||
| @@ -79,12 +79,14 @@ static pid_t *_cmd_pids = NULL; | |||
| 79 | * If that fails and the macro isn't defined, we fall back to an educated | 79 | * If that fails and the macro isn't defined, we fall back to an educated |
| 80 | * guess. There's no guarantee that our guess is adequate and the program | 80 | * guess. There's no guarantee that our guess is adequate and the program |
| 81 | * will die with SIGSEGV if it isn't and the upper boundary is breached. */ | 81 | * will die with SIGSEGV if it isn't and the upper boundary is breached. */ |
| 82 | #define DEFAULT_MAXFD 256 /* fallback value if no max open files value is set */ | ||
| 83 | #define MAXFD_LIMIT 8192 /* upper limit of open files */ | ||
| 82 | #ifdef _SC_OPEN_MAX | 84 | #ifdef _SC_OPEN_MAX |
| 83 | static long maxfd = 0; | 85 | static long maxfd = 0; |
| 84 | #elif defined(OPEN_MAX) | 86 | #elif defined(OPEN_MAX) |
| 85 | # define maxfd OPEN_MAX | 87 | # define maxfd OPEN_MAX |
| 86 | #else /* sysconf macro unavailable, so guess (may be wildly inaccurate) */ | 88 | #else /* sysconf macro unavailable, so guess (may be wildly inaccurate) */ |
| 87 | # define maxfd 256 | 89 | # define maxfd DEFAULT_MAXFD |
| 88 | #endif | 90 | #endif |
| 89 | 91 | ||
| 90 | 92 | ||
| @@ -112,10 +114,18 @@ cmd_init (void) | |||
| 112 | if (!maxfd && (maxfd = sysconf (_SC_OPEN_MAX)) < 0) { | 114 | if (!maxfd && (maxfd = sysconf (_SC_OPEN_MAX)) < 0) { |
| 113 | /* possibly log or emit a warning here, since there's no | 115 | /* possibly log or emit a warning here, since there's no |
| 114 | * guarantee that our guess at maxfd will be adequate */ | 116 | * guarantee that our guess at maxfd will be adequate */ |
| 115 | maxfd = 256; | 117 | maxfd = DEFAULT_MAXFD; |
| 116 | } | 118 | } |
| 117 | #endif | 119 | #endif |
| 118 | 120 | ||
| 121 | /* if maxfd is unnaturally high, we force it to a lower value | ||
| 122 | * ( e.g. on SunOS, when ulimit is set to unlimited: 2147483647 this would cause | ||
| 123 | * a segfault when following calloc is called ... ) */ | ||
| 124 | |||
| 125 | if ( maxfd > MAXFD_LIMIT ) { | ||
| 126 | maxfd = MAXFD_LIMIT; | ||
| 127 | } | ||
| 128 | |||
| 119 | if (!_cmd_pids) | 129 | if (!_cmd_pids) |
| 120 | _cmd_pids = calloc (maxfd, sizeof (pid_t)); | 130 | _cmd_pids = calloc (maxfd, sizeof (pid_t)); |
| 121 | } | 131 | } |
diff --git a/perlmods/Monitoring-Plugin-0.37.tar.gz b/perlmods/Monitoring-Plugin-0.37.tar.gz deleted file mode 100644 index bb6fe69e..00000000 --- a/perlmods/Monitoring-Plugin-0.37.tar.gz +++ /dev/null | |||
| Binary files differ | |||
diff --git a/perlmods/Monitoring-Plugin-0.39.tar.gz b/perlmods/Monitoring-Plugin-0.39.tar.gz new file mode 100644 index 00000000..7a35d9e7 --- /dev/null +++ b/perlmods/Monitoring-Plugin-0.39.tar.gz | |||
| Binary files differ | |||
diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c index 25d4ed40..d8afb172 100644 --- a/plugins-root/check_dhcp.c +++ b/plugins-root/check_dhcp.c | |||
| @@ -1142,11 +1142,11 @@ int call_getopt(int argc, char **argv){ | |||
| 1142 | 1142 | ||
| 1143 | case 'V': /* version */ | 1143 | case 'V': /* version */ |
| 1144 | print_revision(progname, NP_VERSION); | 1144 | print_revision(progname, NP_VERSION); |
| 1145 | exit(STATE_OK); | 1145 | exit(STATE_UNKNOWN); |
| 1146 | 1146 | ||
| 1147 | case 'h': /* help */ | 1147 | case 'h': /* help */ |
| 1148 | print_help(); | 1148 | print_help(); |
| 1149 | exit(STATE_OK); | 1149 | exit(STATE_UNKNOWN); |
| 1150 | 1150 | ||
| 1151 | case 'v': /* verbose */ | 1151 | case 'v': /* verbose */ |
| 1152 | verbose=1; | 1152 | verbose=1; |
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index 8b563e40..9ed12ba1 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c | |||
| @@ -184,7 +184,7 @@ static u_int get_timevar(const char *); | |||
| 184 | static u_int get_timevaldiff(struct timeval *, struct timeval *); | 184 | static u_int get_timevaldiff(struct timeval *, struct timeval *); |
| 185 | static in_addr_t get_ip_address(const char *); | 185 | static in_addr_t get_ip_address(const char *); |
| 186 | static int wait_for_reply(int, u_int); | 186 | static int wait_for_reply(int, u_int); |
| 187 | static int recvfrom_wto(int, void *, unsigned int, struct sockaddr *, u_int *); | 187 | static int recvfrom_wto(int, void *, unsigned int, struct sockaddr *, u_int *, struct timeval*); |
| 188 | static int send_icmp_ping(int, struct rta_host *); | 188 | static int send_icmp_ping(int, struct rta_host *); |
| 189 | static int get_threshold(char *str, threshold *th); | 189 | static int get_threshold(char *str, threshold *th); |
| 190 | static void run_checks(void); | 190 | static void run_checks(void); |
| @@ -378,6 +378,9 @@ main(int argc, char **argv) | |||
| 378 | int icmp_sockerrno, udp_sockerrno, tcp_sockerrno; | 378 | int icmp_sockerrno, udp_sockerrno, tcp_sockerrno; |
| 379 | int result; | 379 | int result; |
| 380 | struct rta_host *host; | 380 | struct rta_host *host; |
| 381 | #ifdef SO_TIMESTAMP | ||
| 382 | int on = 1; | ||
| 383 | #endif | ||
| 381 | 384 | ||
| 382 | setlocale (LC_ALL, ""); | 385 | setlocale (LC_ALL, ""); |
| 383 | bindtextdomain (PACKAGE, LOCALEDIR); | 386 | bindtextdomain (PACKAGE, LOCALEDIR); |
| @@ -402,6 +405,11 @@ main(int argc, char **argv) | |||
| 402 | /* now drop privileges (no effect if not setsuid or geteuid() == 0) */ | 405 | /* now drop privileges (no effect if not setsuid or geteuid() == 0) */ |
| 403 | setuid(getuid()); | 406 | setuid(getuid()); |
| 404 | 407 | ||
| 408 | #ifdef SO_TIMESTAMP | ||
| 409 | if(setsockopt(icmp_sock, SOL_SOCKET, SO_TIMESTAMP, &on, sizeof(on))) | ||
| 410 | if(debug) printf("Warning: no SO_TIMESTAMP support\n"); | ||
| 411 | #endif // SO_TIMESTAMP | ||
| 412 | |||
| 405 | /* POSIXLY_CORRECT might break things, so unset it (the portable way) */ | 413 | /* POSIXLY_CORRECT might break things, so unset it (the portable way) */ |
| 406 | environ = NULL; | 414 | environ = NULL; |
| 407 | 415 | ||
| @@ -462,13 +470,13 @@ main(int argc, char **argv) | |||
| 462 | /* parse the arguments */ | 470 | /* parse the arguments */ |
| 463 | for(i = 1; i < argc; i++) { | 471 | for(i = 1; i < argc; i++) { |
| 464 | while((arg = getopt(argc, argv, "vhVw:c:n:p:t:H:s:i:b:I:l:m:")) != EOF) { | 472 | while((arg = getopt(argc, argv, "vhVw:c:n:p:t:H:s:i:b:I:l:m:")) != EOF) { |
| 465 | long size; | 473 | unsigned short size; |
| 466 | switch(arg) { | 474 | switch(arg) { |
| 467 | case 'v': | 475 | case 'v': |
| 468 | debug++; | 476 | debug++; |
| 469 | break; | 477 | break; |
| 470 | case 'b': | 478 | case 'b': |
| 471 | size = strtol(optarg,NULL,0); | 479 | size = (unsigned short)strtol(optarg,NULL,0); |
| 472 | if (size >= (sizeof(struct icmp) + sizeof(struct icmp_ping_data)) && | 480 | if (size >= (sizeof(struct icmp) + sizeof(struct icmp_ping_data)) && |
| 473 | size < MAX_PING_DATA) { | 481 | size < MAX_PING_DATA) { |
| 474 | icmp_data_size = size; | 482 | icmp_data_size = size; |
| @@ -518,10 +526,10 @@ main(int argc, char **argv) | |||
| 518 | break; | 526 | break; |
| 519 | case 'V': /* version */ | 527 | case 'V': /* version */ |
| 520 | print_revision (progname, NP_VERSION); | 528 | print_revision (progname, NP_VERSION); |
| 521 | exit (STATE_OK); | 529 | exit (STATE_UNKNOWN); |
| 522 | case 'h': /* help */ | 530 | case 'h': /* help */ |
| 523 | print_help (); | 531 | print_help (); |
| 524 | exit (STATE_OK); | 532 | exit (STATE_UNKNOWN); |
| 525 | } | 533 | } |
| 526 | } | 534 | } |
| 527 | } | 535 | } |
| @@ -727,7 +735,7 @@ wait_for_reply(int sock, u_int t) | |||
| 727 | 735 | ||
| 728 | /* reap responses until we hit a timeout */ | 736 | /* reap responses until we hit a timeout */ |
| 729 | n = recvfrom_wto(sock, buf, sizeof(buf), | 737 | n = recvfrom_wto(sock, buf, sizeof(buf), |
| 730 | (struct sockaddr *)&resp_addr, &t); | 738 | (struct sockaddr *)&resp_addr, &t, &now); |
| 731 | if(!n) { | 739 | if(!n) { |
| 732 | if(debug > 1) { | 740 | if(debug > 1) { |
| 733 | printf("recvfrom_wto() timed out during a %u usecs wait\n", | 741 | printf("recvfrom_wto() timed out during a %u usecs wait\n", |
| @@ -777,11 +785,11 @@ wait_for_reply(int sock, u_int t) | |||
| 777 | /* this is indeed a valid response */ | 785 | /* this is indeed a valid response */ |
| 778 | memcpy(&data, icp.icmp_data, sizeof(data)); | 786 | memcpy(&data, icp.icmp_data, sizeof(data)); |
| 779 | if (debug > 2) | 787 | if (debug > 2) |
| 780 | printf("ICMP echo-reply of len %u, id %u, seq %u, cksum 0x%X\n", | 788 | printf("ICMP echo-reply of len %lu, id %u, seq %u, cksum 0x%X\n", |
| 781 | sizeof(data), ntohs(icp.icmp_id), ntohs(icp.icmp_seq), icp.icmp_cksum); | 789 | (unsigned long)sizeof(data), ntohs(icp.icmp_id), |
| 790 | ntohs(icp.icmp_seq), icp.icmp_cksum); | ||
| 782 | 791 | ||
| 783 | host = table[ntohs(icp.icmp_seq)/packets]; | 792 | host = table[ntohs(icp.icmp_seq)/packets]; |
| 784 | gettimeofday(&now, &tz); | ||
| 785 | tdiff = get_timevaldiff(&data.stime, &now); | 793 | tdiff = get_timevaldiff(&data.stime, &now); |
| 786 | 794 | ||
| 787 | host->time_waited += tdiff; | 795 | host->time_waited += tdiff; |
| @@ -823,6 +831,8 @@ send_icmp_ping(int sock, struct rta_host *host) | |||
| 823 | } packet = { NULL }; | 831 | } packet = { NULL }; |
| 824 | long int len; | 832 | long int len; |
| 825 | struct icmp_ping_data data; | 833 | struct icmp_ping_data data; |
| 834 | struct msghdr hdr; | ||
| 835 | struct iovec iov; | ||
| 826 | struct timeval tv; | 836 | struct timeval tv; |
| 827 | struct sockaddr *addr; | 837 | struct sockaddr *addr; |
| 828 | 838 | ||
| @@ -855,11 +865,27 @@ send_icmp_ping(int sock, struct rta_host *host) | |||
| 855 | packet.icp->icmp_cksum = icmp_checksum(packet.cksum_in, icmp_pkt_size); | 865 | packet.icp->icmp_cksum = icmp_checksum(packet.cksum_in, icmp_pkt_size); |
| 856 | 866 | ||
| 857 | if (debug > 2) | 867 | if (debug > 2) |
| 858 | printf("Sending ICMP echo-request of len %u, id %u, seq %u, cksum 0x%X to host %s\n", | 868 | printf("Sending ICMP echo-request of len %lu, id %u, seq %u, cksum 0x%X to host %s\n", |
| 859 | sizeof(data), ntohs(packet.icp->icmp_id), ntohs(packet.icp->icmp_seq), packet.icp->icmp_cksum, host->name); | 869 | (unsigned long)sizeof(data), ntohs(packet.icp->icmp_id), |
| 860 | 870 | ntohs(packet.icp->icmp_seq), packet.icp->icmp_cksum, | |
| 861 | len = sendto(sock, packet.buf, icmp_pkt_size, 0, (struct sockaddr *)addr, | 871 | host->name); |
| 862 | sizeof(struct sockaddr)); | 872 | |
| 873 | memset(&iov, 0, sizeof(iov)); | ||
| 874 | iov.iov_base = packet.buf; | ||
| 875 | iov.iov_len = icmp_pkt_size; | ||
| 876 | |||
| 877 | memset(&hdr, 0, sizeof(hdr)); | ||
| 878 | hdr.msg_name = addr; | ||
| 879 | hdr.msg_namelen = sizeof(struct sockaddr); | ||
| 880 | hdr.msg_iov = &iov; | ||
| 881 | hdr.msg_iovlen = 1; | ||
| 882 | |||
| 883 | /* MSG_CONFIRM is a linux thing and only available on linux kernels >= 2.3.15, see send(2) */ | ||
| 884 | #ifdef MSG_CONFIRM | ||
| 885 | len = sendmsg(sock, &hdr, MSG_CONFIRM); | ||
| 886 | #else | ||
| 887 | len = sendmsg(sock, &hdr, 0); | ||
| 888 | #endif | ||
| 863 | 889 | ||
| 864 | if(len < 0 || (unsigned int)len != icmp_pkt_size) { | 890 | if(len < 0 || (unsigned int)len != icmp_pkt_size) { |
| 865 | if(debug) printf("Failed to send ping to %s\n", | 891 | if(debug) printf("Failed to send ping to %s\n", |
| @@ -875,12 +901,18 @@ send_icmp_ping(int sock, struct rta_host *host) | |||
| 875 | 901 | ||
| 876 | static int | 902 | static int |
| 877 | recvfrom_wto(int sock, void *buf, unsigned int len, struct sockaddr *saddr, | 903 | recvfrom_wto(int sock, void *buf, unsigned int len, struct sockaddr *saddr, |
| 878 | u_int *timo) | 904 | u_int *timo, struct timeval* tv) |
| 879 | { | 905 | { |
| 880 | u_int slen; | 906 | u_int slen; |
| 881 | int n; | 907 | int n, ret; |
| 882 | struct timeval to, then, now; | 908 | struct timeval to, then, now; |
| 883 | fd_set rd, wr; | 909 | fd_set rd, wr; |
| 910 | char ans_data[4096]; | ||
| 911 | struct msghdr hdr; | ||
| 912 | struct iovec iov; | ||
| 913 | #ifdef SO_TIMESTAMP | ||
| 914 | struct cmsghdr* chdr; | ||
| 915 | #endif | ||
| 884 | 916 | ||
| 885 | if(!*timo) { | 917 | if(!*timo) { |
| 886 | if(debug) printf("*timo is not\n"); | 918 | if(debug) printf("*timo is not\n"); |
| @@ -904,7 +936,32 @@ recvfrom_wto(int sock, void *buf, unsigned int len, struct sockaddr *saddr, | |||
| 904 | 936 | ||
| 905 | slen = sizeof(struct sockaddr); | 937 | slen = sizeof(struct sockaddr); |
| 906 | 938 | ||
| 907 | return recvfrom(sock, buf, len, 0, saddr, &slen); | 939 | memset(&iov, 0, sizeof(iov)); |
| 940 | iov.iov_base = buf; | ||
| 941 | iov.iov_len = len; | ||
| 942 | |||
| 943 | memset(&hdr, 0, sizeof(hdr)); | ||
| 944 | hdr.msg_name = saddr; | ||
| 945 | hdr.msg_namelen = slen; | ||
| 946 | hdr.msg_iov = &iov; | ||
| 947 | hdr.msg_iovlen = 1; | ||
| 948 | hdr.msg_control = ans_data; | ||
| 949 | hdr.msg_controllen = sizeof(ans_data); | ||
| 950 | |||
| 951 | ret = recvmsg(sock, &hdr, 0); | ||
| 952 | #ifdef SO_TIMESTAMP | ||
| 953 | for(chdr = CMSG_FIRSTHDR(&hdr); chdr; chdr = CMSG_NXTHDR(&hdr, chdr)) { | ||
| 954 | if(chdr->cmsg_level == SOL_SOCKET | ||
| 955 | && chdr->cmsg_type == SO_TIMESTAMP | ||
| 956 | && chdr->cmsg_len >= CMSG_LEN(sizeof(struct timeval))) { | ||
| 957 | memcpy(tv, CMSG_DATA(chdr), sizeof(*tv)); | ||
| 958 | break ; | ||
| 959 | } | ||
| 960 | } | ||
| 961 | if (!chdr) | ||
| 962 | #endif // SO_TIMESTAMP | ||
| 963 | gettimeofday(tv, &tz); | ||
| 964 | return (ret); | ||
| 908 | } | 965 | } |
| 909 | 966 | ||
| 910 | static void | 967 | static void |
| @@ -1183,7 +1240,7 @@ static u_int | |||
| 1183 | get_timevar(const char *str) | 1240 | get_timevar(const char *str) |
| 1184 | { | 1241 | { |
| 1185 | char p, u, *ptr; | 1242 | char p, u, *ptr; |
| 1186 | unsigned int len; | 1243 | size_t len; |
| 1187 | u_int i, d; /* integer and decimal, respectively */ | 1244 | u_int i, d; /* integer and decimal, respectively */ |
| 1188 | u_int factor = 1000; /* default to milliseconds */ | 1245 | u_int factor = 1000; /* default to milliseconds */ |
| 1189 | 1246 | ||
diff --git a/plugins-scripts/Makefile.am b/plugins-scripts/Makefile.am index 794a34f8..ea65aed1 100644 --- a/plugins-scripts/Makefile.am +++ b/plugins-scripts/Makefile.am | |||
| @@ -36,6 +36,8 @@ TESTS = @SCRIPT_TEST@ | |||
| 36 | test: | 36 | test: |
| 37 | perl -I $(top_builddir) -I $(top_srcdir) ../test.pl | 37 | perl -I $(top_builddir) -I $(top_srcdir) ../test.pl |
| 38 | perl -I $(top_builddir) -I $(top_srcdir) ../test.pl t/utils.t # utils.t is excluded from above, so manually ask to test | 38 | perl -I $(top_builddir) -I $(top_srcdir) ../test.pl t/utils.t # utils.t is excluded from above, so manually ask to test |
| 39 | for SCRIPT in *.pl; do perl -wc $$SCRIPT || exit 1; done | ||
| 40 | set -e; for SCRIPT in *.sh; do sh -n $$SCRIPT || exit 1; done | ||
| 39 | 41 | ||
| 40 | test-debug: | 42 | test-debug: |
| 41 | NPTEST_DEBUG=1 HARNESS_VERBOSE=1 perl -I $(top_builddir) -I $(top_srcdir) ../test.pl | 43 | NPTEST_DEBUG=1 HARNESS_VERBOSE=1 perl -I $(top_builddir) -I $(top_srcdir) ../test.pl |
diff --git a/plugins-scripts/check_breeze.pl b/plugins-scripts/check_breeze.pl index 1a3aceba..05b99203 100755 --- a/plugins-scripts/check_breeze.pl +++ b/plugins-scripts/check_breeze.pl | |||
| @@ -6,7 +6,6 @@ use Getopt::Long; | |||
| 6 | use vars qw($opt_V $opt_h $opt_w $opt_c $opt_H $opt_C $PROGNAME); | 6 | use vars qw($opt_V $opt_h $opt_w $opt_c $opt_H $opt_C $PROGNAME); |
| 7 | use FindBin; | 7 | use FindBin; |
| 8 | use lib "$FindBin::Bin"; | 8 | use lib "$FindBin::Bin"; |
| 9 | use lib '@libexecdir@'; | ||
| 10 | use utils qw(%ERRORS &print_revision &support &usage); | 9 | use utils qw(%ERRORS &print_revision &support &usage); |
| 11 | 10 | ||
| 12 | $PROGNAME = "check_breeze"; | 11 | $PROGNAME = "check_breeze"; |
| @@ -29,10 +28,10 @@ GetOptions | |||
| 29 | 28 | ||
| 30 | if ($opt_V) { | 29 | if ($opt_V) { |
| 31 | print_revision($PROGNAME,'@NP_VERSION@'); | 30 | print_revision($PROGNAME,'@NP_VERSION@'); |
| 32 | exit $ERRORS{'OK'}; | 31 | exit $ERRORS{'UNKNOWN'}; |
| 33 | } | 32 | } |
| 34 | 33 | ||
| 35 | if ($opt_h) {print_help(); exit $ERRORS{'OK'};} | 34 | if ($opt_h) {print_help(); exit $ERRORS{'UNKNOWN'};} |
| 36 | 35 | ||
| 37 | ($opt_H) || usage("Host name/address not specified\n"); | 36 | ($opt_H) || usage("Host name/address not specified\n"); |
| 38 | my $host = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/); | 37 | my $host = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/); |
diff --git a/plugins-scripts/check_disk_smb.pl b/plugins-scripts/check_disk_smb.pl index 4805434f..98992268 100755 --- a/plugins-scripts/check_disk_smb.pl +++ b/plugins-scripts/check_disk_smb.pl | |||
| @@ -26,7 +26,6 @@ use vars qw($opt_P $opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_ | |||
| 26 | use vars qw($PROGNAME); | 26 | use vars qw($PROGNAME); |
| 27 | use FindBin; | 27 | use FindBin; |
| 28 | use lib "$FindBin::Bin"; | 28 | use lib "$FindBin::Bin"; |
| 29 | use lib '@libexecdir@'; | ||
| 30 | use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); | 29 | use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); |
| 31 | 30 | ||
| 32 | sub print_help (); | 31 | sub print_help (); |
| @@ -55,10 +54,10 @@ GetOptions | |||
| 55 | 54 | ||
| 56 | if ($opt_V) { | 55 | if ($opt_V) { |
| 57 | print_revision($PROGNAME,'@NP_VERSION@'); #' | 56 | print_revision($PROGNAME,'@NP_VERSION@'); #' |
| 58 | exit $ERRORS{'OK'}; | 57 | exit $ERRORS{'UNKNOWN'}; |
| 59 | } | 58 | } |
| 60 | 59 | ||
| 61 | if ($opt_h) {print_help(); exit $ERRORS{'OK'};} | 60 | if ($opt_h) {print_help(); exit $ERRORS{'UNKNOWN'};} |
| 62 | 61 | ||
| 63 | my $smbclient = $utils::PATH_TO_SMBCLIENT; | 62 | my $smbclient = $utils::PATH_TO_SMBCLIENT; |
| 64 | $smbclient || usage("check requires smbclient, smbclient not set\n"); | 63 | $smbclient || usage("check requires smbclient, smbclient not set\n"); |
diff --git a/plugins-scripts/check_file_age.pl b/plugins-scripts/check_file_age.pl index 4415fdf4..56b8e97c 100755 --- a/plugins-scripts/check_file_age.pl +++ b/plugins-scripts/check_file_age.pl | |||
| @@ -27,7 +27,6 @@ use File::stat; | |||
| 27 | use vars qw($PROGNAME); | 27 | use vars qw($PROGNAME); |
| 28 | use FindBin; | 28 | use FindBin; |
| 29 | use lib "$FindBin::Bin"; | 29 | use lib "$FindBin::Bin"; |
| 30 | use lib '@libexecdir@'; | ||
| 31 | use utils qw (%ERRORS &print_revision &support); | 30 | use utils qw (%ERRORS &print_revision &support); |
| 32 | 31 | ||
| 33 | sub print_help (); | 32 | sub print_help (); |
| @@ -61,12 +60,12 @@ GetOptions( | |||
| 61 | 60 | ||
| 62 | if ($opt_V) { | 61 | if ($opt_V) { |
| 63 | print_revision($PROGNAME, '@NP_VERSION@'); | 62 | print_revision($PROGNAME, '@NP_VERSION@'); |
| 64 | exit $ERRORS{'OK'}; | 63 | exit $ERRORS{'UNKNOWN'}; |
| 65 | } | 64 | } |
| 66 | 65 | ||
| 67 | if ($opt_h) { | 66 | if ($opt_h) { |
| 68 | print_help(); | 67 | print_help(); |
| 69 | exit $ERRORS{'OK'}; | 68 | exit $ERRORS{'UNKNOWN'}; |
| 70 | } | 69 | } |
| 71 | 70 | ||
| 72 | $opt_f = shift unless ($opt_f); | 71 | $opt_f = shift unless ($opt_f); |
diff --git a/plugins-scripts/check_flexlm.pl b/plugins-scripts/check_flexlm.pl index 5f3ed598..e3fe296f 100755 --- a/plugins-scripts/check_flexlm.pl +++ b/plugins-scripts/check_flexlm.pl | |||
| @@ -37,7 +37,6 @@ use Getopt::Long; | |||
| 37 | use vars qw($opt_V $opt_h $opt_F $opt_t $verbose $PROGNAME); | 37 | use vars qw($opt_V $opt_h $opt_F $opt_t $verbose $PROGNAME); |
| 38 | use FindBin; | 38 | use FindBin; |
| 39 | use lib "$FindBin::Bin"; | 39 | use lib "$FindBin::Bin"; |
| 40 | use lib '@libexecdir@'; | ||
| 41 | use utils qw(%ERRORS &print_revision &support &usage); | 40 | use utils qw(%ERRORS &print_revision &support &usage); |
| 42 | 41 | ||
| 43 | $PROGNAME="check_flexlm"; | 42 | $PROGNAME="check_flexlm"; |
| @@ -59,7 +58,7 @@ GetOptions | |||
| 59 | 58 | ||
| 60 | if ($opt_V) { | 59 | if ($opt_V) { |
| 61 | print_revision($PROGNAME,'@NP_VERSION@'); | 60 | print_revision($PROGNAME,'@NP_VERSION@'); |
| 62 | exit $ERRORS{'OK'}; | 61 | exit $ERRORS{'UNKNOWN'}; |
| 63 | } | 62 | } |
| 64 | 63 | ||
| 65 | unless (defined $opt_t) { | 64 | unless (defined $opt_t) { |
| @@ -67,7 +66,7 @@ unless (defined $opt_t) { | |||
| 67 | } | 66 | } |
| 68 | 67 | ||
| 69 | 68 | ||
| 70 | if ($opt_h) {print_help(); exit $ERRORS{'OK'};} | 69 | if ($opt_h) {print_help(); exit $ERRORS{'UNKNOWN'};} |
| 71 | 70 | ||
| 72 | unless (defined $opt_F) { | 71 | unless (defined $opt_F) { |
| 73 | print "Missing license.dat file\n"; | 72 | print "Missing license.dat file\n"; |
diff --git a/plugins-scripts/check_ifoperstatus.pl b/plugins-scripts/check_ifoperstatus.pl index cf2c7b58..3eed4bcb 100755 --- a/plugins-scripts/check_ifoperstatus.pl +++ b/plugins-scripts/check_ifoperstatus.pl | |||
| @@ -37,7 +37,6 @@ use POSIX; | |||
| 37 | use strict; | 37 | use strict; |
| 38 | use FindBin; | 38 | use FindBin; |
| 39 | use lib "$FindBin::Bin"; | 39 | use lib "$FindBin::Bin"; |
| 40 | use lib '@libexecdir@'; | ||
| 41 | use utils qw($TIMEOUT %ERRORS &print_revision &support); | 40 | use utils qw($TIMEOUT %ERRORS &print_revision &support); |
| 42 | 41 | ||
| 43 | use Net::SNMP; | 42 | use Net::SNMP; |
| @@ -368,17 +367,17 @@ sub process_arguments() { | |||
| 368 | 367 | ||
| 369 | if ($status == 0){ | 368 | if ($status == 0){ |
| 370 | print_help(); | 369 | print_help(); |
| 371 | exit $ERRORS{'OK'}; | 370 | exit $ERRORS{'UNKNOWN'}; |
| 372 | } | 371 | } |
| 373 | 372 | ||
| 374 | if ($opt_V) { | 373 | if ($opt_V) { |
| 375 | print_revision($PROGNAME,'@NP_VERSION@'); | 374 | print_revision($PROGNAME,'@NP_VERSION@'); |
| 376 | exit $ERRORS{'OK'}; | 375 | exit $ERRORS{'UNKNOWN'}; |
| 377 | } | 376 | } |
| 378 | 377 | ||
| 379 | if ($opt_h) { | 378 | if ($opt_h) { |
| 380 | print_help(); | 379 | print_help(); |
| 381 | exit $ERRORS{'OK'}; | 380 | exit $ERRORS{'UNKNOWN'}; |
| 382 | } | 381 | } |
| 383 | 382 | ||
| 384 | if (! utils::is_hostname($hostname)){ | 383 | if (! utils::is_hostname($hostname)){ |
diff --git a/plugins-scripts/check_ifstatus.pl b/plugins-scripts/check_ifstatus.pl index 6ec71d14..9f2f7c31 100755 --- a/plugins-scripts/check_ifstatus.pl +++ b/plugins-scripts/check_ifstatus.pl | |||
| @@ -35,7 +35,6 @@ use POSIX; | |||
| 35 | use strict; | 35 | use strict; |
| 36 | use FindBin; | 36 | use FindBin; |
| 37 | use lib "$FindBin::Bin"; | 37 | use lib "$FindBin::Bin"; |
| 38 | use lib '@libexecdir@'; | ||
| 39 | use utils qw($TIMEOUT %ERRORS &print_revision &support); | 38 | use utils qw($TIMEOUT %ERRORS &print_revision &support); |
| 40 | 39 | ||
| 41 | use Net::SNMP; | 40 | use Net::SNMP; |
| @@ -120,7 +119,7 @@ $status = process_arguments(); | |||
| 120 | if ($status != 0) | 119 | if ($status != 0) |
| 121 | { | 120 | { |
| 122 | print_help() ; | 121 | print_help() ; |
| 123 | exit $ERRORS{'OK'}; | 122 | exit $ERRORS{'UNKNOWN'}; |
| 124 | } | 123 | } |
| 125 | 124 | ||
| 126 | 125 | ||
| @@ -314,17 +313,17 @@ sub process_arguments() { | |||
| 314 | 313 | ||
| 315 | if ($status == 0){ | 314 | if ($status == 0){ |
| 316 | print_help(); | 315 | print_help(); |
| 317 | exit $ERRORS{'OK'}; | 316 | exit $ERRORS{'UNKNOWN'}; |
| 318 | } | 317 | } |
| 319 | 318 | ||
| 320 | if ($opt_V) { | 319 | if ($opt_V) { |
| 321 | print_revision($PROGNAME,'@NP_VERSION@'); | 320 | print_revision($PROGNAME,'@NP_VERSION@'); |
| 322 | exit $ERRORS{'OK'}; | 321 | exit $ERRORS{'UNKNOWN'}; |
| 323 | } | 322 | } |
| 324 | 323 | ||
| 325 | if ($opt_h) { | 324 | if ($opt_h) { |
| 326 | print_help(); | 325 | print_help(); |
| 327 | exit $ERRORS{'OK'}; | 326 | exit $ERRORS{'UNKNOWN'}; |
| 328 | } | 327 | } |
| 329 | 328 | ||
| 330 | unless (defined $timeout) { | 329 | unless (defined $timeout) { |
diff --git a/plugins-scripts/check_ircd.pl b/plugins-scripts/check_ircd.pl index 6d40cf5a..22d21c2e 100755 --- a/plugins-scripts/check_ircd.pl +++ b/plugins-scripts/check_ircd.pl | |||
| @@ -51,7 +51,6 @@ use vars qw($opt_V $opt_h $opt_t $opt_p $opt_H $opt_w $opt_c $verbose); | |||
| 51 | use vars qw($PROGNAME); | 51 | use vars qw($PROGNAME); |
| 52 | use FindBin; | 52 | use FindBin; |
| 53 | use lib "$FindBin::Bin"; | 53 | use lib "$FindBin::Bin"; |
| 54 | use lib '@libexecdir@'; | ||
| 55 | use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); | 54 | use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); |
| 56 | 55 | ||
| 57 | # ----------------------------------------------------[ Function Prototypes ]-- | 56 | # ----------------------------------------------------[ Function Prototypes ]-- |
| @@ -182,10 +181,10 @@ MAIN: | |||
| 182 | 181 | ||
| 183 | if ($opt_V) { | 182 | if ($opt_V) { |
| 184 | print_revision($PROGNAME,'@NP_VERSION@'); | 183 | print_revision($PROGNAME,'@NP_VERSION@'); |
| 185 | exit $ERRORS{'OK'}; | 184 | exit $ERRORS{'UNKNOWN'}; |
| 186 | } | 185 | } |
| 187 | 186 | ||
| 188 | if ($opt_h) {print_help(); exit $ERRORS{'OK'};} | 187 | if ($opt_h) {print_help(); exit $ERRORS{'UNKNOWN'};} |
| 189 | 188 | ||
| 190 | ($opt_H) || ($opt_H = shift @ARGV) || usage("Host name/address not specified\n"); | 189 | ($opt_H) || ($opt_H = shift @ARGV) || usage("Host name/address not specified\n"); |
| 191 | my $remotehost = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/); | 190 | my $remotehost = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/); |
diff --git a/plugins-scripts/check_mailq.pl b/plugins-scripts/check_mailq.pl index 0e8100d0..32f498d3 100755 --- a/plugins-scripts/check_mailq.pl +++ b/plugins-scripts/check_mailq.pl | |||
| @@ -28,14 +28,14 @@ | |||
| 28 | use POSIX; | 28 | use POSIX; |
| 29 | use strict; | 29 | use strict; |
| 30 | use Getopt::Long; | 30 | use Getopt::Long; |
| 31 | use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c $opt_t | 31 | use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c $opt_t $opt_s |
| 32 | $opt_M $mailq $status $state $msg $msg_q $msg_p $opt_W $opt_C $mailq @lines | 32 | $opt_M $mailq $status $state $msg $msg_q $msg_p $opt_W $opt_C $mailq @lines |
| 33 | %srcdomains %dstdomains); | 33 | %srcdomains %dstdomains); |
| 34 | use FindBin; | 34 | use FindBin; |
| 35 | use lib "$FindBin::Bin"; | 35 | use lib "$FindBin::Bin"; |
| 36 | use lib '@libexecdir@'; | ||
| 37 | use utils qw(%ERRORS &print_revision &support &usage ); | 36 | use utils qw(%ERRORS &print_revision &support &usage ); |
| 38 | 37 | ||
| 38 | my ($sudo); | ||
| 39 | 39 | ||
| 40 | sub print_help (); | 40 | sub print_help (); |
| 41 | sub print_usage (); | 41 | sub print_usage (); |
| @@ -57,6 +57,17 @@ if ($status){ | |||
| 57 | exit $ERRORS{"UNKNOWN"}; | 57 | exit $ERRORS{"UNKNOWN"}; |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | if ($opt_s) { | ||
| 61 | if (defined $utils::PATH_TO_SUDO && -x $utils::PATH_TO_SUDO) { | ||
| 62 | $sudo = $utils::PATH_TO_SUDO; | ||
| 63 | } else { | ||
| 64 | print "ERROR: Cannot execute sudo\n"; | ||
| 65 | exit $ERRORS{'UNKNOWN'}; | ||
| 66 | } | ||
| 67 | } else { | ||
| 68 | $sudo = ""; | ||
| 69 | } | ||
| 70 | |||
| 60 | $SIG{'ALRM'} = sub { | 71 | $SIG{'ALRM'} = sub { |
| 61 | print ("ERROR: timed out waiting for $utils::PATH_TO_MAILQ \n"); | 72 | print ("ERROR: timed out waiting for $utils::PATH_TO_MAILQ \n"); |
| 62 | exit $ERRORS{"WARNING"}; | 73 | exit $ERRORS{"WARNING"}; |
| @@ -69,7 +80,7 @@ if ($mailq eq "sendmail") { | |||
| 69 | 80 | ||
| 70 | ## open mailq | 81 | ## open mailq |
| 71 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { | 82 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { |
| 72 | if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) { | 83 | if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) { |
| 73 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; | 84 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; |
| 74 | exit $ERRORS{'UNKNOWN'}; | 85 | exit $ERRORS{'UNKNOWN'}; |
| 75 | } | 86 | } |
| @@ -298,7 +309,7 @@ elsif ( $mailq eq "postfix" ) { | |||
| 298 | 309 | ||
| 299 | ## open mailq | 310 | ## open mailq |
| 300 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { | 311 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { |
| 301 | if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) { | 312 | if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) { |
| 302 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; | 313 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; |
| 303 | exit $ERRORS{'UNKNOWN'}; | 314 | exit $ERRORS{'UNKNOWN'}; |
| 304 | } | 315 | } |
| @@ -380,7 +391,7 @@ elsif ( $mailq eq "qmail" ) { | |||
| 380 | 391 | ||
| 381 | # open qmail-qstat | 392 | # open qmail-qstat |
| 382 | if ( defined $utils::PATH_TO_QMAIL_QSTAT && -x $utils::PATH_TO_QMAIL_QSTAT ) { | 393 | if ( defined $utils::PATH_TO_QMAIL_QSTAT && -x $utils::PATH_TO_QMAIL_QSTAT ) { |
| 383 | if (! open (MAILQ, "$utils::PATH_TO_QMAIL_QSTAT | " ) ) { | 394 | if (! open (MAILQ, "$sudo $utils::PATH_TO_QMAIL_QSTAT | " ) ) { |
| 384 | print "ERROR: could not open $utils::PATH_TO_QMAIL_QSTAT \n"; | 395 | print "ERROR: could not open $utils::PATH_TO_QMAIL_QSTAT \n"; |
| 385 | exit $ERRORS{'UNKNOWN'}; | 396 | exit $ERRORS{'UNKNOWN'}; |
| 386 | } | 397 | } |
| @@ -462,7 +473,7 @@ elsif ( $mailq eq "qmail" ) { | |||
| 462 | elsif ( $mailq eq "exim" ) { | 473 | elsif ( $mailq eq "exim" ) { |
| 463 | ## open mailq | 474 | ## open mailq |
| 464 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { | 475 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { |
| 465 | if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) { | 476 | if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) { |
| 466 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; | 477 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; |
| 467 | exit $ERRORS{'UNKNOWN'}; | 478 | exit $ERRORS{'UNKNOWN'}; |
| 468 | } | 479 | } |
| @@ -505,7 +516,7 @@ elsif ( $mailq eq "exim" ) { | |||
| 505 | elsif ( $mailq eq "nullmailer" ) { | 516 | elsif ( $mailq eq "nullmailer" ) { |
| 506 | ## open mailq | 517 | ## open mailq |
| 507 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { | 518 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { |
| 508 | if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) { | 519 | if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) { |
| 509 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; | 520 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; |
| 510 | exit $ERRORS{'UNKNOWN'}; | 521 | exit $ERRORS{'UNKNOWN'}; |
| 511 | } | 522 | } |
| @@ -556,17 +567,18 @@ sub process_arguments(){ | |||
| 556 | "M:s" => \$opt_M, "mailserver:s" => \$opt_M, # mailserver (default sendmail) | 567 | "M:s" => \$opt_M, "mailserver:s" => \$opt_M, # mailserver (default sendmail) |
| 557 | "w=i" => \$opt_w, "warning=i" => \$opt_w, # warning if above this number | 568 | "w=i" => \$opt_w, "warning=i" => \$opt_w, # warning if above this number |
| 558 | "c=i" => \$opt_c, "critical=i" => \$opt_c, # critical if above this number | 569 | "c=i" => \$opt_c, "critical=i" => \$opt_c, # critical if above this number |
| 559 | "t=i" => \$opt_t, "timeout=i" => \$opt_t | 570 | "t=i" => \$opt_t, "timeout=i" => \$opt_t, |
| 571 | "s" => \$opt_s, "sudo" => \$opt_s | ||
| 560 | ); | 572 | ); |
| 561 | 573 | ||
| 562 | if ($opt_V) { | 574 | if ($opt_V) { |
| 563 | print_revision($PROGNAME,'@NP_VERSION@'); | 575 | print_revision($PROGNAME,'@NP_VERSION@'); |
| 564 | exit $ERRORS{'OK'}; | 576 | exit $ERRORS{'UNKNOWN'}; |
| 565 | } | 577 | } |
| 566 | 578 | ||
| 567 | if ($opt_h) { | 579 | if ($opt_h) { |
| 568 | print_help(); | 580 | print_help(); |
| 569 | exit $ERRORS{'OK'}; | 581 | exit $ERRORS{'UNKNOWN'}; |
| 570 | } | 582 | } |
| 571 | 583 | ||
| 572 | if (defined $opt_v ){ | 584 | if (defined $opt_v ){ |
| @@ -637,7 +649,7 @@ sub process_arguments(){ | |||
| 637 | } | 649 | } |
| 638 | 650 | ||
| 639 | sub print_usage () { | 651 | sub print_usage () { |
| 640 | print "Usage: $PROGNAME -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA>] [-t <timeout>] [-v verbose]\n"; | 652 | print "Usage: $PROGNAME -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA>] [-t <timeout>] [-s] [-v]\n"; |
| 641 | } | 653 | } |
| 642 | 654 | ||
| 643 | sub print_help () { | 655 | sub print_help () { |
| @@ -654,6 +666,7 @@ sub print_help () { | |||
| 654 | print "-C (--Critical) = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n"; | 666 | print "-C (--Critical) = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n"; |
| 655 | print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n"; | 667 | print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n"; |
| 656 | print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = autodetect)\n"; | 668 | print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = autodetect)\n"; |
| 669 | print "-s (--sudo) = Use sudo to call the mailq command\n"; | ||
| 657 | print "-h (--help)\n"; | 670 | print "-h (--help)\n"; |
| 658 | print "-V (--version)\n"; | 671 | print "-V (--version)\n"; |
| 659 | print "-v (--verbose) = debugging output\n"; | 672 | print "-v (--verbose) = debugging output\n"; |
diff --git a/plugins-scripts/check_mssql.pl b/plugins-scripts/check_mssql.pl index 1f387884..fb3952d4 100755 --- a/plugins-scripts/check_mssql.pl +++ b/plugins-scripts/check_mssql.pl | |||
| @@ -31,7 +31,6 @@ use DBD::Sybase; | |||
| 31 | use Getopt::Long; | 31 | use Getopt::Long; |
| 32 | use FindBin; | 32 | use FindBin; |
| 33 | use lib "$FindBin::Bin"; | 33 | use lib "$FindBin::Bin"; |
| 34 | use lib '@libexecdir@'; | ||
| 35 | use utils qw($TIMEOUT %ERRORS &print_revision &support); | 34 | use utils qw($TIMEOUT %ERRORS &print_revision &support); |
| 36 | use strict; | 35 | use strict; |
| 37 | 36 | ||
| @@ -131,7 +130,7 @@ sub process_arguments { | |||
| 131 | 130 | ||
| 132 | if (defined $opt_V) { | 131 | if (defined $opt_V) { |
| 133 | print_revision($PROGNAME,'@NP_VERSION@'); | 132 | print_revision($PROGNAME,'@NP_VERSION@'); |
| 134 | exit $ERRORS{'OK'}; | 133 | exit $ERRORS{'UNKNOWN'}; |
| 135 | } | 134 | } |
| 136 | 135 | ||
| 137 | syntax("Help:") if ($help); | 136 | syntax("Help:") if ($help); |
diff --git a/plugins-scripts/check_netdns.pl b/plugins-scripts/check_netdns.pl index 59c81a90..38538e56 100755 --- a/plugins-scripts/check_netdns.pl +++ b/plugins-scripts/check_netdns.pl | |||
| @@ -29,10 +29,12 @@ use Getopt::Long; | |||
| 29 | use Net::DNS; | 29 | use Net::DNS; |
| 30 | use FindBin; | 30 | use FindBin; |
| 31 | use lib "$FindBin::Bin"; | 31 | use lib "$FindBin::Bin"; |
| 32 | use lib '@libexecdir@'; | 32 | use utils; |
| 33 | use utils ; | ||
| 34 | 33 | ||
| 35 | my $PROGNAME = "check_netdns"; | 34 | my $PROGNAME = "check_netdns"; |
| 35 | sub print_help (); | ||
| 36 | sub print_version(); | ||
| 37 | sub print_usage (); | ||
| 36 | 38 | ||
| 37 | $ENV{'PATH'}='@TRUSTED_PATH@'; | 39 | $ENV{'PATH'}='@TRUSTED_PATH@'; |
| 38 | $ENV{'BASH_ENV'}=''; | 40 | $ENV{'BASH_ENV'}=''; |
| @@ -44,12 +46,12 @@ GetOptions("V" => $opt_V, "version" => $opt_V, | |||
| 44 | "t=i" => $opt_t, "timeout=i" => $opt_t, | 46 | "t=i" => $opt_t, "timeout=i" => $opt_t, |
| 45 | "s=s" => $opt_s, "server=s" => $opt_s, | 47 | "s=s" => $opt_s, "server=s" => $opt_s, |
| 46 | "H=s" => $opt_H, "hostname=s" => $opt_H); | 48 | "H=s" => $opt_H, "hostname=s" => $opt_H); |
| 47 | 49 | ||
| 48 | # -h means display verbose help screen | 50 | # -h means display verbose help screen |
| 49 | if($opt_h){ print_help(); exit 0; } | 51 | if($opt_h){ print_help(); exit 3; } |
| 50 | 52 | ||
| 51 | # -V means display version number | 53 | # -V means display version number |
| 52 | if ($opt_V) { print_version(); exit 0; } | 54 | if ($opt_V) { print_version(); exit 3; } |
| 53 | 55 | ||
| 54 | # -H means host name | 56 | # -H means host name |
| 55 | $opt_H = shift unless ($opt_H); | 57 | $opt_H = shift unless ($opt_H); |
| @@ -71,7 +73,7 @@ if ($opt_s) { | |||
| 71 | $server = $1; | 73 | $server = $1; |
| 72 | } else { | 74 | } else { |
| 73 | print "$opt_s is not a valid host name"; | 75 | print "$opt_s is not a valid host name"; |
| 74 | exit -1; | 76 | exit 3; |
| 75 | } | 77 | } |
| 76 | } | 78 | } |
| 77 | 79 | ||
diff --git a/plugins-scripts/check_ntp.pl b/plugins-scripts/check_ntp.pl deleted file mode 100755 index 13da939c..00000000 --- a/plugins-scripts/check_ntp.pl +++ /dev/null | |||
| @@ -1,471 +0,0 @@ | |||
| 1 | #!@PERL@ -w | ||
| 2 | # | ||
| 3 | # (c)1999 Ian Cass, Knowledge Matters Ltd. | ||
| 4 | # Read the GNU copyright stuff for all the legalese | ||
| 5 | # | ||
| 6 | # Check NTP time servers plugin. This plugin requires the ntpdate utility to | ||
| 7 | # be installed on the system, however since it's part of the ntp suite, you | ||
| 8 | # should already have it installed. | ||
| 9 | # | ||
| 10 | # | ||
| 11 | # Nothing clever done in this program - its a very simple bare basics hack to | ||
| 12 | # get the job done. | ||
| 13 | # | ||
| 14 | # Things to do... | ||
| 15 | # check @words[9] for time differences greater than +/- x secs & return a | ||
| 16 | # warning. | ||
| 17 | # | ||
| 18 | # (c) 1999 Mark Jewiss, Knowledge Matters Limited | ||
| 19 | # 22-9-1999, 12:45 | ||
| 20 | # | ||
| 21 | # Modified script to accept 2 parameters or set defaults. | ||
| 22 | # Now issues warning or critical alert is time difference is greater than the | ||
| 23 | # time passed. | ||
| 24 | # | ||
| 25 | # These changes have not been tested completely due to the unavailability of a | ||
| 26 | # server with the incorrect time. | ||
| 27 | # | ||
| 28 | # (c) 1999 Bo Kersey, VirCIO - Managed Server Solutions <bo@vircio.com> | ||
| 29 | # 22-10-99, 12:17 | ||
| 30 | # | ||
| 31 | # Modified the script to give useage if no parameters are input. | ||
| 32 | # | ||
| 33 | # Modified the script to check for negative as well as positive | ||
| 34 | # time differences. | ||
| 35 | # | ||
| 36 | # Modified the script to work with ntpdate 3-5.93e Wed Apr 14 20:23:03 EDT 1999 | ||
| 37 | # | ||
| 38 | # Modified the script to work with ntpdate's that return adjust or offset... | ||
| 39 | # | ||
| 40 | # | ||
| 41 | # Script modified 2000 June 01 by William Pietri <william@bianca.com> | ||
| 42 | # | ||
| 43 | # Modified script to handle weird cases: | ||
| 44 | # o NTP server doesn't respond (e.g., has died) | ||
| 45 | # o Server has correct time but isn't suitable synchronization | ||
| 46 | # source. This happens while starting up and if contact | ||
| 47 | # with master has been lost. | ||
| 48 | # | ||
| 49 | # Modifed to run under Embedded Perl (sghosh@users.sf.net) | ||
| 50 | # - combined logic some blocks together.. | ||
| 51 | # | ||
| 52 | # Added ntpdate check for stratum 16 desynch peer (James Fidell) Feb 03, 2003 | ||
| 53 | # | ||
| 54 | # ntpdate - offset is in seconds | ||
| 55 | # changed ntpdc to ntpq - jitter/dispersion is in milliseconds | ||
| 56 | # | ||
| 57 | # Patch for for regex for stratum1 refid. | ||
| 58 | |||
| 59 | require 5.004; | ||
| 60 | use POSIX; | ||
| 61 | use strict; | ||
| 62 | use Getopt::Long; | ||
| 63 | use vars qw($opt_V $opt_h $opt_H $opt_t $opt_w $opt_c $opt_O $opt_j $opt_k $verbose $PROGNAME $def_jitter $ipv4 $ipv6); | ||
| 64 | use lib utils.pm; | ||
| 65 | use utils qw($TIMEOUT %ERRORS &print_revision &support); | ||
| 66 | |||
| 67 | $PROGNAME="check_ntp"; | ||
| 68 | |||
| 69 | sub print_help (); | ||
| 70 | sub print_usage (); | ||
| 71 | |||
| 72 | $ENV{'PATH'}='@TRUSTED_PATH@'; | ||
| 73 | $ENV{'BASH_ENV'}=''; | ||
| 74 | $ENV{'ENV'}=''; | ||
| 75 | |||
| 76 | # defaults in sec | ||
| 77 | my $DEFAULT_OFFSET_WARN = 60; # 1 minute | ||
| 78 | my $DEFAULT_OFFSET_CRIT = 120; # 2 minutes | ||
| 79 | # default in millisec | ||
| 80 | my $DEFAULT_JITTER_WARN = 5000; # 5 sec | ||
| 81 | my $DEFAULT_JITTER_CRIT = 10000; # 10 sec | ||
| 82 | |||
| 83 | Getopt::Long::Configure('bundling'); | ||
| 84 | GetOptions | ||
| 85 | ("V" => \$opt_V, "version" => \$opt_V, | ||
| 86 | "h" => \$opt_h, "help" => \$opt_h, | ||
| 87 | "v" => \$verbose, "verbose" => \$verbose, | ||
| 88 | "4" => \$ipv4, "use-ipv4" => \$ipv4, | ||
| 89 | "6" => \$ipv6, "use-ipv6" => \$ipv6, | ||
| 90 | "w=f" => \$opt_w, "warning=f" => \$opt_w, # offset|adjust warning if above this number | ||
| 91 | "c=f" => \$opt_c, "critical=f" => \$opt_c, # offset|adjust critical if above this number | ||
| 92 | "O" => \$opt_O, "zero-offset" => \$opt_O, # zero-offset bad | ||
| 93 | "j=s" => \$opt_j, "jwarn=i" => \$opt_j, # jitter warning if above this number | ||
| 94 | "k=s" => \$opt_k, "jcrit=i" => \$opt_k, # jitter critical if above this number | ||
| 95 | "t=s" => \$opt_t, "timeout=i" => \$opt_t, | ||
| 96 | "H=s" => \$opt_H, "hostname=s" => \$opt_H); | ||
| 97 | |||
| 98 | if ($opt_V) { | ||
| 99 | print_revision($PROGNAME,'@NP_VERSION@'); | ||
| 100 | exit $ERRORS{'OK'}; | ||
| 101 | } | ||
| 102 | |||
| 103 | if ($opt_h) { | ||
| 104 | print_help(); | ||
| 105 | exit $ERRORS{'OK'}; | ||
| 106 | } | ||
| 107 | |||
| 108 | # jitter test params specified | ||
| 109 | if (defined $opt_j || defined $opt_k ) { | ||
| 110 | $def_jitter = 1; | ||
| 111 | } | ||
| 112 | |||
| 113 | $opt_H = shift unless ($opt_H); | ||
| 114 | my $host = $1 if ($opt_H && $opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]+(\.[a-zA-Z][-a-zA-Z0-9]+)*)$/); | ||
| 115 | unless ($host) { | ||
| 116 | print "No target host specified\n"; | ||
| 117 | print_usage(); | ||
| 118 | exit $ERRORS{'UNKNOWN'}; | ||
| 119 | } | ||
| 120 | |||
| 121 | my ($timeout, $owarn, $ocrit, $jwarn, $jcrit); | ||
| 122 | |||
| 123 | $timeout = $TIMEOUT; | ||
| 124 | ($opt_t) && ($opt_t =~ /^([0-9]+)$/) && ($timeout = $1); | ||
| 125 | |||
| 126 | $owarn = $DEFAULT_OFFSET_WARN; | ||
| 127 | ($opt_w) && ($opt_w =~ /^([0-9.]+)$/) && ($owarn = $1); | ||
| 128 | |||
| 129 | $ocrit = $DEFAULT_OFFSET_CRIT; | ||
| 130 | ($opt_c) && ($opt_c =~ /^([0-9.]+)$/) && ($ocrit = $1); | ||
| 131 | |||
| 132 | $jwarn = $DEFAULT_JITTER_WARN; | ||
| 133 | ($opt_j) && ($opt_j =~ /^([0-9]+)$/) && ($jwarn = $1); | ||
| 134 | |||
| 135 | $jcrit = $DEFAULT_JITTER_CRIT; | ||
| 136 | ($opt_k) && ($opt_k =~ /^([0-9]+)$/) && ($jcrit = $1); | ||
| 137 | |||
| 138 | if ($ocrit < $owarn ) { | ||
| 139 | print "Critical offset should be larger than warning offset\n"; | ||
| 140 | print_usage(); | ||
| 141 | exit $ERRORS{"UNKNOWN"}; | ||
| 142 | } | ||
| 143 | |||
| 144 | if ($def_jitter) { | ||
| 145 | if ($opt_k < $opt_j) { | ||
| 146 | print "Critical jitter should be larger than warning jitter\n"; | ||
| 147 | print_usage(); | ||
| 148 | exit $ERRORS{'UNKNOWN'}; | ||
| 149 | } | ||
| 150 | } | ||
| 151 | |||
| 152 | |||
| 153 | my $stratum = -1; | ||
| 154 | my $ignoreret = 0; | ||
| 155 | my $answer = undef; | ||
| 156 | my $offset = undef; | ||
| 157 | my $jitter = undef; | ||
| 158 | my $syspeer = undef; | ||
| 159 | my $candidate = 0; | ||
| 160 | my @candidates; | ||
| 161 | my $msg; # first line of output to print if format is invalid | ||
| 162 | |||
| 163 | my $state = $ERRORS{'UNKNOWN'}; | ||
| 164 | my $ntpdate_error = $ERRORS{'UNKNOWN'}; | ||
| 165 | my $jitter_error = $ERRORS{'UNKNOWN'}; | ||
| 166 | |||
| 167 | # some systems don't have a proper ntpq (migrated from ntpdc) | ||
| 168 | my $have_ntpq = undef; | ||
| 169 | if ($utils::PATH_TO_NTPQ && -x $utils::PATH_TO_NTPQ ) { | ||
| 170 | $have_ntpq = 1; | ||
| 171 | }else{ | ||
| 172 | $have_ntpq = 0; | ||
| 173 | } | ||
| 174 | |||
| 175 | # Just in case of problems, let's not hang Nagios | ||
| 176 | $SIG{'ALRM'} = sub { | ||
| 177 | print ("ERROR: No response from ntp server (alarm)\n"); | ||
| 178 | exit $ERRORS{"UNKNOWN"}; | ||
| 179 | }; | ||
| 180 | alarm($timeout); | ||
| 181 | |||
| 182 | # Determine protocol to be used for ntpdate and ntpq | ||
| 183 | my $ntpdate = $utils::PATH_TO_NTPDATE; | ||
| 184 | my $ntpq = $utils::PATH_TO_NTPQ; | ||
| 185 | if ($ipv4) { | ||
| 186 | $ntpdate .= " -4"; | ||
| 187 | $ntpq .= " -4"; | ||
| 188 | } | ||
| 189 | elsif ($ipv6) { | ||
| 190 | $ntpdate .= " -6"; | ||
| 191 | $ntpq .= " -6"; | ||
| 192 | } | ||
| 193 | # else don't use any flags | ||
| 194 | |||
| 195 | ### | ||
| 196 | ### | ||
| 197 | ### First, check ntpdate | ||
| 198 | ### | ||
| 199 | ### | ||
| 200 | |||
| 201 | if (!open (NTPDATE, $ntpdate . " -q $host 2>&1 |")) { | ||
| 202 | print "Could not open $ntpdate: $!\n"; | ||
| 203 | exit $ERRORS{"UNKNOWN"}; | ||
| 204 | } | ||
| 205 | |||
| 206 | my $out; | ||
| 207 | while (<NTPDATE>) { | ||
| 208 | #print if ($verbose); # noop | ||
| 209 | $msg = $_ unless ($msg); | ||
| 210 | $out .= "$_ "; | ||
| 211 | |||
| 212 | if (/stratum\s(\d+)/) { | ||
| 213 | $stratum = $1; | ||
| 214 | } | ||
| 215 | |||
| 216 | if (/(offset|adjust)\s+([-.\d]+)/i) { | ||
| 217 | $offset = $2; | ||
| 218 | |||
| 219 | # An offset of 0.000000 with an error is probably bogus. Actually, | ||
| 220 | # it's probably always bogus, but let's be paranoid here. | ||
| 221 | # Has been reported that 0.0000 happens in a production environment | ||
| 222 | # on Solaris 8 so this check should be taken out - SF tracker 1150777 | ||
| 223 | if (defined $opt_O ) { | ||
| 224 | if ($offset == 0) { undef $offset;} | ||
| 225 | } | ||
| 226 | |||
| 227 | $ntpdate_error = defined ($offset) ? $ERRORS{"OK"} : $ERRORS{"CRITICAL"}; | ||
| 228 | print "ntperr = $ntpdate_error \n" if $verbose; | ||
| 229 | |||
| 230 | } | ||
| 231 | |||
| 232 | if (/no server suitable for synchronization found/) { | ||
| 233 | if ($stratum == 16) { | ||
| 234 | $ntpdate_error = $ERRORS{"WARNING"}; | ||
| 235 | $msg = "Desynchronized peer server found"; | ||
| 236 | $ignoreret=1; | ||
| 237 | } | ||
| 238 | else { | ||
| 239 | $ntpdate_error = $ERRORS{"CRITICAL"}; | ||
| 240 | $msg = "No suitable peer server found - "; | ||
| 241 | } | ||
| 242 | } | ||
| 243 | |||
| 244 | } | ||
| 245 | $out =~ s/\n//g; | ||
| 246 | close (NTPDATE) || | ||
| 247 | die $! ? "$out - Error closing $ntpdate pipe: $!" | ||
| 248 | : "$out - Exit status: $? from $ntpdate\n"; | ||
| 249 | |||
| 250 | # declare an error if we also get a non-zero return code from ntpdate | ||
| 251 | # unless already set to critical | ||
| 252 | if ( $? && !$ignoreret ) { | ||
| 253 | print "stderr = $? : $! \n" if $verbose; | ||
| 254 | $ntpdate_error = $ntpdate_error == $ERRORS{"CRITICAL"} ? $ERRORS{"CRITICAL"} : $ERRORS{"UNKNOWN"} ; | ||
| 255 | print "ntperr = $ntpdate_error : $!\n" if $verbose; | ||
| 256 | } | ||
| 257 | |||
| 258 | ### | ||
| 259 | ### | ||
| 260 | ### Then scan xntpq/ntpq if it exists | ||
| 261 | ### and look in the 11th column for jitter | ||
| 262 | ### | ||
| 263 | # Field 1: Tally Code ( Space, 'x','.','-','+','#','*','o') | ||
| 264 | # Only match for '*' which implies sys.peer | ||
| 265 | # or 'o' which implies pps.peer | ||
| 266 | # If both exist, the last one is picked. | ||
| 267 | # Field 2: address of the remote peer | ||
| 268 | # Field 3: Refid of the clock (0.0.0.0 if unknown, WWWV/PPS/GPS/ACTS/USNO/PCS/... if Stratum1) | ||
| 269 | # Field 4: stratum (0-15) | ||
| 270 | # Field 5: Type of the peer: local (l), unicast (u), multicast (m) | ||
| 271 | # broadcast (b); not sure about multicast/broadcast | ||
| 272 | # Field 6: last packet receive (in seconds) | ||
| 273 | # Field 7: polling interval | ||
| 274 | # Field 8: reachability resgister (octal) | ||
| 275 | # Field 9: delay | ||
| 276 | # Field 10: offset | ||
| 277 | # Field 11: dispersion/jitter | ||
| 278 | # | ||
| 279 | # According to bug 773588 Some solaris xntpd implementations seemto match on | ||
| 280 | # "#" even though the docs say it exceeds maximum distance. Providing patch | ||
| 281 | # here which will generate a warining. | ||
| 282 | |||
| 283 | if ($have_ntpq) { | ||
| 284 | |||
| 285 | if ( open(NTPQ, $ntpq . " -np $host 2>&1 |") ) { | ||
| 286 | while (<NTPQ>) { | ||
| 287 | print $_ if ($verbose); | ||
| 288 | if ( /timed out/ ){ | ||
| 289 | $have_ntpq = 0 ; | ||
| 290 | last ; | ||
| 291 | } | ||
| 292 | # number of candidates on <host> for sys.peer | ||
| 293 | if (/^(\*|\+|\#|o])/) { | ||
| 294 | ++$candidate; | ||
| 295 | push (@candidates, $_); | ||
| 296 | print "Candidate count= $candidate\n" if ($verbose); | ||
| 297 | } | ||
| 298 | |||
| 299 | # match sys.peer or pps.peer | ||
| 300 | if (/^(\*|o)(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/) { | ||
| 301 | $syspeer = $2; | ||
| 302 | $stratum = $4; | ||
| 303 | $jitter = $11; | ||
| 304 | print "match $_ \n" if $verbose; | ||
| 305 | if ($jitter > $jcrit) { | ||
| 306 | print "Jitter_crit = $11 :$jcrit\n" if ($verbose); | ||
| 307 | $jitter_error = $ERRORS{'CRITICAL'}; | ||
| 308 | } elsif ($jitter > $jwarn ) { | ||
| 309 | print "Jitter_warn = $11 :$jwarn\n" if ($verbose); | ||
| 310 | $jitter_error = $ERRORS{'WARNING'}; | ||
| 311 | } else { | ||
| 312 | $jitter_error = $ERRORS{'OK'}; | ||
| 313 | } | ||
| 314 | } else { | ||
| 315 | print "No match!\n" if $verbose; | ||
| 316 | $jitter = '(not parsed)'; | ||
| 317 | } | ||
| 318 | |||
| 319 | } | ||
| 320 | close NTPQ || | ||
| 321 | die $! ? "Error closing $ntpq pipe: $!" | ||
| 322 | : "Exit status: $? from $ntpq\n"; | ||
| 323 | |||
| 324 | # if we did not match sys.peer or pps.peer but matched # candidates only | ||
| 325 | # generate a warning | ||
| 326 | # based on bug id 773588 | ||
| 327 | unless (defined $syspeer) { | ||
| 328 | if ($#candidates >=0) { | ||
| 329 | foreach my $c (@candidates) { | ||
| 330 | $c =~ /^(#)([-0-9.\s]+)\s+([-0-9A-Za-z_().]+)\s+([-0-9.]+)\s+([lumb-]+)\s+([-0-9m.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)/; | ||
| 331 | $syspeer = $2; | ||
| 332 | $stratum = $4; | ||
| 333 | $jitter = $11; | ||
| 334 | print "candidate match $c \n" if $verbose; | ||
| 335 | if ($jitter > $jcrit) { | ||
| 336 | print "Candidate match - Jitter_crit = $11 :$jcrit\n" if ($verbose); | ||
| 337 | $jitter_error = $ERRORS{'CRITICAL'}; | ||
| 338 | }elsif ($jitter > $jwarn ) { | ||
| 339 | print "Candidate match - Jitter_warn = $11 :$jwarn \n" if ($verbose); | ||
| 340 | $jitter_error = $ERRORS{'WARNING'}; | ||
| 341 | } else { | ||
| 342 | $jitter_error = $ERRORS{'WARNING'}; | ||
| 343 | } | ||
| 344 | } | ||
| 345 | |||
| 346 | } | ||
| 347 | } | ||
| 348 | } | ||
| 349 | } | ||
| 350 | |||
| 351 | |||
| 352 | if ($ntpdate_error != $ERRORS{'OK'}) { | ||
| 353 | $state = $ntpdate_error; | ||
| 354 | if ($ntpdate_error == $ERRORS{'WARNING'} ) { | ||
| 355 | $answer = $msg; | ||
| 356 | } | ||
| 357 | else { | ||
| 358 | $answer = $msg . "Server for ntp probably down"; | ||
| 359 | } | ||
| 360 | |||
| 361 | if (defined($offset) && abs($offset) > $ocrit) { | ||
| 362 | $state = $ERRORS{'CRITICAL'}; | ||
| 363 | $answer = "Server Error and offset $offset sec > +/- $ocrit sec"; | ||
| 364 | } elsif (defined($offset) && abs($offset) > $owarn) { | ||
| 365 | $answer = "Server error and offset $offset sec > +/- $owarn sec"; | ||
| 366 | } elsif (defined($jitter) && abs($jitter) > $jcrit) { | ||
| 367 | $answer = "Server error and jitter $jitter msec > +/- $jcrit msec"; | ||
| 368 | } elsif (defined($jitter) && abs($jitter) > $jwarn) { | ||
| 369 | $answer = "Server error and jitter $jitter msec > +/- $jwarn msec"; | ||
| 370 | } | ||
| 371 | |||
| 372 | } elsif ($have_ntpq && $jitter_error != $ERRORS{'OK'}) { | ||
| 373 | $state = $jitter_error; | ||
| 374 | $answer = "Jitter $jitter too high"; | ||
| 375 | if (defined($offset) && abs($offset) > $ocrit) { | ||
| 376 | $state = $ERRORS{'CRITICAL'}; | ||
| 377 | $answer = "Jitter error and offset $offset sec > +/- $ocrit sec"; | ||
| 378 | } elsif (defined($offset) && abs($offset) > $owarn) { | ||
| 379 | $answer = "Jitter error and offset $offset sec > +/- $owarn sec"; | ||
| 380 | } elsif (defined($jitter) && abs($jitter) > $jcrit) { | ||
| 381 | $answer = "Jitter error and jitter $jitter msec > +/- $jcrit msec"; | ||
| 382 | } elsif (defined($jitter) && abs($jitter) > $jwarn) { | ||
| 383 | $answer = "Jitter error and jitter $jitter msec > +/- $jwarn msec"; | ||
| 384 | } | ||
| 385 | |||
| 386 | } elsif( !$have_ntpq ) { # no errors from ntpdate and no ntpq or ntpq timed out | ||
| 387 | if (abs($offset) > $ocrit) { | ||
| 388 | $state = $ERRORS{'CRITICAL'}; | ||
| 389 | $answer = "Offset $offset sec > +/- $ocrit sec"; | ||
| 390 | } elsif (abs($offset) > $owarn) { | ||
| 391 | $state = $ERRORS{'WARNING'}; | ||
| 392 | $answer = "Offset $offset sec > +/- $owarn sec"; | ||
| 393 | } elsif (( abs($offset) > $owarn) && $def_jitter ) { | ||
| 394 | $state = $ERRORS{'WARNING'}; | ||
| 395 | $answer = "Offset $offset sec > +/- $owarn sec, ntpq timed out"; | ||
| 396 | } elsif ( $def_jitter ) { | ||
| 397 | $state = $ERRORS{'WARNING'}; | ||
| 398 | $answer = "Offset $offset secs, ntpq timed out"; | ||
| 399 | } else{ | ||
| 400 | $state = $ERRORS{'OK'}; | ||
| 401 | $answer = "Offset $offset secs"; | ||
| 402 | } | ||
| 403 | |||
| 404 | |||
| 405 | |||
| 406 | } else { # no errors from ntpdate or ntpq | ||
| 407 | if (abs($offset) > $ocrit) { | ||
| 408 | $state = $ERRORS{'CRITICAL'}; | ||
| 409 | $answer = "Offset $offset sec > +/- $ocrit sec, jitter $jitter msec"; | ||
| 410 | } elsif (abs($jitter) > $jcrit ) { | ||
| 411 | $state = $ERRORS{'CRITICAL'}; | ||
| 412 | $answer = "Jitter $jitter msec> +/- $jcrit msec, offset $offset sec"; | ||
| 413 | } elsif (abs($offset) > $owarn) { | ||
| 414 | $state = $ERRORS{'WARNING'}; | ||
| 415 | $answer = "Offset $offset sec > +/- $owarn sec, jitter $jitter msec"; | ||
| 416 | } elsif (abs($jitter) > $jwarn ) { | ||
| 417 | $state = $ERRORS{'WARNING'}; | ||
| 418 | $answer = "Jitter $jitter msec> +/- $jwarn msec, offset $offset sec"; | ||
| 419 | |||
| 420 | } else { | ||
| 421 | $state = $ERRORS{'OK'}; | ||
| 422 | $answer = "Offset $offset secs, jitter $jitter msec, peer is stratum $stratum"; | ||
| 423 | } | ||
| 424 | |||
| 425 | } | ||
| 426 | |||
| 427 | foreach my $key (keys %ERRORS) { | ||
| 428 | if ($state==$ERRORS{$key}) { | ||
| 429 | # print ("NTP $key: $answer"); | ||
| 430 | print ("NTP $key: $answer|offset=$offset, jitter=" . $jitter/1000 . ",peer_stratum=$stratum\n"); | ||
| 431 | last; | ||
| 432 | } | ||
| 433 | } | ||
| 434 | exit $state; | ||
| 435 | |||
| 436 | |||
| 437 | #### | ||
| 438 | #### subs | ||
| 439 | |||
| 440 | sub print_usage () { | ||
| 441 | print "Usage: $PROGNAME -H <host> [-46] [-O] [-w <warn>] [-c <crit>] [-j <warn>] [-k <crit>] [-v verbose]\n"; | ||
| 442 | } | ||
| 443 | |||
| 444 | sub print_help () { | ||
| 445 | print_revision($PROGNAME,'@NP_VERSION@'); | ||
| 446 | print "Copyright (c) 2003 Bo Kersey/Karl DeBisschop\n"; | ||
| 447 | print "\n"; | ||
| 448 | print_usage(); | ||
| 449 | print " | ||
| 450 | Checks the local timestamp offset versus <host> with ntpdate | ||
| 451 | Checks the jitter/dispersion of clock signal between <host> and its sys.peer with ntpq\n | ||
| 452 | -O (--zero-offset) | ||
| 453 | A zero offset on \"ntpdate\" will generate a CRITICAL.\n | ||
| 454 | -w (--warning) | ||
| 455 | Clock offset in seconds at which a warning message will be generated.\n Defaults to $DEFAULT_OFFSET_WARN. | ||
| 456 | -c (--critical) | ||
| 457 | Clock offset in seconds at which a critical message will be generated.\n Defaults to $DEFAULT_OFFSET_CRIT. | ||
| 458 | -j (--jwarn) | ||
| 459 | Clock jitter in milliseconds at which a warning message will be generated.\n Defaults to $DEFAULT_JITTER_WARN. | ||
| 460 | -k (--jcrit) | ||
| 461 | Clock jitter in milliseconds at which a critical message will be generated.\n Defaults to $DEFAULT_JITTER_CRIT. | ||
| 462 | |||
| 463 | If jitter/dispersion is specified with -j or -k and ntpq times out, then a | ||
| 464 | warning is returned.\n | ||
| 465 | -4 (--use-ipv4) | ||
| 466 | Use IPv4 connection | ||
| 467 | -6 (--use-ipv6) | ||
| 468 | Use IPv6 connection | ||
| 469 | \n"; | ||
| 470 | support(); | ||
| 471 | } | ||
diff --git a/plugins-scripts/check_rpc.pl b/plugins-scripts/check_rpc.pl index b1c61471..47d6e49e 100755 --- a/plugins-scripts/check_rpc.pl +++ b/plugins-scripts/check_rpc.pl | |||
| @@ -22,7 +22,6 @@ | |||
| 22 | use strict; | 22 | use strict; |
| 23 | use FindBin; | 23 | use FindBin; |
| 24 | use lib "$FindBin::Bin"; | 24 | use lib "$FindBin::Bin"; |
| 25 | use lib '@libexecdir@'; | ||
| 26 | use utils qw($TIMEOUT %ERRORS &print_revision &support); | 25 | use utils qw($TIMEOUT %ERRORS &print_revision &support); |
| 27 | use vars qw($PROGNAME); | 26 | use vars qw($PROGNAME); |
| 28 | my ($verbose,@proto,%prognum,$host,$response,$prognum,$port,$cmd,$progver,$state); | 27 | my ($verbose,@proto,%prognum,$host,$response,$prognum,$port,$cmd,$progver,$state); |
| @@ -64,12 +63,12 @@ GetOptions( | |||
| 64 | ); | 63 | ); |
| 65 | 64 | ||
| 66 | # -h means display verbose help screen | 65 | # -h means display verbose help screen |
| 67 | if ($opt_h) { print_help(); exit $ERRORS{'OK'}; } | 66 | if ($opt_h) { print_help(); exit $ERRORS{'UNKNOWN'}; } |
| 68 | 67 | ||
| 69 | # -V means display version number | 68 | # -V means display version number |
| 70 | if ($opt_V) { | 69 | if ($opt_V) { |
| 71 | print_revision($PROGNAME,'@NP_VERSION@'); | 70 | print_revision($PROGNAME,'@NP_VERSION@'); |
| 72 | exit $ERRORS{'OK'}; | 71 | exit $ERRORS{'UNKNOWN'}; |
| 73 | } | 72 | } |
| 74 | 73 | ||
| 75 | # Hash containing all RPC program names and numbers | 74 | # Hash containing all RPC program names and numbers |
diff --git a/plugins-scripts/check_wave.pl b/plugins-scripts/check_wave.pl index ee0fda4d..41e15f50 100755 --- a/plugins-scripts/check_wave.pl +++ b/plugins-scripts/check_wave.pl | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | use strict; | 5 | use strict; |
| 6 | use FindBin; | 6 | use FindBin; |
| 7 | use lib "$FindBin::Bin"; | 7 | use lib "$FindBin::Bin"; |
| 8 | use lib '@libexecdir@'; | ||
| 9 | use utils qw($TIMEOUT %ERRORS &print_revision &support); | 8 | use utils qw($TIMEOUT %ERRORS &print_revision &support); |
| 10 | use vars qw($PROGNAME); | 9 | use vars qw($PROGNAME); |
| 11 | use Getopt::Long; | 10 | use Getopt::Long; |
| @@ -32,12 +31,12 @@ GetOptions | |||
| 32 | 31 | ||
| 33 | if ($opt_V) { | 32 | if ($opt_V) { |
| 34 | print_revision($PROGNAME,'@NP_VERSION@'); #' | 33 | print_revision($PROGNAME,'@NP_VERSION@'); #' |
| 35 | exit $ERRORS{'OK'}; | 34 | exit $ERRORS{'UNKNOWN'}; |
| 36 | } | 35 | } |
| 37 | 36 | ||
| 38 | if ($opt_h) { | 37 | if ($opt_h) { |
| 39 | print_help(); | 38 | print_help(); |
| 40 | exit $ERRORS{'OK'}; | 39 | exit $ERRORS{'UNKNOWN'}; |
| 41 | } | 40 | } |
| 42 | 41 | ||
| 43 | $opt_H = shift unless ($opt_H); | 42 | $opt_H = shift unless ($opt_H); |
diff --git a/plugins-scripts/t/check_rpc.t b/plugins-scripts/t/check_rpc.t index be8ae2f7..c58f7bf7 100644 --- a/plugins-scripts/t/check_rpc.t +++ b/plugins-scripts/t/check_rpc.t | |||
| @@ -15,7 +15,7 @@ my $successOutput = '/^check_rpc/'; | |||
| 15 | 15 | ||
| 16 | my $t; | 16 | my $t; |
| 17 | 17 | ||
| 18 | $t += checkCmd( "./check_rpc -V", 0, $successOutput ); | 18 | $t += checkCmd( "./check_rpc -V", 3, $successOutput ); |
| 19 | 19 | ||
| 20 | exit(0) if defined($Test::Harness::VERSION); | 20 | exit(0) if defined($Test::Harness::VERSION); |
| 21 | exit($tests - $t); | 21 | exit($tests - $t); |
diff --git a/plugins-scripts/utils.pm.in b/plugins-scripts/utils.pm.in index 0f53243c..386831eb 100644 --- a/plugins-scripts/utils.pm.in +++ b/plugins-scripts/utils.pm.in | |||
| @@ -17,6 +17,7 @@ sub support(); | |||
| 17 | sub is_hostname; | 17 | sub is_hostname; |
| 18 | 18 | ||
| 19 | ## updated by autoconf | 19 | ## updated by autoconf |
| 20 | $PATH_TO_SUDO = "@PATH_TO_SUDO@"; | ||
| 20 | $PATH_TO_RPCINFO = "@PATH_TO_RPCINFO@" ; | 21 | $PATH_TO_RPCINFO = "@PATH_TO_RPCINFO@" ; |
| 21 | $PATH_TO_LMSTAT = "@PATH_TO_LMSTAT@" ; | 22 | $PATH_TO_LMSTAT = "@PATH_TO_LMSTAT@" ; |
| 22 | $PATH_TO_SMBCLIENT = "@PATH_TO_SMBCLIENT@" ; | 23 | $PATH_TO_SMBCLIENT = "@PATH_TO_SMBCLIENT@" ; |
diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 0ddf9bd1..41906c53 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am | |||
| @@ -71,7 +71,7 @@ check_apt_LDADD = $(BASEOBJS) | |||
| 71 | check_cluster_LDADD = $(BASEOBJS) | 71 | check_cluster_LDADD = $(BASEOBJS) |
| 72 | check_dbi_LDADD = $(NETLIBS) $(DBILIBS) | 72 | check_dbi_LDADD = $(NETLIBS) $(DBILIBS) |
| 73 | check_dig_LDADD = $(NETLIBS) | 73 | check_dig_LDADD = $(NETLIBS) |
| 74 | check_disk_LDADD = $(BASEOBJS) | 74 | check_disk_LDADD = $(BASEOBJS) $(THREADLIBS) |
| 75 | check_dns_LDADD = $(NETLIBS) | 75 | check_dns_LDADD = $(NETLIBS) |
| 76 | check_dummy_LDADD = $(BASEOBJS) | 76 | check_dummy_LDADD = $(BASEOBJS) |
| 77 | check_fping_LDADD = $(NETLIBS) | 77 | check_fping_LDADD = $(NETLIBS) |
diff --git a/plugins/check_apt.c b/plugins/check_apt.c index 8747f904..a639a411 100644 --- a/plugins/check_apt.c +++ b/plugins/check_apt.c | |||
| @@ -160,10 +160,10 @@ int process_arguments (int argc, char **argv) { | |||
| 160 | switch(c) { | 160 | switch(c) { |
| 161 | case 'h': | 161 | case 'h': |
| 162 | print_help(); | 162 | print_help(); |
| 163 | exit(STATE_OK); | 163 | exit(STATE_UNKNOWN); |
| 164 | case 'V': | 164 | case 'V': |
| 165 | print_revision(progname, NP_VERSION); | 165 | print_revision(progname, NP_VERSION); |
| 166 | exit(STATE_OK); | 166 | exit(STATE_UNKNOWN); |
| 167 | case 'v': | 167 | case 'v': |
| 168 | verbose++; | 168 | verbose++; |
| 169 | break; | 169 | break; |
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c index a877f888..04bce38d 100644 --- a/plugins/check_by_ssh.c +++ b/plugins/check_by_ssh.c | |||
| @@ -209,10 +209,10 @@ process_arguments (int argc, char **argv) | |||
| 209 | switch (c) { | 209 | switch (c) { |
| 210 | case 'V': /* version */ | 210 | case 'V': /* version */ |
| 211 | print_revision (progname, NP_VERSION); | 211 | print_revision (progname, NP_VERSION); |
| 212 | exit (STATE_OK); | 212 | exit (STATE_UNKNOWN); |
| 213 | case 'h': /* help */ | 213 | case 'h': /* help */ |
| 214 | print_help (); | 214 | print_help (); |
| 215 | exit (STATE_OK); | 215 | exit (STATE_UNKNOWN); |
| 216 | case 'v': /* help */ | 216 | case 'v': /* help */ |
| 217 | verbose = TRUE; | 217 | verbose = TRUE; |
| 218 | break; | 218 | break; |
diff --git a/plugins/check_cluster.c b/plugins/check_cluster.c index cf699e1f..b86e501d 100644 --- a/plugins/check_cluster.c +++ b/plugins/check_cluster.c | |||
| @@ -200,7 +200,7 @@ int process_arguments(int argc, char **argv){ | |||
| 200 | 200 | ||
| 201 | case 'V': /* version */ | 201 | case 'V': /* version */ |
| 202 | print_revision (progname, NP_VERSION); | 202 | print_revision (progname, NP_VERSION); |
| 203 | exit (STATE_OK); | 203 | exit (STATE_UNKNOWN); |
| 204 | break; | 204 | break; |
| 205 | 205 | ||
| 206 | case 'H': /* help */ | 206 | case 'H': /* help */ |
diff --git a/plugins/check_dbi.c b/plugins/check_dbi.c index a3d033f4..826eb8d9 100644 --- a/plugins/check_dbi.c +++ b/plugins/check_dbi.c | |||
| @@ -368,10 +368,10 @@ process_arguments (int argc, char **argv) | |||
| 368 | usage5 (); | 368 | usage5 (); |
| 369 | case 'h': /* help */ | 369 | case 'h': /* help */ |
| 370 | print_help (); | 370 | print_help (); |
| 371 | exit (STATE_OK); | 371 | exit (STATE_UNKNOWN); |
| 372 | case 'V': /* version */ | 372 | case 'V': /* version */ |
| 373 | print_revision (progname, NP_VERSION); | 373 | print_revision (progname, NP_VERSION); |
| 374 | exit (STATE_OK); | 374 | exit (STATE_UNKNOWN); |
| 375 | 375 | ||
| 376 | case 'c': /* critical range */ | 376 | case 'c': /* critical range */ |
| 377 | critical_range = optarg; | 377 | critical_range = optarg; |
diff --git a/plugins/check_dig.c b/plugins/check_dig.c index d899b119..db4b20eb 100644 --- a/plugins/check_dig.c +++ b/plugins/check_dig.c | |||
| @@ -223,10 +223,10 @@ process_arguments (int argc, char **argv) | |||
| 223 | switch (c) { | 223 | switch (c) { |
| 224 | case 'h': /* help */ | 224 | case 'h': /* help */ |
| 225 | print_help (); | 225 | print_help (); |
| 226 | exit (STATE_OK); | 226 | exit (STATE_UNKNOWN); |
| 227 | case 'V': /* version */ | 227 | case 'V': /* version */ |
| 228 | print_revision (progname, NP_VERSION); | 228 | print_revision (progname, NP_VERSION); |
| 229 | exit (STATE_OK); | 229 | exit (STATE_UNKNOWN); |
| 230 | case 'H': /* hostname */ | 230 | case 'H': /* hostname */ |
| 231 | host_or_die(optarg); | 231 | host_or_die(optarg); |
| 232 | dns_server = optarg; | 232 | dns_server = optarg; |
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 0d73a4f1..9693bad3 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
| @@ -51,6 +51,9 @@ const char *email = "devel@monitoring-plugins.org"; | |||
| 51 | # include <limits.h> | 51 | # include <limits.h> |
| 52 | #endif | 52 | #endif |
| 53 | #include "regex.h" | 53 | #include "regex.h" |
| 54 | #if HAVE_PTHREAD_H | ||
| 55 | # include <pthread.h> | ||
| 56 | #endif | ||
| 54 | 57 | ||
| 55 | #ifdef __CYGWIN__ | 58 | #ifdef __CYGWIN__ |
| 56 | # include <windows.h> | 59 | # include <windows.h> |
| @@ -130,6 +133,7 @@ void print_help (void); | |||
| 130 | void print_usage (void); | 133 | void print_usage (void); |
| 131 | double calculate_percent(uintmax_t, uintmax_t); | 134 | double calculate_percent(uintmax_t, uintmax_t); |
| 132 | void stat_path (struct parameter_list *p); | 135 | void stat_path (struct parameter_list *p); |
| 136 | void *do_stat_path (void *p); | ||
| 133 | void get_stats (struct parameter_list *p, struct fs_usage *fsp); | 137 | void get_stats (struct parameter_list *p, struct fs_usage *fsp); |
| 134 | void get_path_stats (struct parameter_list *p, struct fs_usage *fsp); | 138 | void get_path_stats (struct parameter_list *p, struct fs_usage *fsp); |
| 135 | 139 | ||
| @@ -762,10 +766,10 @@ process_arguments (int argc, char **argv) | |||
| 762 | break; | 766 | break; |
| 763 | case 'V': /* version */ | 767 | case 'V': /* version */ |
| 764 | print_revision (progname, NP_VERSION); | 768 | print_revision (progname, NP_VERSION); |
| 765 | exit (STATE_OK); | 769 | exit (STATE_UNKNOWN); |
| 766 | case 'h': /* help */ | 770 | case 'h': /* help */ |
| 767 | print_help (); | 771 | print_help (); |
| 768 | exit (STATE_OK); | 772 | exit (STATE_UNKNOWN); |
| 769 | case '?': /* help */ | 773 | case '?': /* help */ |
| 770 | usage (_("Unknown argument")); | 774 | usage (_("Unknown argument")); |
| 771 | } | 775 | } |
| @@ -968,6 +972,44 @@ print_usage (void) | |||
| 968 | void | 972 | void |
| 969 | stat_path (struct parameter_list *p) | 973 | stat_path (struct parameter_list *p) |
| 970 | { | 974 | { |
| 975 | #ifdef HAVE_PTHREAD_H | ||
| 976 | pthread_t stat_thread; | ||
| 977 | int statdone = 0; | ||
| 978 | int timer = timeout_interval; | ||
| 979 | struct timespec req, rem; | ||
| 980 | |||
| 981 | req.tv_sec = 0; | ||
| 982 | pthread_create(&stat_thread, NULL, do_stat_path, p); | ||
| 983 | while (timer-- > 0) { | ||
| 984 | req.tv_nsec = 10000000; | ||
| 985 | nanosleep(&req, &rem); | ||
| 986 | if (pthread_kill(stat_thread, 0)) { | ||
| 987 | statdone = 1; | ||
| 988 | break; | ||
| 989 | } else { | ||
| 990 | req.tv_nsec = 990000000; | ||
| 991 | nanosleep(&req, &rem); | ||
| 992 | } | ||
| 993 | } | ||
| 994 | if (statdone == 1) { | ||
| 995 | pthread_join(stat_thread, NULL); | ||
| 996 | } else { | ||
| 997 | pthread_detach(stat_thread); | ||
| 998 | if (verbose >= 3) | ||
| 999 | printf("stat did not return within %ds on %s\n", timeout_interval, p->name); | ||
| 1000 | printf("DISK %s - ", _("CRITICAL")); | ||
| 1001 | die (STATE_CRITICAL, _("%s %s: %s\n"), p->name, _("hangs"), _("Timeout")); | ||
| 1002 | } | ||
| 1003 | #else | ||
| 1004 | do_stat_path(p); | ||
| 1005 | #endif | ||
| 1006 | } | ||
| 1007 | |||
| 1008 | void * | ||
| 1009 | do_stat_path (void *in) | ||
| 1010 | { | ||
| 1011 | struct parameter_list *p = in; | ||
| 1012 | |||
| 971 | /* Stat entry to check that dir exists and is accessible */ | 1013 | /* Stat entry to check that dir exists and is accessible */ |
| 972 | if (verbose >= 3) | 1014 | if (verbose >= 3) |
| 973 | printf("calling stat on %s\n", p->name); | 1015 | printf("calling stat on %s\n", p->name); |
| @@ -977,6 +1019,7 @@ stat_path (struct parameter_list *p) | |||
| 977 | printf("DISK %s - ", _("CRITICAL")); | 1019 | printf("DISK %s - ", _("CRITICAL")); |
| 978 | die (STATE_CRITICAL, _("%s %s: %s\n"), p->name, _("is not accessible"), strerror(errno)); | 1020 | die (STATE_CRITICAL, _("%s %s: %s\n"), p->name, _("is not accessible"), strerror(errno)); |
| 979 | } | 1021 | } |
| 1022 | return NULL; | ||
| 980 | } | 1023 | } |
| 981 | 1024 | ||
| 982 | 1025 | ||
diff --git a/plugins/check_dns.c b/plugins/check_dns.c index 22121226..d6bd2c0f 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c | |||
| @@ -395,10 +395,10 @@ process_arguments (int argc, char **argv) | |||
| 395 | switch (c) { | 395 | switch (c) { |
| 396 | case 'h': /* help */ | 396 | case 'h': /* help */ |
| 397 | print_help (); | 397 | print_help (); |
| 398 | exit (STATE_OK); | 398 | exit (STATE_UNKNOWN); |
| 399 | case 'V': /* version */ | 399 | case 'V': /* version */ |
| 400 | print_revision (progname, NP_VERSION); | 400 | print_revision (progname, NP_VERSION); |
| 401 | exit (STATE_OK); | 401 | exit (STATE_UNKNOWN); |
| 402 | case 'v': /* version */ | 402 | case 'v': /* version */ |
| 403 | verbose = TRUE; | 403 | verbose = TRUE; |
| 404 | break; | 404 | break; |
diff --git a/plugins/check_dummy.c b/plugins/check_dummy.c index 3ed68717..212a1344 100644 --- a/plugins/check_dummy.c +++ b/plugins/check_dummy.c | |||
| @@ -52,11 +52,11 @@ main (int argc, char **argv) | |||
| 52 | usage4 (_("Could not parse arguments")); | 52 | usage4 (_("Could not parse arguments")); |
| 53 | else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) { | 53 | else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) { |
| 54 | print_revision (progname, NP_VERSION); | 54 | print_revision (progname, NP_VERSION); |
| 55 | exit (STATE_OK); | 55 | exit (STATE_UNKNOWN); |
| 56 | } | 56 | } |
| 57 | else if (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0) { | 57 | else if (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0) { |
| 58 | print_help (); | 58 | print_help (); |
| 59 | exit (STATE_OK); | 59 | exit (STATE_UNKNOWN); |
| 60 | } | 60 | } |
| 61 | else if (!is_integer (argv[1])) | 61 | else if (!is_integer (argv[1])) |
| 62 | usage4 (_("Arguments to check_dummy must be an integer")); | 62 | usage4 (_("Arguments to check_dummy must be an integer")); |
diff --git a/plugins/check_fping.c b/plugins/check_fping.c index 46046b4f..da1ce1a6 100644 --- a/plugins/check_fping.c +++ b/plugins/check_fping.c | |||
| @@ -105,7 +105,7 @@ main (int argc, char **argv) | |||
| 105 | xasprintf(&option_string, "%s-I %s ", option_string, sourceif); | 105 | xasprintf(&option_string, "%s-I %s ", option_string, sourceif); |
| 106 | 106 | ||
| 107 | #ifdef PATH_TO_FPING6 | 107 | #ifdef PATH_TO_FPING6 |
| 108 | if (address_family == AF_INET6) | 108 | if (address_family != AF_INET && is_inet6_addr(server)) |
| 109 | fping_prog = strdup(PATH_TO_FPING6); | 109 | fping_prog = strdup(PATH_TO_FPING6); |
| 110 | else | 110 | else |
| 111 | fping_prog = strdup(PATH_TO_FPING); | 111 | fping_prog = strdup(PATH_TO_FPING); |
| @@ -314,10 +314,10 @@ process_arguments (int argc, char **argv) | |||
| 314 | usage5 (); | 314 | usage5 (); |
| 315 | case 'h': /* help */ | 315 | case 'h': /* help */ |
| 316 | print_help (); | 316 | print_help (); |
| 317 | exit (STATE_OK); | 317 | exit (STATE_UNKNOWN); |
| 318 | case 'V': /* version */ | 318 | case 'V': /* version */ |
| 319 | print_revision (progname, NP_VERSION); | 319 | print_revision (progname, NP_VERSION); |
| 320 | exit (STATE_OK); | 320 | exit (STATE_UNKNOWN); |
| 321 | case 'v': /* verbose mode */ | 321 | case 'v': /* verbose mode */ |
| 322 | verbose = TRUE; | 322 | verbose = TRUE; |
| 323 | break; | 323 | break; |
diff --git a/plugins/check_game.c b/plugins/check_game.c index 29e59e2f..709dae1b 100644 --- a/plugins/check_game.c +++ b/plugins/check_game.c | |||
| @@ -196,10 +196,10 @@ process_arguments (int argc, char **argv) | |||
| 196 | switch (c) { | 196 | switch (c) { |
| 197 | case 'h': /* help */ | 197 | case 'h': /* help */ |
| 198 | print_help (); | 198 | print_help (); |
| 199 | exit (STATE_OK); | 199 | exit (STATE_UNKNOWN); |
| 200 | case 'V': /* version */ | 200 | case 'V': /* version */ |
| 201 | print_revision (progname, NP_VERSION); | 201 | print_revision (progname, NP_VERSION); |
| 202 | exit (STATE_OK); | 202 | exit (STATE_UNKNOWN); |
| 203 | case 'v': /* version */ | 203 | case 'v': /* version */ |
| 204 | verbose = TRUE; | 204 | verbose = TRUE; |
| 205 | break; | 205 | break; |
diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c index 5fe06984..f159f5a2 100644 --- a/plugins/check_hpjd.c +++ b/plugins/check_hpjd.c | |||
| @@ -350,10 +350,10 @@ process_arguments (int argc, char **argv) | |||
| 350 | break; | 350 | break; |
| 351 | case 'V': /* version */ | 351 | case 'V': /* version */ |
| 352 | print_revision (progname, NP_VERSION); | 352 | print_revision (progname, NP_VERSION); |
| 353 | exit (STATE_OK); | 353 | exit (STATE_UNKNOWN); |
| 354 | case 'h': /* help */ | 354 | case 'h': /* help */ |
| 355 | print_help (); | 355 | print_help (); |
| 356 | exit (STATE_OK); | 356 | exit (STATE_UNKNOWN); |
| 357 | case '?': /* help */ | 357 | case '?': /* help */ |
| 358 | usage5 (); | 358 | usage5 (); |
| 359 | } | 359 | } |
diff --git a/plugins/check_http.c b/plugins/check_http.c index 51679975..2038f4a1 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
| @@ -267,11 +267,11 @@ process_arguments (int argc, char **argv) | |||
| 267 | break; | 267 | break; |
| 268 | case 'h': /* help */ | 268 | case 'h': /* help */ |
| 269 | print_help (); | 269 | print_help (); |
| 270 | exit (STATE_OK); | 270 | exit (STATE_UNKNOWN); |
| 271 | break; | 271 | break; |
| 272 | case 'V': /* version */ | 272 | case 'V': /* version */ |
| 273 | print_revision (progname, NP_VERSION); | 273 | print_revision (progname, NP_VERSION); |
| 274 | exit (STATE_OK); | 274 | exit (STATE_UNKNOWN); |
| 275 | break; | 275 | break; |
| 276 | case 't': /* timeout period */ | 276 | case 't': /* timeout period */ |
| 277 | if (!is_intnonneg (optarg)) | 277 | if (!is_intnonneg (optarg)) |
| @@ -343,9 +343,20 @@ process_arguments (int argc, char **argv) | |||
| 343 | parameters, like -S and -C combinations */ | 343 | parameters, like -S and -C combinations */ |
| 344 | use_ssl = TRUE; | 344 | use_ssl = TRUE; |
| 345 | if (c=='S' && optarg != NULL) { | 345 | if (c=='S' && optarg != NULL) { |
| 346 | ssl_version = atoi(optarg); | 346 | int got_plus = strchr(optarg, '+') != NULL; |
| 347 | if (ssl_version < 1 || ssl_version > 3) | 347 | |
| 348 | usage4 (_("Invalid option - Valid values for SSL Version are 1 (TLSv1), 2 (SSLv2) or 3 (SSLv3)")); | 348 | if (!strncmp (optarg, "1.2", 3)) |
| 349 | ssl_version = got_plus ? MP_TLSv1_2_OR_NEWER : MP_TLSv1_2; | ||
| 350 | else if (!strncmp (optarg, "1.1", 3)) | ||
| 351 | ssl_version = got_plus ? MP_TLSv1_1_OR_NEWER : MP_TLSv1_1; | ||
| 352 | else if (optarg[0] == '1') | ||
| 353 | ssl_version = got_plus ? MP_TLSv1_OR_NEWER : MP_TLSv1; | ||
| 354 | else if (optarg[0] == '3') | ||
| 355 | ssl_version = got_plus ? MP_SSLv3_OR_NEWER : MP_SSLv3; | ||
| 356 | else if (optarg[0] == '2') | ||
| 357 | ssl_version = got_plus ? MP_SSLv2_OR_NEWER : MP_SSLv2; | ||
| 358 | else | ||
| 359 | usage4 (_("Invalid option - Valid SSL/TLS versions: 2, 3, 1, 1.1, 1.2 (with optional '+' suffix)")); | ||
| 349 | } | 360 | } |
| 350 | if (specify_port == FALSE) | 361 | if (specify_port == FALSE) |
| 351 | server_port = HTTPS_PORT; | 362 | server_port = HTTPS_PORT; |
| @@ -869,17 +880,42 @@ check_http (void) | |||
| 869 | double elapsed_time_transfer = 0.0; | 880 | double elapsed_time_transfer = 0.0; |
| 870 | int page_len = 0; | 881 | int page_len = 0; |
| 871 | int result = STATE_OK; | 882 | int result = STATE_OK; |
| 883 | char *force_host_header = NULL; | ||
| 872 | 884 | ||
| 873 | /* try to connect to the host at the given port number */ | 885 | /* try to connect to the host at the given port number */ |
| 874 | gettimeofday (&tv_temp, NULL); | 886 | gettimeofday (&tv_temp, NULL); |
| 875 | if (my_tcp_connect (server_address, server_port, &sd) != STATE_OK) | 887 | if (my_tcp_connect (server_address, server_port, &sd) != STATE_OK) |
| 876 | die (STATE_CRITICAL, _("HTTP CRITICAL - Unable to open TCP socket\n")); | 888 | die (STATE_CRITICAL, _("HTTP CRITICAL - Unable to open TCP socket\n")); |
| 877 | microsec_connect = deltime (tv_temp); | 889 | microsec_connect = deltime (tv_temp); |
| 890 | |||
| 891 | /* if we are called with the -I option, the -j method is CONNECT and */ | ||
| 892 | /* we received -S for SSL, then we tunnel the request through a proxy*/ | ||
| 893 | /* @20100414, public[at]frank4dd.com, http://www.frank4dd.com/howto */ | ||
| 894 | |||
| 895 | if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0 | ||
| 896 | && host_name != NULL && use_ssl == TRUE) { | ||
| 897 | |||
| 898 | if (verbose) printf ("Entering CONNECT tunnel mode with proxy %s:%d to dst %s:%d\n", server_address, server_port, host_name, HTTPS_PORT); | ||
| 899 | asprintf (&buf, "%s %s:%d HTTP/1.1\r\n%s\r\n", http_method, host_name, HTTPS_PORT, user_agent); | ||
| 900 | asprintf (&buf, "%sProxy-Connection: keep-alive\r\n", buf); | ||
| 901 | asprintf (&buf, "%sHost: %s\r\n", buf, host_name); | ||
| 902 | /* we finished our request, send empty line with CRLF */ | ||
| 903 | asprintf (&buf, "%s%s", buf, CRLF); | ||
| 904 | if (verbose) printf ("%s\n", buf); | ||
| 905 | send(sd, buf, strlen (buf), 0); | ||
| 906 | buf[0]='\0'; | ||
| 907 | |||
| 908 | if (verbose) printf ("Receive response from proxy\n"); | ||
| 909 | read (sd, buffer, MAX_INPUT_BUFFER-1); | ||
| 910 | if (verbose) printf ("%s", buffer); | ||
| 911 | /* Here we should check if we got HTTP/1.1 200 Connection established */ | ||
| 912 | } | ||
| 878 | #ifdef HAVE_SSL | 913 | #ifdef HAVE_SSL |
| 879 | elapsed_time_connect = (double)microsec_connect / 1.0e6; | 914 | elapsed_time_connect = (double)microsec_connect / 1.0e6; |
| 880 | if (use_ssl == TRUE) { | 915 | if (use_ssl == TRUE) { |
| 881 | gettimeofday (&tv_temp, NULL); | 916 | gettimeofday (&tv_temp, NULL); |
| 882 | result = np_net_ssl_init_with_hostname_version_and_cert(sd, (use_sni ? host_name : NULL), ssl_version, client_cert, client_privkey); | 917 | result = np_net_ssl_init_with_hostname_version_and_cert(sd, (use_sni ? host_name : NULL), ssl_version, client_cert, client_privkey); |
| 918 | if (verbose) printf ("SSL initialized\n"); | ||
| 883 | if (result != STATE_OK) | 919 | if (result != STATE_OK) |
| 884 | die (STATE_CRITICAL, NULL); | 920 | die (STATE_CRITICAL, NULL); |
| 885 | microsec_ssl = deltime (tv_temp); | 921 | microsec_ssl = deltime (tv_temp); |
| @@ -893,29 +929,51 @@ check_http (void) | |||
| 893 | } | 929 | } |
| 894 | #endif /* HAVE_SSL */ | 930 | #endif /* HAVE_SSL */ |
| 895 | 931 | ||
| 896 | xasprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent); | 932 | if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0 |
| 933 | && host_name != NULL && use_ssl == TRUE) | ||
| 934 | asprintf (&buf, "%s %s %s\r\n%s\r\n", "GET", server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent); | ||
| 935 | else | ||
| 936 | asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent); | ||
| 897 | 937 | ||
| 898 | /* tell HTTP/1.1 servers not to keep the connection alive */ | 938 | /* tell HTTP/1.1 servers not to keep the connection alive */ |
| 899 | xasprintf (&buf, "%sConnection: close\r\n", buf); | 939 | xasprintf (&buf, "%sConnection: close\r\n", buf); |
| 900 | 940 | ||
| 941 | /* check if Host header is explicitly set in options */ | ||
| 942 | if (http_opt_headers_count) { | ||
| 943 | for (i = 0; i < http_opt_headers_count ; i++) { | ||
| 944 | if (strncmp(http_opt_headers[i], "Host:", 5) == 0) { | ||
| 945 | force_host_header = http_opt_headers[i]; | ||
| 946 | } | ||
| 947 | } | ||
| 948 | } | ||
| 949 | |||
| 901 | /* optionally send the host header info */ | 950 | /* optionally send the host header info */ |
| 902 | if (host_name) { | 951 | if (host_name) { |
| 903 | /* | 952 | if (force_host_header) { |
| 904 | * Specify the port only if we're using a non-default port (see RFC 2616, | 953 | xasprintf (&buf, "%s%s\r\n", buf, force_host_header); |
| 905 | * 14.23). Some server applications/configurations cause trouble if the | 954 | } |
| 906 | * (default) port is explicitly specified in the "Host:" header line. | 955 | else { |
| 907 | */ | 956 | /* |
| 908 | if ((use_ssl == FALSE && server_port == HTTP_PORT) || | 957 | * Specify the port only if we're using a non-default port (see RFC 2616, |
| 909 | (use_ssl == TRUE && server_port == HTTPS_PORT)) | 958 | * 14.23). Some server applications/configurations cause trouble if the |
| 910 | xasprintf (&buf, "%sHost: %s\r\n", buf, host_name); | 959 | * (default) port is explicitly specified in the "Host:" header line. |
| 911 | else | 960 | */ |
| 912 | xasprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, server_port); | 961 | if ((use_ssl == FALSE && server_port == HTTP_PORT) || |
| 962 | (use_ssl == TRUE && server_port == HTTPS_PORT) || | ||
| 963 | (server_address != NULL && strcmp(http_method, "CONNECT") == 0 | ||
| 964 | && host_name != NULL && use_ssl == TRUE)) | ||
| 965 | xasprintf (&buf, "%sHost: %s\r\n", buf, host_name); | ||
| 966 | else | ||
| 967 | xasprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, server_port); | ||
| 968 | } | ||
| 913 | } | 969 | } |
| 914 | 970 | ||
| 915 | /* optionally send any other header tag */ | 971 | /* optionally send any other header tag */ |
| 916 | if (http_opt_headers_count) { | 972 | if (http_opt_headers_count) { |
| 917 | for (i = 0; i < http_opt_headers_count ; i++) { | 973 | for (i = 0; i < http_opt_headers_count ; i++) { |
| 918 | xasprintf (&buf, "%s%s\r\n", buf, http_opt_headers[i]); | 974 | if (force_host_header != http_opt_headers[i]) { |
| 975 | xasprintf (&buf, "%s%s\r\n", buf, http_opt_headers[i]); | ||
| 976 | } | ||
| 919 | } | 977 | } |
| 920 | /* This cannot be free'd here because a redirection will then try to access this and segfault */ | 978 | /* This cannot be free'd here because a redirection will then try to access this and segfault */ |
| 921 | /* Covered in a testcase in tests/check_http.t */ | 979 | /* Covered in a testcase in tests/check_http.t */ |
| @@ -1467,9 +1525,10 @@ print_help (void) | |||
| 1467 | printf (UT_IPv46); | 1525 | printf (UT_IPv46); |
| 1468 | 1526 | ||
| 1469 | #ifdef HAVE_SSL | 1527 | #ifdef HAVE_SSL |
| 1470 | printf (" %s\n", "-S, --ssl=VERSION"); | 1528 | printf (" %s\n", "-S, --ssl=VERSION[+]"); |
| 1471 | printf (" %s\n", _("Connect via SSL. Port defaults to 443. VERSION is optional, and prevents")); | 1529 | printf (" %s\n", _("Connect via SSL. Port defaults to 443. VERSION is optional, and prevents")); |
| 1472 | printf (" %s\n", _("auto-negotiation (1 = TLSv1, 2 = SSLv2, 3 = SSLv3).")); | 1530 | printf (" %s\n", _("auto-negotiation (2 = SSLv2, 3 = SSLv3, 1 = TLSv1, 1.1 = TLSv1.1,")); |
| 1531 | printf (" %s\n", _("1.2 = TLSv1.2). With a '+' suffix, newer versions are also accepted.")); | ||
| 1473 | printf (" %s\n", "--sni"); | 1532 | printf (" %s\n", "--sni"); |
| 1474 | printf (" %s\n", _("Enable SSL/TLS hostname extension support (SNI)")); | 1533 | printf (" %s\n", _("Enable SSL/TLS hostname extension support (SNI)")); |
| 1475 | printf (" %s\n", "-C, --certificate=INTEGER[,INTEGER]"); | 1534 | printf (" %s\n", "-C, --certificate=INTEGER[,INTEGER]"); |
| @@ -1496,7 +1555,7 @@ print_help (void) | |||
| 1496 | printf (" %s\n", _("URL to GET or POST (default: /)")); | 1555 | printf (" %s\n", _("URL to GET or POST (default: /)")); |
| 1497 | printf (" %s\n", "-P, --post=STRING"); | 1556 | printf (" %s\n", "-P, --post=STRING"); |
| 1498 | printf (" %s\n", _("URL encoded http POST data")); | 1557 | printf (" %s\n", _("URL encoded http POST data")); |
| 1499 | printf (" %s\n", "-j, --method=STRING (for example: HEAD, OPTIONS, TRACE, PUT, DELETE)"); | 1558 | printf (" %s\n", "-j, --method=STRING (for example: HEAD, OPTIONS, TRACE, PUT, DELETE, CONNECT)"); |
| 1500 | printf (" %s\n", _("Set HTTP method.")); | 1559 | printf (" %s\n", _("Set HTTP method.")); |
| 1501 | printf (" %s\n", "-N, --no-body"); | 1560 | printf (" %s\n", "-N, --no-body"); |
| 1502 | printf (" %s\n", _("Don't wait for document body: stop reading after headers.")); | 1561 | printf (" %s\n", _("Don't wait for document body: stop reading after headers.")); |
| @@ -1570,7 +1629,7 @@ print_help (void) | |||
| 1570 | printf (" %s\n", _("When the certificate of 'www.verisign.com' is valid for more than 14 days,")); | 1629 | printf (" %s\n", _("When the certificate of 'www.verisign.com' is valid for more than 14 days,")); |
| 1571 | printf (" %s\n", _("a STATE_OK is returned. When the certificate is still valid, but for less than")); | 1630 | printf (" %s\n", _("a STATE_OK is returned. When the certificate is still valid, but for less than")); |
| 1572 | printf (" %s\n", _("14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when")); | 1631 | printf (" %s\n", _("14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when")); |
| 1573 | printf (" %s\n", _("the certificate is expired.")); | 1632 | printf (" %s\n\n", _("the certificate is expired.")); |
| 1574 | printf ("\n"); | 1633 | printf ("\n"); |
| 1575 | printf (" %s\n\n", "CHECK CERTIFICATE: check_http -H www.verisign.com -C 30,14"); | 1634 | printf (" %s\n\n", "CHECK CERTIFICATE: check_http -H www.verisign.com -C 30,14"); |
| 1576 | printf (" %s\n", _("When the certificate of 'www.verisign.com' is valid for more than 30 days,")); | 1635 | printf (" %s\n", _("When the certificate of 'www.verisign.com' is valid for more than 30 days,")); |
| @@ -1578,6 +1637,13 @@ print_help (void) | |||
| 1578 | printf (" %s\n", _("30 days, but more than 14 days, a STATE_WARNING is returned.")); | 1637 | printf (" %s\n", _("30 days, but more than 14 days, a STATE_WARNING is returned.")); |
| 1579 | printf (" %s\n", _("A STATE_CRITICAL will be returned when certificate expires in less than 14 days")); | 1638 | printf (" %s\n", _("A STATE_CRITICAL will be returned when certificate expires in less than 14 days")); |
| 1580 | 1639 | ||
| 1640 | printf (" %s\n\n", "CHECK SSL WEBSERVER CONTENT VIA PROXY USING HTTP 1.1 CONNECT: "); | ||
| 1641 | printf (" %s\n", _("check_http -I 192.168.100.35 -p 80 -u https://www.verisign.com/ -S -j CONNECT -H www.verisign.com ")); | ||
| 1642 | printf (" %s\n", _("all these options are needed: -I <proxy> -p <proxy-port> -u <check-url> -S(sl) -j CONNECT -H <webserver>")); | ||
| 1643 | printf (" %s\n", _("a STATE_OK will be returned. When the server returns its content but exceeds")); | ||
| 1644 | printf (" %s\n", _("the 5-second threshold, a STATE_WARNING will be returned. When an error occurs,")); | ||
| 1645 | printf (" %s\n", _("a STATE_CRITICAL will be returned.")); | ||
| 1646 | |||
| 1581 | #endif | 1647 | #endif |
| 1582 | 1648 | ||
| 1583 | printf (UT_SUPPORT); | 1649 | printf (UT_SUPPORT); |
diff --git a/plugins/check_ide_smart.c b/plugins/check_ide_smart.c index 47605e96..8d540ca1 100644 --- a/plugins/check_ide_smart.c +++ b/plugins/check_ide_smart.c | |||
| @@ -234,10 +234,10 @@ main (int argc, char *argv[]) | |||
| 234 | break; | 234 | break; |
| 235 | case 'h': | 235 | case 'h': |
| 236 | print_help (); | 236 | print_help (); |
| 237 | return STATE_OK; | 237 | return STATE_UNKNOWN; |
| 238 | case 'V': | 238 | case 'V': |
| 239 | print_revision (progname, NP_VERSION); | 239 | print_revision (progname, NP_VERSION); |
| 240 | return STATE_OK; | 240 | return STATE_UNKNOWN; |
| 241 | default: | 241 | default: |
| 242 | usage5 (); | 242 | usage5 (); |
| 243 | } | 243 | } |
| @@ -249,7 +249,7 @@ main (int argc, char *argv[]) | |||
| 249 | 249 | ||
| 250 | if (!device) { | 250 | if (!device) { |
| 251 | print_help (); | 251 | print_help (); |
| 252 | return STATE_OK; | 252 | return STATE_UNKNOWN; |
| 253 | } | 253 | } |
| 254 | 254 | ||
| 255 | fd = open (device, OPEN_MODE); | 255 | fd = open (device, OPEN_MODE); |
diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c index c371be97..e70d6a51 100644 --- a/plugins/check_ldap.c +++ b/plugins/check_ldap.c | |||
| @@ -1,29 +1,29 @@ | |||
| 1 | /***************************************************************************** | 1 | /***************************************************************************** |
| 2 | * | 2 | * |
| 3 | * Monitoring check_ldap plugin | 3 | * Monitoring check_ldap plugin |
| 4 | * | 4 | * |
| 5 | * License: GPL | 5 | * License: GPL |
| 6 | * Copyright (c) 2000-2008 Monitoring Plugins Development Team | 6 | * Copyright (c) 2000-2008 Monitoring Plugins Development Team |
| 7 | * | 7 | * |
| 8 | * Description: | 8 | * Description: |
| 9 | * | 9 | * |
| 10 | * This file contains the check_ldap plugin | 10 | * This file contains the check_ldap plugin |
| 11 | * | 11 | * |
| 12 | * | 12 | * |
| 13 | * This program is free software: you can redistribute it and/or modify | 13 | * This program is free software: you can redistribute it and/or modify |
| 14 | * it under the terms of the GNU General Public License as published by | 14 | * it under the terms of the GNU General Public License as published by |
| 15 | * the Free Software Foundation, either version 3 of the License, or | 15 | * the Free Software Foundation, either version 3 of the License, or |
| 16 | * (at your option) any later version. | 16 | * (at your option) any later version. |
| 17 | * | 17 | * |
| 18 | * This program is distributed in the hope that it will be useful, | 18 | * This program is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | * GNU General Public License for more details. | 21 | * GNU General Public License for more details. |
| 22 | * | 22 | * |
| 23 | * You should have received a copy of the GNU General Public License | 23 | * You should have received a copy of the GNU General Public License |
| 24 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 24 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 25 | * | 25 | * |
| 26 | * | 26 | * |
| 27 | *****************************************************************************/ | 27 | *****************************************************************************/ |
| 28 | 28 | ||
| 29 | /* progname may be check_ldaps */ | 29 | /* progname may be check_ldaps */ |
| @@ -67,7 +67,10 @@ int ld_protocol = DEFAULT_PROTOCOL; | |||
| 67 | #endif | 67 | #endif |
| 68 | double warn_time = UNDEFINED; | 68 | double warn_time = UNDEFINED; |
| 69 | double crit_time = UNDEFINED; | 69 | double crit_time = UNDEFINED; |
| 70 | thresholds *entries_thresholds = NULL; | ||
| 70 | struct timeval tv; | 71 | struct timeval tv; |
| 72 | char* warn_entries = NULL; | ||
| 73 | char* crit_entries = NULL; | ||
| 71 | int starttls = FALSE; | 74 | int starttls = FALSE; |
| 72 | int ssl_on_connect = FALSE; | 75 | int ssl_on_connect = FALSE; |
| 73 | int verbose = 0; | 76 | int verbose = 0; |
| @@ -94,6 +97,12 @@ main (int argc, char *argv[]) | |||
| 94 | int tls; | 97 | int tls; |
| 95 | int version=3; | 98 | int version=3; |
| 96 | 99 | ||
| 100 | /* for entry counting */ | ||
| 101 | |||
| 102 | LDAPMessage *next_entry; | ||
| 103 | int status_entries = STATE_OK; | ||
| 104 | int num_entries = 0; | ||
| 105 | |||
| 97 | setlocale (LC_ALL, ""); | 106 | setlocale (LC_ALL, ""); |
| 98 | bindtextdomain (PACKAGE, LOCALEDIR); | 107 | bindtextdomain (PACKAGE, LOCALEDIR); |
| 99 | textdomain (PACKAGE); | 108 | textdomain (PACKAGE); |
| @@ -197,12 +206,14 @@ main (int argc, char *argv[]) | |||
| 197 | } | 206 | } |
| 198 | 207 | ||
| 199 | /* do a search of all objectclasses in the base dn */ | 208 | /* do a search of all objectclasses in the base dn */ |
| 200 | if (ldap_search_s (ld, ld_base, LDAP_SCOPE_BASE, ld_attr, NULL, 0, &result) | 209 | if (ldap_search_s (ld, ld_base, (crit_entries!=NULL || warn_entries!=NULL) ? LDAP_SCOPE_SUBTREE : LDAP_SCOPE_BASE, ld_attr, NULL, 0, &result) |
| 201 | != LDAP_SUCCESS) { | 210 | != LDAP_SUCCESS) { |
| 202 | if (verbose) | 211 | if (verbose) |
| 203 | ldap_perror(ld, "ldap_search"); | 212 | ldap_perror(ld, "ldap_search"); |
| 204 | printf (_("Could not search/find objectclasses in %s\n"), ld_base); | 213 | printf (_("Could not search/find objectclasses in %s\n"), ld_base); |
| 205 | return STATE_CRITICAL; | 214 | return STATE_CRITICAL; |
| 215 | } else if (crit_entries!=NULL || warn_entries!=NULL) { | ||
| 216 | num_entries = ldap_count_entries(ld, result); | ||
| 206 | } | 217 | } |
| 207 | 218 | ||
| 208 | /* unbind from the ldap server */ | 219 | /* unbind from the ldap server */ |
| @@ -223,14 +234,42 @@ main (int argc, char *argv[]) | |||
| 223 | else | 234 | else |
| 224 | status = STATE_OK; | 235 | status = STATE_OK; |
| 225 | 236 | ||
| 237 | if(entries_thresholds != NULL) { | ||
| 238 | if (verbose) { | ||
| 239 | printf ("entries found: %d\n", num_entries); | ||
| 240 | print_thresholds("entry threasholds", entries_thresholds); | ||
| 241 | } | ||
| 242 | status_entries = get_status(num_entries, entries_thresholds); | ||
| 243 | if (status_entries == STATE_CRITICAL) { | ||
| 244 | status = STATE_CRITICAL; | ||
| 245 | } else if (status != STATE_CRITICAL) { | ||
| 246 | status = status_entries; | ||
| 247 | } | ||
| 248 | } | ||
| 249 | |||
| 226 | /* print out the result */ | 250 | /* print out the result */ |
| 227 | printf (_("LDAP %s - %.3f seconds response time|%s\n"), | 251 | if (crit_entries!=NULL || warn_entries!=NULL) { |
| 228 | state_text (status), | 252 | printf (_("LDAP %s - found %d entries in %.3f seconds|%s %s\n"), |
| 229 | elapsed_time, | 253 | state_text (status), |
| 230 | fperfdata ("time", elapsed_time, "s", | 254 | num_entries, |
| 231 | (int)warn_time, warn_time, | 255 | elapsed_time, |
| 232 | (int)crit_time, crit_time, | 256 | fperfdata ("time", elapsed_time, "s", |
| 233 | TRUE, 0, FALSE, 0)); | 257 | (int)warn_time, warn_time, |
| 258 | (int)crit_time, crit_time, | ||
| 259 | TRUE, 0, FALSE, 0), | ||
| 260 | sperfdata ("entries", (double)num_entries, "", | ||
| 261 | warn_entries, | ||
| 262 | crit_entries, | ||
| 263 | TRUE, 0.0, FALSE, 0.0)); | ||
| 264 | } else { | ||
| 265 | printf (_("LDAP %s - %.3f seconds response time|%s\n"), | ||
| 266 | state_text (status), | ||
| 267 | elapsed_time, | ||
| 268 | fperfdata ("time", elapsed_time, "s", | ||
| 269 | (int)warn_time, warn_time, | ||
| 270 | (int)crit_time, crit_time, | ||
| 271 | TRUE, 0, FALSE, 0)); | ||
| 272 | } | ||
| 234 | 273 | ||
| 235 | return status; | 274 | return status; |
| 236 | } | 275 | } |
| @@ -263,6 +302,8 @@ process_arguments (int argc, char **argv) | |||
| 263 | {"port", required_argument, 0, 'p'}, | 302 | {"port", required_argument, 0, 'p'}, |
| 264 | {"warn", required_argument, 0, 'w'}, | 303 | {"warn", required_argument, 0, 'w'}, |
| 265 | {"crit", required_argument, 0, 'c'}, | 304 | {"crit", required_argument, 0, 'c'}, |
| 305 | {"warn-entries", required_argument, 0, 'W'}, | ||
| 306 | {"crit-entries", required_argument, 0, 'C'}, | ||
| 266 | {"verbose", no_argument, 0, 'v'}, | 307 | {"verbose", no_argument, 0, 'v'}, |
| 267 | {0, 0, 0, 0} | 308 | {0, 0, 0, 0} |
| 268 | }; | 309 | }; |
| @@ -276,7 +317,7 @@ process_arguments (int argc, char **argv) | |||
| 276 | } | 317 | } |
| 277 | 318 | ||
| 278 | while (1) { | 319 | while (1) { |
| 279 | c = getopt_long (argc, argv, "hvV234TS6t:c:w:H:b:p:a:D:P:", longopts, &option); | 320 | c = getopt_long (argc, argv, "hvV234TS6t:c:w:H:b:p:a:D:P:C:W:", longopts, &option); |
| 280 | 321 | ||
| 281 | if (c == -1 || c == EOF) | 322 | if (c == -1 || c == EOF) |
| 282 | break; | 323 | break; |
| @@ -284,10 +325,10 @@ process_arguments (int argc, char **argv) | |||
| 284 | switch (c) { | 325 | switch (c) { |
| 285 | case 'h': /* help */ | 326 | case 'h': /* help */ |
| 286 | print_help (); | 327 | print_help (); |
| 287 | exit (STATE_OK); | 328 | exit (STATE_UNKNOWN); |
| 288 | case 'V': /* version */ | 329 | case 'V': /* version */ |
| 289 | print_revision (progname, NP_VERSION); | 330 | print_revision (progname, NP_VERSION); |
| 290 | exit (STATE_OK); | 331 | exit (STATE_UNKNOWN); |
| 291 | case 't': /* timeout period */ | 332 | case 't': /* timeout period */ |
| 292 | if (!is_intnonneg (optarg)) | 333 | if (!is_intnonneg (optarg)) |
| 293 | usage2 (_("Timeout interval must be a positive integer"), optarg); | 334 | usage2 (_("Timeout interval must be a positive integer"), optarg); |
| @@ -318,6 +359,12 @@ process_arguments (int argc, char **argv) | |||
| 318 | case 'c': | 359 | case 'c': |
| 319 | crit_time = strtod (optarg, NULL); | 360 | crit_time = strtod (optarg, NULL); |
| 320 | break; | 361 | break; |
| 362 | case 'W': | ||
| 363 | warn_entries = optarg; | ||
| 364 | break; | ||
| 365 | case 'C': | ||
| 366 | crit_entries = optarg; | ||
| 367 | break; | ||
| 321 | #ifdef HAVE_LDAP_SET_OPTION | 368 | #ifdef HAVE_LDAP_SET_OPTION |
| 322 | case '2': | 369 | case '2': |
| 323 | ld_protocol = 2; | 370 | ld_protocol = 2; |
| @@ -381,6 +428,10 @@ validate_arguments () | |||
| 381 | if (ld_base==NULL) | 428 | if (ld_base==NULL) |
| 382 | usage4 (_("Please specify the LDAP base\n")); | 429 | usage4 (_("Please specify the LDAP base\n")); |
| 383 | 430 | ||
| 431 | if (crit_entries!=NULL || warn_entries!=NULL) { | ||
| 432 | set_thresholds(&entries_thresholds, | ||
| 433 | warn_entries, crit_entries); | ||
| 434 | } | ||
| 384 | return OK; | 435 | return OK; |
| 385 | } | 436 | } |
| 386 | 437 | ||
| @@ -430,6 +481,11 @@ print_help (void) | |||
| 430 | 481 | ||
| 431 | printf (UT_WARN_CRIT); | 482 | printf (UT_WARN_CRIT); |
| 432 | 483 | ||
| 484 | printf (" %s\n", "-W [--warn-entries]"); | ||
| 485 | printf (" %s\n", _("Number of found entries to result in warning status")); | ||
| 486 | printf (" %s\n", "-W [--crit-entries]"); | ||
| 487 | printf (" %s\n", _("Number of found entries to result in critical status")); | ||
| 488 | |||
| 433 | printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); | 489 | printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); |
| 434 | 490 | ||
| 435 | printf (UT_VERBOSE); | 491 | printf (UT_VERBOSE); |
| @@ -441,6 +497,7 @@ print_help (void) | |||
| 441 | printf (" %s\n", _("'SSL on connect' will be used no matter how the plugin was called.")); | 497 | printf (" %s\n", _("'SSL on connect' will be used no matter how the plugin was called.")); |
| 442 | printf (" %s\n", _("This detection is deprecated, please use 'check_ldap' with the '--starttls' or '--ssl' flags")); | 498 | printf (" %s\n", _("This detection is deprecated, please use 'check_ldap' with the '--starttls' or '--ssl' flags")); |
| 443 | printf (" %s\n", _("to define the behaviour explicitly instead.")); | 499 | printf (" %s\n", _("to define the behaviour explicitly instead.")); |
| 500 | printf (" %s\n", _("The parameters --warn-entries and --crit-entries are optional.")); | ||
| 444 | 501 | ||
| 445 | printf (UT_SUPPORT); | 502 | printf (UT_SUPPORT); |
| 446 | } | 503 | } |
diff --git a/plugins/check_load.c b/plugins/check_load.c index cde63e56..a96435f4 100644 --- a/plugins/check_load.c +++ b/plugins/check_load.c | |||
| @@ -251,10 +251,10 @@ process_arguments (int argc, char **argv) | |||
| 251 | break; | 251 | break; |
| 252 | case 'V': /* version */ | 252 | case 'V': /* version */ |
| 253 | print_revision (progname, NP_VERSION); | 253 | print_revision (progname, NP_VERSION); |
| 254 | exit (STATE_OK); | 254 | exit (STATE_UNKNOWN); |
| 255 | case 'h': /* help */ | 255 | case 'h': /* help */ |
| 256 | print_help (); | 256 | print_help (); |
| 257 | exit (STATE_OK); | 257 | exit (STATE_UNKNOWN); |
| 258 | case '?': /* help */ | 258 | case '?': /* help */ |
| 259 | usage5 (); | 259 | usage5 (); |
| 260 | } | 260 | } |
diff --git a/plugins/check_mrtg.c b/plugins/check_mrtg.c index cf3fe044..1fda5492 100644 --- a/plugins/check_mrtg.c +++ b/plugins/check_mrtg.c | |||
| @@ -234,10 +234,10 @@ process_arguments (int argc, char **argv) | |||
| 234 | break; | 234 | break; |
| 235 | case 'V': /* version */ | 235 | case 'V': /* version */ |
| 236 | print_revision (progname, NP_VERSION); | 236 | print_revision (progname, NP_VERSION); |
| 237 | exit (STATE_OK); | 237 | exit (STATE_UNKNOWN); |
| 238 | case 'h': /* help */ | 238 | case 'h': /* help */ |
| 239 | print_help (); | 239 | print_help (); |
| 240 | exit (STATE_OK); | 240 | exit (STATE_UNKNOWN); |
| 241 | case '?': /* help */ | 241 | case '?': /* help */ |
| 242 | usage5 (); | 242 | usage5 (); |
| 243 | } | 243 | } |
diff --git a/plugins/check_mrtgtraf.c b/plugins/check_mrtgtraf.c index 32ba0507..eb66f622 100644 --- a/plugins/check_mrtgtraf.c +++ b/plugins/check_mrtgtraf.c | |||
| @@ -148,37 +148,37 @@ main (int argc, char **argv) | |||
| 148 | 148 | ||
| 149 | /* report incoming traffic in Bytes/sec */ | 149 | /* report incoming traffic in Bytes/sec */ |
| 150 | if (incoming_rate < 1024) { | 150 | if (incoming_rate < 1024) { |
| 151 | strcpy (incoming_speed_rating, "B/s"); | 151 | strcpy (incoming_speed_rating, "B"); |
| 152 | adjusted_incoming_rate = (double) incoming_rate; | 152 | adjusted_incoming_rate = (double) incoming_rate; |
| 153 | } | 153 | } |
| 154 | 154 | ||
| 155 | /* report incoming traffic in KBytes/sec */ | 155 | /* report incoming traffic in KBytes/sec */ |
| 156 | else if (incoming_rate < (1024 * 1024)) { | 156 | else if (incoming_rate < (1024 * 1024)) { |
| 157 | strcpy (incoming_speed_rating, "KB/s"); | 157 | strcpy (incoming_speed_rating, "KB"); |
| 158 | adjusted_incoming_rate = (double) (incoming_rate / 1024.0); | 158 | adjusted_incoming_rate = (double) (incoming_rate / 1024.0); |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | /* report incoming traffic in MBytes/sec */ | 161 | /* report incoming traffic in MBytes/sec */ |
| 162 | else { | 162 | else { |
| 163 | strcpy (incoming_speed_rating, "MB/s"); | 163 | strcpy (incoming_speed_rating, "MB"); |
| 164 | adjusted_incoming_rate = (double) (incoming_rate / 1024.0 / 1024.0); | 164 | adjusted_incoming_rate = (double) (incoming_rate / 1024.0 / 1024.0); |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | /* report outgoing traffic in Bytes/sec */ | 167 | /* report outgoing traffic in Bytes/sec */ |
| 168 | if (outgoing_rate < 1024) { | 168 | if (outgoing_rate < 1024) { |
| 169 | strcpy (outgoing_speed_rating, "B/s"); | 169 | strcpy (outgoing_speed_rating, "B"); |
| 170 | adjusted_outgoing_rate = (double) outgoing_rate; | 170 | adjusted_outgoing_rate = (double) outgoing_rate; |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | /* report outgoing traffic in KBytes/sec */ | 173 | /* report outgoing traffic in KBytes/sec */ |
| 174 | else if (outgoing_rate < (1024 * 1024)) { | 174 | else if (outgoing_rate < (1024 * 1024)) { |
| 175 | strcpy (outgoing_speed_rating, "KB/s"); | 175 | strcpy (outgoing_speed_rating, "KB"); |
| 176 | adjusted_outgoing_rate = (double) (outgoing_rate / 1024.0); | 176 | adjusted_outgoing_rate = (double) (outgoing_rate / 1024.0); |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | /* report outgoing traffic in MBytes/sec */ | 179 | /* report outgoing traffic in MBytes/sec */ |
| 180 | else { | 180 | else { |
| 181 | strcpy (outgoing_speed_rating, "MB/s"); | 181 | strcpy (outgoing_speed_rating, "MB"); |
| 182 | adjusted_outgoing_rate = (double) (outgoing_rate / 1024.0 / 1024.0); | 182 | adjusted_outgoing_rate = (double) (outgoing_rate / 1024.0 / 1024.0); |
| 183 | } | 183 | } |
| 184 | 184 | ||
| @@ -191,7 +191,7 @@ main (int argc, char **argv) | |||
| 191 | result = STATE_WARNING; | 191 | result = STATE_WARNING; |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | xasprintf (&error_message, _("%s. In = %0.1f %s, %s. Out = %0.1f %s|%s %s\n"), | 194 | xasprintf (&error_message, _("%s. In = %0.1f %s/s, %s. Out = %0.1f %s/s|%s %s\n"), |
| 195 | (use_average == TRUE) ? _("Avg") : _("Max"), adjusted_incoming_rate, | 195 | (use_average == TRUE) ? _("Avg") : _("Max"), adjusted_incoming_rate, |
| 196 | incoming_speed_rating, (use_average == TRUE) ? _("Avg") : _("Max"), | 196 | incoming_speed_rating, (use_average == TRUE) ? _("Avg") : _("Max"), |
| 197 | adjusted_outgoing_rate, outgoing_speed_rating, | 197 | adjusted_outgoing_rate, outgoing_speed_rating, |
| @@ -270,10 +270,10 @@ process_arguments (int argc, char **argv) | |||
| 270 | break; | 270 | break; |
| 271 | case 'V': /* version */ | 271 | case 'V': /* version */ |
| 272 | print_revision (progname, NP_VERSION); | 272 | print_revision (progname, NP_VERSION); |
| 273 | exit (STATE_OK); | 273 | exit (STATE_UNKNOWN); |
| 274 | case 'h': /* help */ | 274 | case 'h': /* help */ |
| 275 | print_help (); | 275 | print_help (); |
| 276 | exit (STATE_OK); | 276 | exit (STATE_UNKNOWN); |
| 277 | case '?': /* help */ | 277 | case '?': /* help */ |
| 278 | usage5 (); | 278 | usage5 (); |
| 279 | } | 279 | } |
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c index 216626bc..5773afd9 100644 --- a/plugins/check_mysql.c +++ b/plugins/check_mysql.c | |||
| @@ -444,10 +444,10 @@ process_arguments (int argc, char **argv) | |||
| 444 | break; | 444 | break; |
| 445 | case 'V': /* version */ | 445 | case 'V': /* version */ |
| 446 | print_revision (progname, NP_VERSION); | 446 | print_revision (progname, NP_VERSION); |
| 447 | exit (STATE_OK); | 447 | exit (STATE_UNKNOWN); |
| 448 | case 'h': /* help */ | 448 | case 'h': /* help */ |
| 449 | print_help (); | 449 | print_help (); |
| 450 | exit (STATE_OK); | 450 | exit (STATE_UNKNOWN); |
| 451 | case 'v': | 451 | case 'v': |
| 452 | verbose++; | 452 | verbose++; |
| 453 | break; | 453 | break; |
diff --git a/plugins/check_mysql_query.c b/plugins/check_mysql_query.c index 71ab7768..49a14dd3 100644 --- a/plugins/check_mysql_query.c +++ b/plugins/check_mysql_query.c | |||
| @@ -250,10 +250,10 @@ process_arguments (int argc, char **argv) | |||
| 250 | break; | 250 | break; |
| 251 | case 'V': /* version */ | 251 | case 'V': /* version */ |
| 252 | print_revision (progname, NP_VERSION); | 252 | print_revision (progname, NP_VERSION); |
| 253 | exit (STATE_OK); | 253 | exit (STATE_UNKNOWN); |
| 254 | case 'h': /* help */ | 254 | case 'h': /* help */ |
| 255 | print_help (); | 255 | print_help (); |
| 256 | exit (STATE_OK); | 256 | exit (STATE_UNKNOWN); |
| 257 | case 'q': | 257 | case 'q': |
| 258 | xasprintf(&sql_query, "%s", optarg); | 258 | xasprintf(&sql_query, "%s", optarg); |
| 259 | break; | 259 | break; |
diff --git a/plugins/check_nagios.c b/plugins/check_nagios.c index 791b6dbe..40d68f03 100644 --- a/plugins/check_nagios.c +++ b/plugins/check_nagios.c | |||
| @@ -235,10 +235,10 @@ process_arguments (int argc, char **argv) | |||
| 235 | switch (c) { | 235 | switch (c) { |
| 236 | case 'h': /* help */ | 236 | case 'h': /* help */ |
| 237 | print_help (); | 237 | print_help (); |
| 238 | exit (STATE_OK); | 238 | exit (STATE_UNKNOWN); |
| 239 | case 'V': /* version */ | 239 | case 'V': /* version */ |
| 240 | print_revision (progname, NP_VERSION); | 240 | print_revision (progname, NP_VERSION); |
| 241 | exit (STATE_OK); | 241 | exit (STATE_UNKNOWN); |
| 242 | case 'F': /* status log */ | 242 | case 'F': /* status log */ |
| 243 | status_log = optarg; | 243 | status_log = optarg; |
| 244 | break; | 244 | break; |
diff --git a/plugins/check_nt.c b/plugins/check_nt.c index fefbfb7a..59c135db 100644 --- a/plugins/check_nt.c +++ b/plugins/check_nt.c | |||
| @@ -197,19 +197,40 @@ int main(int argc, char **argv){ | |||
| 197 | 197 | ||
| 198 | case CHECK_UPTIME: | 198 | case CHECK_UPTIME: |
| 199 | 199 | ||
| 200 | xasprintf(&send_buffer, "%s&3", req_password); | 200 | if (value_list == NULL) { |
| 201 | fetch_data (server_address, server_port, send_buffer); | 201 | value_list = "minutes"; |
| 202 | uptime=strtoul(recv_buffer,NULL,10); | 202 | } |
| 203 | updays = uptime / 86400; | 203 | if (strncmp(value_list, "seconds", strlen("seconds") + 1 ) && |
| 204 | uphours = (uptime % 86400) / 3600; | 204 | strncmp(value_list, "minutes", strlen("minutes") + 1) && |
| 205 | upminutes = ((uptime % 86400) % 3600) / 60; | 205 | strncmp(value_list, "hours", strlen("hours") + 1) && |
| 206 | xasprintf(&output_message,_("System Uptime - %u day(s) %u hour(s) %u minute(s)|uptime=%lu"), updays, uphours, upminutes, uptime); | 206 | strncmp(value_list, "days", strlen("days") + 1)) { |
| 207 | if (check_critical_value==TRUE && uptime <= critical_value) | 207 | |
| 208 | return_code=STATE_CRITICAL; | 208 | output_message = strdup (_("wrong -l argument")); |
| 209 | else if (check_warning_value==TRUE && uptime <= warning_value) | 209 | } else { |
| 210 | return_code=STATE_WARNING; | 210 | xasprintf(&send_buffer, "%s&3", req_password); |
| 211 | else | 211 | fetch_data (server_address, server_port, send_buffer); |
| 212 | return_code=STATE_OK; | 212 | uptime=strtoul(recv_buffer,NULL,10); |
| 213 | updays = uptime / 86400; | ||
| 214 | uphours = (uptime % 86400) / 3600; | ||
| 215 | upminutes = ((uptime % 86400) % 3600) / 60; | ||
| 216 | |||
| 217 | if (!strncmp(value_list, "minutes", strlen("minutes"))) | ||
| 218 | uptime = uptime / 60; | ||
| 219 | else if (!strncmp(value_list, "hours", strlen("hours"))) | ||
| 220 | uptime = uptime / 3600; | ||
| 221 | else if (!strncmp(value_list, "days", strlen("days"))) | ||
| 222 | uptime = uptime / 86400; | ||
| 223 | /* else uptime in seconds, nothing to do */ | ||
| 224 | |||
| 225 | xasprintf(&output_message,_("System Uptime - %u day(s) %u hour(s) %u minute(s) |uptime=%lu"),updays, uphours, upminutes, uptime); | ||
| 226 | |||
| 227 | if (check_critical_value==TRUE && uptime <= critical_value) | ||
| 228 | return_code=STATE_CRITICAL; | ||
| 229 | else if (check_warning_value==TRUE && uptime <= warning_value) | ||
| 230 | return_code=STATE_WARNING; | ||
| 231 | else | ||
| 232 | return_code=STATE_OK; | ||
| 233 | } | ||
| 213 | break; | 234 | break; |
| 214 | 235 | ||
| 215 | case CHECK_USEDDISKSPACE: | 236 | case CHECK_USEDDISKSPACE: |
| @@ -532,10 +553,10 @@ int process_arguments(int argc, char **argv){ | |||
| 532 | usage5 (); | 553 | usage5 (); |
| 533 | case 'h': /* help */ | 554 | case 'h': /* help */ |
| 534 | print_help(); | 555 | print_help(); |
| 535 | exit(STATE_OK); | 556 | exit(STATE_UNKNOWN); |
| 536 | case 'V': /* version */ | 557 | case 'V': /* version */ |
| 537 | print_revision(progname, NP_VERSION); | 558 | print_revision(progname, NP_VERSION); |
| 538 | exit(STATE_OK); | 559 | exit(STATE_UNKNOWN); |
| 539 | case 'H': /* hostname */ | 560 | case 'H': /* hostname */ |
| 540 | server_address = optarg; | 561 | server_address = optarg; |
| 541 | break; | 562 | break; |
| @@ -713,7 +734,9 @@ void print_help(void) | |||
| 713 | printf (" %s\n", "ie: -l 60,90,95,120,90,95"); | 734 | printf (" %s\n", "ie: -l 60,90,95,120,90,95"); |
| 714 | printf (" %s\n", "UPTIME ="); | 735 | printf (" %s\n", "UPTIME ="); |
| 715 | printf (" %s\n", _("Get the uptime of the machine.")); | 736 | printf (" %s\n", _("Get the uptime of the machine.")); |
| 716 | printf (" %s\n", _("No specific parameters. No warning or critical threshold")); | 737 | printf (" %s\n", _("-l <unit> ")); |
| 738 | printf (" %s\n", _("<unit> = seconds, minutes, hours, or days. (default: minutes)")); | ||
| 739 | printf (" %s\n", _("Thresholds will use the unit specified above.")); | ||
| 717 | printf (" %s\n", "USEDDISKSPACE ="); | 740 | printf (" %s\n", "USEDDISKSPACE ="); |
| 718 | printf (" %s\n", _("Size and percentage of disk use.")); | 741 | printf (" %s\n", _("Size and percentage of disk use.")); |
| 719 | printf (" %s\n", _("Request a -l parameter containing the drive letter only.")); | 742 | printf (" %s\n", _("Request a -l parameter containing the drive letter only.")); |
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c index a7d278de..75efc289 100644 --- a/plugins/check_ntp.c +++ b/plugins/check_ntp.c | |||
| @@ -691,11 +691,11 @@ int process_arguments(int argc, char **argv){ | |||
| 691 | switch (c) { | 691 | switch (c) { |
| 692 | case 'h': | 692 | case 'h': |
| 693 | print_help(); | 693 | print_help(); |
| 694 | exit(STATE_OK); | 694 | exit(STATE_UNKNOWN); |
| 695 | break; | 695 | break; |
| 696 | case 'V': | 696 | case 'V': |
| 697 | print_revision(progname, NP_VERSION); | 697 | print_revision(progname, NP_VERSION); |
| 698 | exit(STATE_OK); | 698 | exit(STATE_UNKNOWN); |
| 699 | break; | 699 | break; |
| 700 | case 'v': | 700 | case 'v': |
| 701 | verbose++; | 701 | verbose++; |
diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c index 44424af5..c656b0f5 100644 --- a/plugins/check_ntp_peer.c +++ b/plugins/check_ntp_peer.c | |||
| @@ -448,11 +448,11 @@ int process_arguments(int argc, char **argv){ | |||
| 448 | switch (c) { | 448 | switch (c) { |
| 449 | case 'h': | 449 | case 'h': |
| 450 | print_help(); | 450 | print_help(); |
| 451 | exit(STATE_OK); | 451 | exit(STATE_UNKNOWN); |
| 452 | break; | 452 | break; |
| 453 | case 'V': | 453 | case 'V': |
| 454 | print_revision(progname, NP_VERSION); | 454 | print_revision(progname, NP_VERSION); |
| 455 | exit(STATE_OK); | 455 | exit(STATE_UNKNOWN); |
| 456 | break; | 456 | break; |
| 457 | case 'v': | 457 | case 'v': |
| 458 | verbose++; | 458 | verbose++; |
diff --git a/plugins/check_ntp_time.c b/plugins/check_ntp_time.c index e344f8b7..295f86f6 100644 --- a/plugins/check_ntp_time.c +++ b/plugins/check_ntp_time.c | |||
| @@ -477,11 +477,11 @@ int process_arguments(int argc, char **argv){ | |||
| 477 | switch (c) { | 477 | switch (c) { |
| 478 | case 'h': | 478 | case 'h': |
| 479 | print_help(); | 479 | print_help(); |
| 480 | exit(STATE_OK); | 480 | exit(STATE_UNKNOWN); |
| 481 | break; | 481 | break; |
| 482 | case 'V': | 482 | case 'V': |
| 483 | print_revision(progname, NP_VERSION); | 483 | print_revision(progname, NP_VERSION); |
| 484 | exit(STATE_OK); | 484 | exit(STATE_UNKNOWN); |
| 485 | break; | 485 | break; |
| 486 | case 'v': | 486 | case 'v': |
| 487 | verbose++; | 487 | verbose++; |
diff --git a/plugins/check_nwstat.c b/plugins/check_nwstat.c index 1a7bfa16..e7e8de05 100644 --- a/plugins/check_nwstat.c +++ b/plugins/check_nwstat.c | |||
| @@ -1354,10 +1354,10 @@ int process_arguments(int argc, char **argv) { | |||
| 1354 | usage5 (); | 1354 | usage5 (); |
| 1355 | case 'h': /* help */ | 1355 | case 'h': /* help */ |
| 1356 | print_help(); | 1356 | print_help(); |
| 1357 | exit(STATE_OK); | 1357 | exit(STATE_UNKNOWN); |
| 1358 | case 'V': /* version */ | 1358 | case 'V': /* version */ |
| 1359 | print_revision(progname, NP_VERSION); | 1359 | print_revision(progname, NP_VERSION); |
| 1360 | exit(STATE_OK); | 1360 | exit(STATE_UNKNOWN); |
| 1361 | case 'H': /* hostname */ | 1361 | case 'H': /* hostname */ |
| 1362 | server_address=optarg; | 1362 | server_address=optarg; |
| 1363 | break; | 1363 | break; |
diff --git a/plugins/check_overcr.c b/plugins/check_overcr.c index af5eb9b9..9a4d25fa 100644 --- a/plugins/check_overcr.c +++ b/plugins/check_overcr.c | |||
| @@ -340,10 +340,10 @@ process_arguments (int argc, char **argv) | |||
| 340 | usage5 (); | 340 | usage5 (); |
| 341 | case 'h': /* help */ | 341 | case 'h': /* help */ |
| 342 | print_help (); | 342 | print_help (); |
| 343 | exit (STATE_OK); | 343 | exit (STATE_UNKNOWN); |
| 344 | case 'V': /* version */ | 344 | case 'V': /* version */ |
| 345 | print_revision (progname, NP_VERSION); | 345 | print_revision (progname, NP_VERSION); |
| 346 | exit (STATE_OK); | 346 | exit (STATE_UNKNOWN); |
| 347 | case 'H': /* hostname */ | 347 | case 'H': /* hostname */ |
| 348 | server_address = optarg; | 348 | server_address = optarg; |
| 349 | break; | 349 | break; |
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c index 9bad1ec5..2eb699e8 100644 --- a/plugins/check_pgsql.c +++ b/plugins/check_pgsql.c | |||
| @@ -302,10 +302,10 @@ process_arguments (int argc, char **argv) | |||
| 302 | usage5 (); | 302 | usage5 (); |
| 303 | case 'h': /* help */ | 303 | case 'h': /* help */ |
| 304 | print_help (); | 304 | print_help (); |
| 305 | exit (STATE_OK); | 305 | exit (STATE_UNKNOWN); |
| 306 | case 'V': /* version */ | 306 | case 'V': /* version */ |
| 307 | print_revision (progname, NP_VERSION); | 307 | print_revision (progname, NP_VERSION); |
| 308 | exit (STATE_OK); | 308 | exit (STATE_UNKNOWN); |
| 309 | case 't': /* timeout period */ | 309 | case 't': /* timeout period */ |
| 310 | if (!is_integer (optarg)) | 310 | if (!is_integer (optarg)) |
| 311 | usage2 (_("Timeout interval must be a positive integer"), optarg); | 311 | usage2 (_("Timeout interval must be a positive integer"), optarg); |
diff --git a/plugins/check_ping.c b/plugins/check_ping.c index dbc5c3e4..423ecbe5 100644 --- a/plugins/check_ping.c +++ b/plugins/check_ping.c | |||
| @@ -224,11 +224,11 @@ process_arguments (int argc, char **argv) | |||
| 224 | usage5 (); | 224 | usage5 (); |
| 225 | case 'h': /* help */ | 225 | case 'h': /* help */ |
| 226 | print_help (); | 226 | print_help (); |
| 227 | exit (STATE_OK); | 227 | exit (STATE_UNKNOWN); |
| 228 | break; | 228 | break; |
| 229 | case 'V': /* version */ | 229 | case 'V': /* version */ |
| 230 | print_revision (progname, NP_VERSION); | 230 | print_revision (progname, NP_VERSION); |
| 231 | exit (STATE_OK); | 231 | exit (STATE_UNKNOWN); |
| 232 | break; | 232 | break; |
| 233 | case 't': /* timeout period */ | 233 | case 't': /* timeout period */ |
| 234 | timeout_interval = atoi (optarg); | 234 | timeout_interval = atoi (optarg); |
diff --git a/plugins/check_procs.c b/plugins/check_procs.c index 402aac53..4bcc56bc 100644 --- a/plugins/check_procs.c +++ b/plugins/check_procs.c | |||
| @@ -428,10 +428,10 @@ process_arguments (int argc, char **argv) | |||
| 428 | usage5 (); | 428 | usage5 (); |
| 429 | case 'h': /* help */ | 429 | case 'h': /* help */ |
| 430 | print_help (); | 430 | print_help (); |
| 431 | exit (STATE_OK); | 431 | exit (STATE_UNKNOWN); |
| 432 | case 'V': /* version */ | 432 | case 'V': /* version */ |
| 433 | print_revision (progname, NP_VERSION); | 433 | print_revision (progname, NP_VERSION); |
| 434 | exit (STATE_OK); | 434 | exit (STATE_UNKNOWN); |
| 435 | case 't': /* timeout period */ | 435 | case 't': /* timeout period */ |
| 436 | if (!is_integer (optarg)) | 436 | if (!is_integer (optarg)) |
| 437 | usage2 (_("Timeout interval must be a positive integer"), optarg); | 437 | usage2 (_("Timeout interval must be a positive integer"), optarg); |
diff --git a/plugins/check_radius.c b/plugins/check_radius.c index b2943475..03cbb8b0 100644 --- a/plugins/check_radius.c +++ b/plugins/check_radius.c | |||
| @@ -259,10 +259,10 @@ process_arguments (int argc, char **argv) | |||
| 259 | usage5 (); | 259 | usage5 (); |
| 260 | case 'h': /* help */ | 260 | case 'h': /* help */ |
| 261 | print_help (); | 261 | print_help (); |
| 262 | exit (OK); | 262 | exit (STATE_UNKNOWN); |
| 263 | case 'V': /* version */ | 263 | case 'V': /* version */ |
| 264 | print_revision (progname, NP_VERSION); | 264 | print_revision (progname, NP_VERSION); |
| 265 | exit (OK); | 265 | exit (STATE_UNKNOWN); |
| 266 | case 'v': /* verbose mode */ | 266 | case 'v': /* verbose mode */ |
| 267 | verbose = TRUE; | 267 | verbose = TRUE; |
| 268 | break; | 268 | break; |
diff --git a/plugins/check_real.c b/plugins/check_real.c index 1816bf56..6491e6e9 100644 --- a/plugins/check_real.c +++ b/plugins/check_real.c | |||
| @@ -163,17 +163,17 @@ main (int argc, char **argv) | |||
| 163 | 163 | ||
| 164 | /* Part I - Server Check */ | 164 | /* Part I - Server Check */ |
| 165 | 165 | ||
| 166 | /* send the OPTIONS request */ | 166 | /* send the DESCRIBE request */ |
| 167 | sprintf (buffer, "DESCRIBE rtsp://%s:%d%s RTSP/1.0\n", host_name, | 167 | sprintf (buffer, "DESCRIBE rtsp://%s:%d%s RTSP/1.0\r\n", host_name, |
| 168 | server_port, server_url); | 168 | server_port, server_url); |
| 169 | result = send (sd, buffer, strlen (buffer), 0); | 169 | result = send (sd, buffer, strlen (buffer), 0); |
| 170 | 170 | ||
| 171 | /* send the header sync */ | 171 | /* send the header sync */ |
| 172 | sprintf (buffer, "CSeq: 2\n"); | 172 | sprintf (buffer, "CSeq: 2\r\n"); |
| 173 | result = send (sd, buffer, strlen (buffer), 0); | 173 | result = send (sd, buffer, strlen (buffer), 0); |
| 174 | 174 | ||
| 175 | /* send a newline so the server knows we're done with the request */ | 175 | /* send a newline so the server knows we're done with the request */ |
| 176 | sprintf (buffer, "\n"); | 176 | sprintf (buffer, "\r\n"); |
| 177 | result = send (sd, buffer, strlen (buffer), 0); | 177 | result = send (sd, buffer, strlen (buffer), 0); |
| 178 | 178 | ||
| 179 | /* watch for the REAL connection string */ | 179 | /* watch for the REAL connection string */ |
| @@ -359,10 +359,10 @@ process_arguments (int argc, char **argv) | |||
| 359 | break; | 359 | break; |
| 360 | case 'V': /* version */ | 360 | case 'V': /* version */ |
| 361 | print_revision (progname, NP_VERSION); | 361 | print_revision (progname, NP_VERSION); |
| 362 | exit (STATE_OK); | 362 | exit (STATE_UNKNOWN); |
| 363 | case 'h': /* help */ | 363 | case 'h': /* help */ |
| 364 | print_help (); | 364 | print_help (); |
| 365 | exit (STATE_OK); | 365 | exit (STATE_UNKNOWN); |
| 366 | case '?': /* usage */ | 366 | case '?': /* usage */ |
| 367 | usage5 (); | 367 | usage5 (); |
| 368 | } | 368 | } |
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index 24304534..1996c6d3 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c | |||
| @@ -231,7 +231,7 @@ main (int argc, char **argv) | |||
| 231 | send(sd, SMTP_STARTTLS, strlen(SMTP_STARTTLS), 0); | 231 | send(sd, SMTP_STARTTLS, strlen(SMTP_STARTTLS), 0); |
| 232 | 232 | ||
| 233 | recvlines(buffer, MAX_INPUT_BUFFER); /* wait for it */ | 233 | recvlines(buffer, MAX_INPUT_BUFFER); /* wait for it */ |
| 234 | if (!strstr (buffer, server_expect)) { | 234 | if (!strstr (buffer, SMTP_EXPECT)) { |
| 235 | printf (_("Server does not support STARTTLS\n")); | 235 | printf (_("Server does not support STARTTLS\n")); |
| 236 | smtp_quit(); | 236 | smtp_quit(); |
| 237 | return STATE_UNKNOWN; | 237 | return STATE_UNKNOWN; |
| @@ -276,6 +276,7 @@ main (int argc, char **argv) | |||
| 276 | # ifdef USE_OPENSSL | 276 | # ifdef USE_OPENSSL |
| 277 | if ( check_cert ) { | 277 | if ( check_cert ) { |
| 278 | result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit); | 278 | result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit); |
| 279 | smtp_quit(); | ||
| 279 | my_close(); | 280 | my_close(); |
| 280 | return result; | 281 | return result; |
| 281 | } | 282 | } |
| @@ -581,11 +582,6 @@ process_arguments (int argc, char **argv) | |||
| 581 | usage4 (_("Timeout interval must be a positive integer")); | 582 | usage4 (_("Timeout interval must be a positive integer")); |
| 582 | } | 583 | } |
| 583 | break; | 584 | break; |
| 584 | case 'S': | ||
| 585 | /* starttls */ | ||
| 586 | use_ssl = TRUE; | ||
| 587 | use_ehlo = TRUE; | ||
| 588 | break; | ||
| 589 | case 'D': | 585 | case 'D': |
| 590 | /* Check SSL cert validity */ | 586 | /* Check SSL cert validity */ |
| 591 | #ifdef USE_OPENSSL | 587 | #ifdef USE_OPENSSL |
| @@ -607,9 +603,14 @@ process_arguments (int argc, char **argv) | |||
| 607 | days_till_exp_warn = atoi (optarg); | 603 | days_till_exp_warn = atoi (optarg); |
| 608 | } | 604 | } |
| 609 | check_cert = TRUE; | 605 | check_cert = TRUE; |
| 606 | ignore_send_quit_failure = TRUE; | ||
| 610 | #else | 607 | #else |
| 611 | usage (_("SSL support not available - install OpenSSL and recompile")); | 608 | usage (_("SSL support not available - install OpenSSL and recompile")); |
| 612 | #endif | 609 | #endif |
| 610 | case 'S': | ||
| 611 | /* starttls */ | ||
| 612 | use_ssl = TRUE; | ||
| 613 | use_ehlo = TRUE; | ||
| 613 | break; | 614 | break; |
| 614 | case '4': | 615 | case '4': |
| 615 | address_family = AF_INET; | 616 | address_family = AF_INET; |
| @@ -623,10 +624,10 @@ process_arguments (int argc, char **argv) | |||
| 623 | break; | 624 | break; |
| 624 | case 'V': /* version */ | 625 | case 'V': /* version */ |
| 625 | print_revision (progname, NP_VERSION); | 626 | print_revision (progname, NP_VERSION); |
| 626 | exit (STATE_OK); | 627 | exit (STATE_UNKNOWN); |
| 627 | case 'h': /* help */ | 628 | case 'h': /* help */ |
| 628 | print_help (); | 629 | print_help (); |
| 629 | exit (STATE_OK); | 630 | exit (STATE_UNKNOWN); |
| 630 | case '?': /* help */ | 631 | case '?': /* help */ |
| 631 | usage5 (); | 632 | usage5 (); |
| 632 | } | 633 | } |
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 6d7ec6d9..9839d6e8 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
| @@ -103,6 +103,8 @@ int errcode, excode; | |||
| 103 | 103 | ||
| 104 | char *server_address = NULL; | 104 | char *server_address = NULL; |
| 105 | char *community = NULL; | 105 | char *community = NULL; |
| 106 | char **contextargs = NULL; | ||
| 107 | char *context = NULL; | ||
| 106 | char **authpriv = NULL; | 108 | char **authpriv = NULL; |
| 107 | char *proto = NULL; | 109 | char *proto = NULL; |
| 108 | char *seclevel = NULL; | 110 | char *seclevel = NULL; |
| @@ -127,6 +129,7 @@ size_t nunits = 0; | |||
| 127 | size_t unitv_size = OID_COUNT_STEP; | 129 | size_t unitv_size = OID_COUNT_STEP; |
| 128 | int numoids = 0; | 130 | int numoids = 0; |
| 129 | int numauthpriv = 0; | 131 | int numauthpriv = 0; |
| 132 | int numcontext = 0; | ||
| 130 | int verbose = 0; | 133 | int verbose = 0; |
| 131 | int usesnmpgetnext = FALSE; | 134 | int usesnmpgetnext = FALSE; |
| 132 | char *warning_thresholds = NULL; | 135 | char *warning_thresholds = NULL; |
| @@ -296,8 +299,8 @@ main (int argc, char **argv) | |||
| 296 | snmpcmd = strdup (PATH_TO_SNMPGET); | 299 | snmpcmd = strdup (PATH_TO_SNMPGET); |
| 297 | } | 300 | } |
| 298 | 301 | ||
| 299 | /* 10 arguments to pass before authpriv options + 1 for host and numoids. Add one for terminating NULL */ | 302 | /* 10 arguments to pass before context and authpriv options + 1 for host and numoids. Add one for terminating NULL */ |
| 300 | command_line = calloc (10 + numauthpriv + 1 + numoids + 1, sizeof (char *)); | 303 | command_line = calloc (10 + numcontext + numauthpriv + 1 + numoids + 1, sizeof (char *)); |
| 301 | command_line[0] = snmpcmd; | 304 | command_line[0] = snmpcmd; |
| 302 | command_line[1] = strdup ("-Le"); | 305 | command_line[1] = strdup ("-Le"); |
| 303 | command_line[2] = strdup ("-t"); | 306 | command_line[2] = strdup ("-t"); |
| @@ -309,23 +312,27 @@ main (int argc, char **argv) | |||
| 309 | command_line[8] = "-v"; | 312 | command_line[8] = "-v"; |
| 310 | command_line[9] = strdup (proto); | 313 | command_line[9] = strdup (proto); |
| 311 | 314 | ||
| 315 | for (i = 0; i < numcontext; i++) { | ||
| 316 | command_line[10 + i] = contextargs[i]; | ||
| 317 | } | ||
| 318 | |||
| 312 | for (i = 0; i < numauthpriv; i++) { | 319 | for (i = 0; i < numauthpriv; i++) { |
| 313 | command_line[10 + i] = authpriv[i]; | 320 | command_line[10 + numcontext + i] = authpriv[i]; |
| 314 | } | 321 | } |
| 315 | 322 | ||
| 316 | xasprintf (&command_line[10 + numauthpriv], "%s:%s", server_address, port); | 323 | xasprintf (&command_line[10 + numcontext + numauthpriv], "%s:%s", server_address, port); |
| 317 | 324 | ||
| 318 | /* This is just for display purposes, so it can remain a string */ | 325 | /* This is just for display purposes, so it can remain a string */ |
| 319 | xasprintf(&cl_hidden_auth, "%s -Le -t %d -r %d -m %s -v %s %s %s:%s", | 326 | xasprintf(&cl_hidden_auth, "%s -Le -t %d -r %d -m %s -v %s %s %s %s:%s", |
| 320 | snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", proto, "[authpriv]", | 327 | snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", proto, "[context]", "[authpriv]", |
| 321 | server_address, port); | 328 | server_address, port); |
| 322 | 329 | ||
| 323 | for (i = 0; i < numoids; i++) { | 330 | for (i = 0; i < numoids; i++) { |
| 324 | command_line[10 + numauthpriv + 1 + i] = oids[i]; | 331 | command_line[10 + numcontext + numauthpriv + 1 + i] = oids[i]; |
| 325 | xasprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]); | 332 | xasprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]); |
| 326 | } | 333 | } |
| 327 | 334 | ||
| 328 | command_line[10 + numauthpriv + 1 + numoids] = NULL; | 335 | command_line[10 + numcontext + numauthpriv + 1 + numoids] = NULL; |
| 329 | 336 | ||
| 330 | if (verbose) | 337 | if (verbose) |
| 331 | printf ("%s\n", cl_hidden_auth); | 338 | printf ("%s\n", cl_hidden_auth); |
| @@ -410,6 +417,9 @@ main (int argc, char **argv) | |||
| 410 | else if (strstr (response, "INTEGER: ")) { | 417 | else if (strstr (response, "INTEGER: ")) { |
| 411 | show = strstr (response, "INTEGER: ") + 9; | 418 | show = strstr (response, "INTEGER: ") + 9; |
| 412 | } | 419 | } |
| 420 | else if (strstr (response, "OID: ")) { | ||
| 421 | show = strstr (response, "OID: ") + 5; | ||
| 422 | } | ||
| 413 | else if (strstr (response, "STRING: ")) { | 423 | else if (strstr (response, "STRING: ")) { |
| 414 | show = strstr (response, "STRING: ") + 8; | 424 | show = strstr (response, "STRING: ") + 8; |
| 415 | conv = "%.10g"; | 425 | conv = "%.10g"; |
| @@ -566,6 +576,18 @@ main (int argc, char **argv) | |||
| 566 | len = sizeof(perfstr)-strlen(perfstr)-1; | 576 | len = sizeof(perfstr)-strlen(perfstr)-1; |
| 567 | strncat(perfstr, show, len>ptr-show ? ptr-show : len); | 577 | strncat(perfstr, show, len>ptr-show ? ptr-show : len); |
| 568 | 578 | ||
| 579 | if (warning_thresholds) { | ||
| 580 | strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1); | ||
| 581 | strncat(perfstr, warning_thresholds, sizeof(perfstr)-strlen(perfstr)-1); | ||
| 582 | } | ||
| 583 | |||
| 584 | if (critical_thresholds) { | ||
| 585 | if (!warning_thresholds) | ||
| 586 | strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1); | ||
| 587 | strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1); | ||
| 588 | strncat(perfstr, critical_thresholds, sizeof(perfstr)-strlen(perfstr)-1); | ||
| 589 | } | ||
| 590 | |||
| 569 | if (type) | 591 | if (type) |
| 570 | strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1); | 592 | strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1); |
| 571 | strncat(perfstr, " ", sizeof(perfstr)-strlen(perfstr)-1); | 593 | strncat(perfstr, " ", sizeof(perfstr)-strlen(perfstr)-1); |
| @@ -645,6 +667,7 @@ process_arguments (int argc, char **argv) | |||
| 645 | {"retries", required_argument, 0, 'e'}, | 667 | {"retries", required_argument, 0, 'e'}, |
| 646 | {"miblist", required_argument, 0, 'm'}, | 668 | {"miblist", required_argument, 0, 'm'}, |
| 647 | {"protocol", required_argument, 0, 'P'}, | 669 | {"protocol", required_argument, 0, 'P'}, |
| 670 | {"context", required_argument, 0, 'N'}, | ||
| 648 | {"seclevel", required_argument, 0, 'L'}, | 671 | {"seclevel", required_argument, 0, 'L'}, |
| 649 | {"secname", required_argument, 0, 'U'}, | 672 | {"secname", required_argument, 0, 'U'}, |
| 650 | {"authproto", required_argument, 0, 'a'}, | 673 | {"authproto", required_argument, 0, 'a'}, |
| @@ -674,7 +697,7 @@ process_arguments (int argc, char **argv) | |||
| 674 | } | 697 | } |
| 675 | 698 | ||
| 676 | while (1) { | 699 | while (1) { |
| 677 | c = getopt_long (argc, argv, "nhvVOt:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:L:U:a:x:A:X:", | 700 | c = getopt_long (argc, argv, "nhvVOt:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:N:L:U:a:x:A:X:", |
| 678 | longopts, &option); | 701 | longopts, &option); |
| 679 | 702 | ||
| 680 | if (c == -1 || c == EOF) | 703 | if (c == -1 || c == EOF) |
| @@ -685,10 +708,10 @@ process_arguments (int argc, char **argv) | |||
| 685 | usage5 (); | 708 | usage5 (); |
| 686 | case 'h': /* help */ | 709 | case 'h': /* help */ |
| 687 | print_help (); | 710 | print_help (); |
| 688 | exit (STATE_OK); | 711 | exit (STATE_UNKNOWN); |
| 689 | case 'V': /* version */ | 712 | case 'V': /* version */ |
| 690 | print_revision (progname, NP_VERSION); | 713 | print_revision (progname, NP_VERSION); |
| 691 | exit (STATE_OK); | 714 | exit (STATE_UNKNOWN); |
| 692 | case 'v': /* verbose */ | 715 | case 'v': /* verbose */ |
| 693 | verbose++; | 716 | verbose++; |
| 694 | break; | 717 | break; |
| @@ -712,6 +735,9 @@ process_arguments (int argc, char **argv) | |||
| 712 | case 'P': /* SNMP protocol version */ | 735 | case 'P': /* SNMP protocol version */ |
| 713 | proto = optarg; | 736 | proto = optarg; |
| 714 | break; | 737 | break; |
| 738 | case 'N': /* SNMPv3 context */ | ||
| 739 | context = optarg; | ||
| 740 | break; | ||
| 715 | case 'L': /* security level */ | 741 | case 'L': /* security level */ |
| 716 | seclevel = optarg; | 742 | seclevel = optarg; |
| 717 | break; | 743 | break; |
| @@ -959,6 +985,13 @@ validate_arguments () | |||
| 959 | authpriv[1] = strdup (community); | 985 | authpriv[1] = strdup (community); |
| 960 | } | 986 | } |
| 961 | else if ( strcmp (proto, "3") == 0 ) { /* snmpv3 args */ | 987 | else if ( strcmp (proto, "3") == 0 ) { /* snmpv3 args */ |
| 988 | if (!(context == NULL)) { | ||
| 989 | numcontext = 2; | ||
| 990 | contextargs = calloc (numcontext, sizeof (char *)); | ||
| 991 | contextargs[0] = strdup ("-n"); | ||
| 992 | contextargs[1] = strdup (context); | ||
| 993 | } | ||
| 994 | |||
| 962 | if (seclevel == NULL) | 995 | if (seclevel == NULL) |
| 963 | xasprintf(&seclevel, "noAuthNoPriv"); | 996 | xasprintf(&seclevel, "noAuthNoPriv"); |
| 964 | 997 | ||
| @@ -1102,6 +1135,8 @@ print_help (void) | |||
| 1102 | printf (" %s\n", _("Use SNMP GETNEXT instead of SNMP GET")); | 1135 | printf (" %s\n", _("Use SNMP GETNEXT instead of SNMP GET")); |
| 1103 | printf (" %s\n", "-P, --protocol=[1|2c|3]"); | 1136 | printf (" %s\n", "-P, --protocol=[1|2c|3]"); |
| 1104 | printf (" %s\n", _("SNMP protocol version")); | 1137 | printf (" %s\n", _("SNMP protocol version")); |
| 1138 | printf (" %s\n", "-N, --context=CONTEXT"); | ||
| 1139 | printf (" %s\n", _("SNMPv3 context")); | ||
| 1105 | printf (" %s\n", "-L, --seclevel=[noAuthNoPriv|authNoPriv|authPriv]"); | 1140 | printf (" %s\n", "-L, --seclevel=[noAuthNoPriv|authNoPriv|authPriv]"); |
| 1106 | printf (" %s\n", _("SNMPv3 securityLevel")); | 1141 | printf (" %s\n", _("SNMPv3 securityLevel")); |
| 1107 | printf (" %s\n", "-a, --authproto=[MD5|SHA]"); | 1142 | printf (" %s\n", "-a, --authproto=[MD5|SHA]"); |
| @@ -1209,6 +1244,6 @@ print_usage (void) | |||
| 1209 | printf ("%s -H <ip_address> -o <OID> [-w warn_range] [-c crit_range]\n",progname); | 1244 | printf ("%s -H <ip_address> -o <OID> [-w warn_range] [-c crit_range]\n",progname); |
| 1210 | printf ("[-C community] [-s string] [-r regex] [-R regexi] [-t timeout] [-e retries]\n"); | 1245 | printf ("[-C community] [-s string] [-r regex] [-R regexi] [-t timeout] [-e retries]\n"); |
| 1211 | printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n"); | 1246 | printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n"); |
| 1212 | printf ("[-m miblist] [-P snmp version] [-L seclevel] [-U secname] [-a authproto]\n"); | 1247 | printf ("[-m miblist] [-P snmp version] [-N context] [-L seclevel] [-U secname]\n"); |
| 1213 | printf ("[-A authpasswd] [-x privproto] [-X privpasswd]\n"); | 1248 | printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd]\n"); |
| 1214 | } | 1249 | } |
diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c index b6187d61..8ccbd5a7 100644 --- a/plugins/check_ssh.c +++ b/plugins/check_ssh.c | |||
| @@ -128,10 +128,10 @@ process_arguments (int argc, char **argv) | |||
| 128 | usage5 (); | 128 | usage5 (); |
| 129 | case 'V': /* version */ | 129 | case 'V': /* version */ |
| 130 | print_revision (progname, NP_VERSION); | 130 | print_revision (progname, NP_VERSION); |
| 131 | exit (STATE_OK); | 131 | exit (STATE_UNKNOWN); |
| 132 | case 'h': /* help */ | 132 | case 'h': /* help */ |
| 133 | print_help (); | 133 | print_help (); |
| 134 | exit (STATE_OK); | 134 | exit (STATE_UNKNOWN); |
| 135 | case 'v': /* verbose */ | 135 | case 'v': /* verbose */ |
| 136 | verbose = TRUE; | 136 | verbose = TRUE; |
| 137 | break; | 137 | break; |
| @@ -253,18 +253,18 @@ ssh_connect (char *haddr, int hport, char *remote_version, char *remote_protocol | |||
| 253 | 253 | ||
| 254 | if (remote_version && strcmp(remote_version, ssh_server)) { | 254 | if (remote_version && strcmp(remote_version, ssh_server)) { |
| 255 | printf | 255 | printf |
| 256 | (_("SSH WARNING - %s (protocol %s) version mismatch, expected '%s'\n"), | 256 | (_("SSH CRITICAL - %s (protocol %s) version mismatch, expected '%s'\n"), |
| 257 | ssh_server, ssh_proto, remote_version); | 257 | ssh_server, ssh_proto, remote_version); |
| 258 | close(sd); | 258 | close(sd); |
| 259 | exit (STATE_WARNING); | 259 | exit (STATE_CRITICAL); |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | if (remote_protocol && strcmp(remote_protocol, ssh_proto)) { | 262 | if (remote_protocol && strcmp(remote_protocol, ssh_proto)) { |
| 263 | printf | 263 | printf |
| 264 | (_("SSH WARNING - %s (protocol %s) protocol version mismatch, expected '%s'\n"), | 264 | (_("SSH CRITICAL - %s (protocol %s) protocol version mismatch, expected '%s'\n"), |
| 265 | ssh_server, ssh_proto, remote_protocol); | 265 | ssh_server, ssh_proto, remote_protocol); |
| 266 | close(sd); | 266 | close(sd); |
| 267 | exit (STATE_WARNING); | 267 | exit (STATE_CRITICAL); |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | elapsed_time = (double)deltime(tv) / 1.0e6; | 270 | elapsed_time = (double)deltime(tv) / 1.0e6; |
| @@ -307,10 +307,10 @@ print_help (void) | |||
| 307 | printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); | 307 | printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); |
| 308 | 308 | ||
| 309 | printf (" %s\n", "-r, --remote-version=STRING"); | 309 | printf (" %s\n", "-r, --remote-version=STRING"); |
| 310 | printf (" %s\n", _("Warn if string doesn't match expected server version (ex: OpenSSH_3.9p1)")); | 310 | printf (" %s\n", _("Alert if string doesn't match expected server version (ex: OpenSSH_3.9p1)")); |
| 311 | 311 | ||
| 312 | printf (" %s\n", "-P, --remote-protocol=STRING"); | 312 | printf (" %s\n", "-P, --remote-protocol=STRING"); |
| 313 | printf (" %s\n", _("Warn if protocol doesn't match expected protocol version (ex: 2.0)")); | 313 | printf (" %s\n", _("Alert if protocol doesn't match expected protocol version (ex: 2.0)")); |
| 314 | 314 | ||
| 315 | printf (UT_VERBOSE); | 315 | printf (UT_VERBOSE); |
| 316 | 316 | ||
diff --git a/plugins/check_swap.c b/plugins/check_swap.c index 88a2a2ad..4d5a4071 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /***************************************************************************** | 1 | /***************************************************************************** |
| 2 | * | 2 | * |
| 3 | * Monitoring check_disk plugin | 3 | * Monitoring check_swap plugin |
| 4 | * | 4 | * |
| 5 | * License: GPL | 5 | * License: GPL |
| 6 | * Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net) | 6 | * Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net) |
| @@ -352,6 +352,7 @@ main (int argc, char **argv) | |||
| 352 | percent_used = 100 * ((double) used_swap_mb) / ((double) total_swap_mb); | 352 | percent_used = 100 * ((double) used_swap_mb) / ((double) total_swap_mb); |
| 353 | } else { | 353 | } else { |
| 354 | percent_used = 100; | 354 | percent_used = 100; |
| 355 | status = "- Swap is either disabled, not present, or of zero size. "; | ||
| 355 | } | 356 | } |
| 356 | 357 | ||
| 357 | result = max_state (result, check_swap (percent_used, free_swap_mb)); | 358 | result = max_state (result, check_swap (percent_used, free_swap_mb)); |
| @@ -469,10 +470,10 @@ process_arguments (int argc, char **argv) | |||
| 469 | break; | 470 | break; |
| 470 | case 'V': /* version */ | 471 | case 'V': /* version */ |
| 471 | print_revision (progname, NP_VERSION); | 472 | print_revision (progname, NP_VERSION); |
| 472 | exit (STATE_OK); | 473 | exit (STATE_UNKNOWN); |
| 473 | case 'h': /* help */ | 474 | case 'h': /* help */ |
| 474 | print_help (); | 475 | print_help (); |
| 475 | exit (STATE_OK); | 476 | exit (STATE_UNKNOWN); |
| 476 | case '?': /* error */ | 477 | case '?': /* error */ |
| 477 | usage5 (); | 478 | usage5 (); |
| 478 | } | 479 | } |
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c index 63f9fd9c..6dc9aa96 100644 --- a/plugins/check_tcp.c +++ b/plugins/check_tcp.c | |||
| @@ -237,7 +237,7 @@ main (int argc, char **argv) | |||
| 237 | gettimeofday (&tv, NULL); | 237 | gettimeofday (&tv, NULL); |
| 238 | 238 | ||
| 239 | result = np_net_connect (server_address, server_port, &sd, PROTOCOL); | 239 | result = np_net_connect (server_address, server_port, &sd, PROTOCOL); |
| 240 | if (result == STATE_CRITICAL) return STATE_CRITICAL; | 240 | if (result == STATE_CRITICAL) return econn_refuse_state; |
| 241 | 241 | ||
| 242 | #ifdef HAVE_SSL | 242 | #ifdef HAVE_SSL |
| 243 | if (flags & FLAG_SSL){ | 243 | if (flags & FLAG_SSL){ |
| @@ -463,10 +463,10 @@ process_arguments (int argc, char **argv) | |||
| 463 | usage5 (); | 463 | usage5 (); |
| 464 | case 'h': /* help */ | 464 | case 'h': /* help */ |
| 465 | print_help (); | 465 | print_help (); |
| 466 | exit (STATE_OK); | 466 | exit (STATE_UNKNOWN); |
| 467 | case 'V': /* version */ | 467 | case 'V': /* version */ |
| 468 | print_revision (progname, NP_VERSION); | 468 | print_revision (progname, NP_VERSION); |
| 469 | exit (STATE_OK); | 469 | exit (STATE_UNKNOWN); |
| 470 | case 'v': /* verbose mode */ | 470 | case 'v': /* verbose mode */ |
| 471 | flags |= FLAG_VERBOSE; | 471 | flags |= FLAG_VERBOSE; |
| 472 | match_flags |= NP_MATCH_VERBOSE; | 472 | match_flags |= NP_MATCH_VERBOSE; |
| @@ -577,7 +577,8 @@ process_arguments (int argc, char **argv) | |||
| 577 | if ((temp=strchr(optarg,','))!=NULL) { | 577 | if ((temp=strchr(optarg,','))!=NULL) { |
| 578 | *temp='\0'; | 578 | *temp='\0'; |
| 579 | if (!is_intnonneg (optarg)) | 579 | if (!is_intnonneg (optarg)) |
| 580 | usage2 (_("Invalid certificate expiration period"), optarg); days_till_exp_warn = atoi(optarg); | 580 | usage2 (_("Invalid certificate expiration period"), optarg); |
| 581 | days_till_exp_warn = atoi (optarg); | ||
| 581 | *temp=','; | 582 | *temp=','; |
| 582 | temp++; | 583 | temp++; |
| 583 | if (!is_intnonneg (temp)) | 584 | if (!is_intnonneg (temp)) |
diff --git a/plugins/check_time.c b/plugins/check_time.c index 3943742a..baf8c591 100644 --- a/plugins/check_time.c +++ b/plugins/check_time.c | |||
| @@ -231,10 +231,10 @@ process_arguments (int argc, char **argv) | |||
| 231 | usage5 (); | 231 | usage5 (); |
| 232 | case 'h': /* help */ | 232 | case 'h': /* help */ |
| 233 | print_help (); | 233 | print_help (); |
| 234 | exit (STATE_OK); | 234 | exit (STATE_UNKNOWN); |
| 235 | case 'V': /* version */ | 235 | case 'V': /* version */ |
| 236 | print_revision (progname, NP_VERSION); | 236 | print_revision (progname, NP_VERSION); |
| 237 | exit (STATE_OK); | 237 | exit (STATE_UNKNOWN); |
| 238 | case 'H': /* hostname */ | 238 | case 'H': /* hostname */ |
| 239 | if (is_host (optarg) == FALSE) | 239 | if (is_host (optarg) == FALSE) |
| 240 | usage2 (_("Invalid hostname/address"), optarg); | 240 | usage2 (_("Invalid hostname/address"), optarg); |
diff --git a/plugins/check_ups.c b/plugins/check_ups.c index fd8c2d13..e9e56a51 100644 --- a/plugins/check_ups.c +++ b/plugins/check_ups.c | |||
| @@ -558,10 +558,10 @@ process_arguments (int argc, char **argv) | |||
| 558 | break; | 558 | break; |
| 559 | case 'V': /* version */ | 559 | case 'V': /* version */ |
| 560 | print_revision (progname, NP_VERSION); | 560 | print_revision (progname, NP_VERSION); |
| 561 | exit (STATE_OK); | 561 | exit (STATE_UNKNOWN); |
| 562 | case 'h': /* help */ | 562 | case 'h': /* help */ |
| 563 | print_help (); | 563 | print_help (); |
| 564 | exit (STATE_OK); | 564 | exit (STATE_UNKNOWN); |
| 565 | } | 565 | } |
| 566 | } | 566 | } |
| 567 | 567 | ||
diff --git a/plugins/check_users.c b/plugins/check_users.c index a009f20b..54415a48 100644 --- a/plugins/check_users.c +++ b/plugins/check_users.c | |||
| @@ -210,10 +210,10 @@ process_arguments (int argc, char **argv) | |||
| 210 | usage5 (); | 210 | usage5 (); |
| 211 | case 'h': /* help */ | 211 | case 'h': /* help */ |
| 212 | print_help (); | 212 | print_help (); |
| 213 | exit (STATE_OK); | 213 | exit (STATE_UNKNOWN); |
| 214 | case 'V': /* version */ | 214 | case 'V': /* version */ |
| 215 | print_revision (progname, NP_VERSION); | 215 | print_revision (progname, NP_VERSION); |
| 216 | exit (STATE_OK); | 216 | exit (STATE_UNKNOWN); |
| 217 | case 'c': /* critical */ | 217 | case 'c': /* critical */ |
| 218 | if (!is_intnonneg (optarg)) | 218 | if (!is_intnonneg (optarg)) |
| 219 | usage4 (_("Critical threshold must be a positive integer")); | 219 | usage4 (_("Critical threshold must be a positive integer")); |
diff --git a/plugins/netutils.c b/plugins/netutils.c index 83f8942f..705aaf09 100644 --- a/plugins/netutils.c +++ b/plugins/netutils.c | |||
| @@ -161,6 +161,10 @@ process_request (const char *server_address, int server_port, int proto, | |||
| 161 | int | 161 | int |
| 162 | np_net_connect (const char *host_name, int port, int *sd, int proto) | 162 | np_net_connect (const char *host_name, int port, int *sd, int proto) |
| 163 | { | 163 | { |
| 164 | /* send back STATE_UNKOWN if there's an error | ||
| 165 | send back STATE_OK if we connect | ||
| 166 | send back STATE_CRITICAL if we can't connect. | ||
| 167 | Let upstream figure out what to send to the user. */ | ||
| 164 | struct addrinfo hints; | 168 | struct addrinfo hints; |
| 165 | struct addrinfo *r, *res; | 169 | struct addrinfo *r, *res; |
| 166 | struct sockaddr_un su; | 170 | struct sockaddr_un su; |
| @@ -250,16 +254,14 @@ np_net_connect (const char *host_name, int port, int *sd, int proto) | |||
| 250 | else if (was_refused) { | 254 | else if (was_refused) { |
| 251 | switch (econn_refuse_state) { /* a user-defined expected outcome */ | 255 | switch (econn_refuse_state) { /* a user-defined expected outcome */ |
| 252 | case STATE_OK: | 256 | case STATE_OK: |
| 253 | case STATE_WARNING: /* user wants WARN or OK on refusal */ | 257 | case STATE_WARNING: /* user wants WARN or OK on refusal, or... */ |
| 254 | return econn_refuse_state; | 258 | case STATE_CRITICAL: /* user did not set econn_refuse_state, or wanted critical */ |
| 255 | break; | ||
| 256 | case STATE_CRITICAL: /* user did not set econn_refuse_state */ | ||
| 257 | if (is_socket) | 259 | if (is_socket) |
| 258 | printf("connect to file socket %s: %s\n", host_name, strerror(errno)); | 260 | printf("connect to file socket %s: %s\n", host_name, strerror(errno)); |
| 259 | else | 261 | else |
| 260 | printf("connect to address %s and port %d: %s\n", | 262 | printf("connect to address %s and port %d: %s\n", |
| 261 | host_name, port, strerror(errno)); | 263 | host_name, port, strerror(errno)); |
| 262 | return econn_refuse_state; | 264 | return STATE_CRITICAL; |
| 263 | break; | 265 | break; |
| 264 | default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */ | 266 | default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */ |
| 265 | return STATE_UNKNOWN; | 267 | return STATE_UNKNOWN; |
diff --git a/plugins/netutils.h b/plugins/netutils.h index c6fce901..2766029e 100644 --- a/plugins/netutils.h +++ b/plugins/netutils.h | |||
| @@ -91,6 +91,16 @@ RETSIGTYPE socket_timeout_alarm_handler (int) __attribute__((noreturn)); | |||
| 91 | 91 | ||
| 92 | /* SSL-Related functionality */ | 92 | /* SSL-Related functionality */ |
| 93 | #ifdef HAVE_SSL | 93 | #ifdef HAVE_SSL |
| 94 | # define MP_SSLv2 1 | ||
| 95 | # define MP_SSLv3 2 | ||
| 96 | # define MP_TLSv1 3 | ||
| 97 | # define MP_TLSv1_1 4 | ||
| 98 | # define MP_TLSv1_2 5 | ||
| 99 | # define MP_SSLv2_OR_NEWER 6 | ||
| 100 | # define MP_SSLv3_OR_NEWER 7 | ||
| 101 | # define MP_TLSv1_OR_NEWER 8 | ||
| 102 | # define MP_TLSv1_1_OR_NEWER 9 | ||
| 103 | # define MP_TLSv1_2_OR_NEWER 10 | ||
| 94 | /* maybe this could be merged with the above np_net_connect, via some flags */ | 104 | /* maybe this could be merged with the above np_net_connect, via some flags */ |
| 95 | int np_net_ssl_init(int sd); | 105 | int np_net_ssl_init(int sd); |
| 96 | int np_net_ssl_init_with_hostname(int sd, char *host_name); | 106 | int np_net_ssl_init_with_hostname(int sd, char *host_name); |
diff --git a/plugins/sslutils.c b/plugins/sslutils.c index f34c3d79..4f9c793c 100644 --- a/plugins/sslutils.c +++ b/plugins/sslutils.c | |||
| @@ -49,33 +49,78 @@ int np_net_ssl_init_with_hostname_and_version(int sd, char *host_name, int versi | |||
| 49 | 49 | ||
| 50 | int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int version, char *cert, char *privkey) { | 50 | int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int version, char *cert, char *privkey) { |
| 51 | SSL_METHOD *method = NULL; | 51 | SSL_METHOD *method = NULL; |
| 52 | long options = 0; | ||
| 52 | 53 | ||
| 53 | switch (version) { | 54 | switch (version) { |
| 54 | case 0: /* Deafult to auto negotiation */ | 55 | case MP_SSLv2: /* SSLv2 protocol */ |
| 55 | method = SSLv23_client_method(); | ||
| 56 | break; | ||
| 57 | case 1: /* TLSv1 protocol */ | ||
| 58 | method = TLSv1_client_method(); | ||
| 59 | break; | ||
| 60 | case 2: /* SSLv2 protocol */ | ||
| 61 | #if defined(USE_GNUTLS) || defined(OPENSSL_NO_SSL2) | 56 | #if defined(USE_GNUTLS) || defined(OPENSSL_NO_SSL2) |
| 62 | printf("%s\n", _("CRITICAL - SSL protocol version 2 is not supported by your SSL library.")); | 57 | printf("%s\n", _("UNKNOWN - SSL protocol version 2 is not supported by your SSL library.")); |
| 63 | return STATE_CRITICAL; | 58 | return STATE_UNKNOWN; |
| 64 | #else | 59 | #else |
| 65 | method = SSLv2_client_method(); | 60 | method = SSLv2_client_method(); |
| 66 | #endif | ||
| 67 | break; | 61 | break; |
| 68 | case 3: /* SSLv3 protocol */ | 62 | #endif |
| 63 | case MP_SSLv3: /* SSLv3 protocol */ | ||
| 69 | #if defined(OPENSSL_NO_SSL3) | 64 | #if defined(OPENSSL_NO_SSL3) |
| 70 | printf("%s\n", _("CRITICAL - SSL protocol version 3 is not supported by your SSL library.")); | 65 | printf("%s\n", _("UNKNOWN - SSL protocol version 3 is not supported by your SSL library.")); |
| 71 | return STATE_CRITICAL; | 66 | return STATE_UNKNOWN; |
| 72 | #else | 67 | #else |
| 73 | method = SSLv3_client_method(); | 68 | method = SSLv3_client_method(); |
| 69 | break; | ||
| 74 | #endif | 70 | #endif |
| 71 | case MP_TLSv1: /* TLSv1 protocol */ | ||
| 72 | #if defined(OPENSSL_NO_TLS1) | ||
| 73 | printf("%s\n", _("UNKNOWN - TLS protocol version 1 is not supported by your SSL library.")); | ||
| 74 | return STATE_UNKNOWN; | ||
| 75 | #else | ||
| 76 | method = TLSv1_client_method(); | ||
| 75 | break; | 77 | break; |
| 76 | default: /* Unsupported */ | 78 | #endif |
| 77 | printf("%s\n", _("CRITICAL - Unsupported SSL protocol version.")); | 79 | case MP_TLSv1_1: /* TLSv1.1 protocol */ |
| 78 | return STATE_CRITICAL; | 80 | #if !defined(SSL_OP_NO_TLSv1_1) |
| 81 | printf("%s\n", _("UNKNOWN - TLS protocol version 1.1 is not supported by your SSL library.")); | ||
| 82 | return STATE_UNKNOWN; | ||
| 83 | #else | ||
| 84 | method = TLSv1_1_client_method(); | ||
| 85 | break; | ||
| 86 | #endif | ||
| 87 | case MP_TLSv1_2: /* TLSv1.2 protocol */ | ||
| 88 | #if !defined(SSL_OP_NO_TLSv1_2) | ||
| 89 | printf("%s\n", _("UNKNOWN - TLS protocol version 1.2 is not supported by your SSL library.")); | ||
| 90 | return STATE_UNKNOWN; | ||
| 91 | #else | ||
| 92 | method = TLSv1_2_client_method(); | ||
| 93 | break; | ||
| 94 | #endif | ||
| 95 | case MP_TLSv1_2_OR_NEWER: | ||
| 96 | #if !defined(SSL_OP_NO_TLSv1_1) | ||
| 97 | printf("%s\n", _("UNKNOWN - Disabling TLSv1.1 is not supported by your SSL library.")); | ||
| 98 | return STATE_UNKNOWN; | ||
| 99 | #else | ||
| 100 | options |= SSL_OP_NO_TLSv1_1; | ||
| 101 | #endif | ||
| 102 | /* FALLTHROUGH */ | ||
| 103 | case MP_TLSv1_1_OR_NEWER: | ||
| 104 | #if !defined(SSL_OP_NO_TLSv1) | ||
| 105 | printf("%s\n", _("UNKNOWN - Disabling TLSv1 is not supported by your SSL library.")); | ||
| 106 | return STATE_UNKNOWN; | ||
| 107 | #else | ||
| 108 | options |= SSL_OP_NO_TLSv1; | ||
| 109 | #endif | ||
| 110 | /* FALLTHROUGH */ | ||
| 111 | case MP_TLSv1_OR_NEWER: | ||
| 112 | #if defined(SSL_OP_NO_SSLv3) | ||
| 113 | options |= SSL_OP_NO_SSLv3; | ||
| 114 | #endif | ||
| 115 | /* FALLTHROUGH */ | ||
| 116 | case MP_SSLv3_OR_NEWER: | ||
| 117 | #if defined(SSL_OP_NO_SSLv2) | ||
| 118 | options |= SSL_OP_NO_SSLv2; | ||
| 119 | #endif | ||
| 120 | case MP_SSLv2_OR_NEWER: | ||
| 121 | /* FALLTHROUGH */ | ||
| 122 | default: /* Default to auto negotiation */ | ||
| 123 | method = SSLv23_client_method(); | ||
| 79 | } | 124 | } |
| 80 | if (!initialized) { | 125 | if (!initialized) { |
| 81 | /* Initialize SSL context */ | 126 | /* Initialize SSL context */ |
| @@ -99,8 +144,9 @@ int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int | |||
| 99 | #endif | 144 | #endif |
| 100 | } | 145 | } |
| 101 | #ifdef SSL_OP_NO_TICKET | 146 | #ifdef SSL_OP_NO_TICKET |
| 102 | SSL_CTX_set_options(c, SSL_OP_NO_TICKET); | 147 | options |= SSL_OP_NO_TICKET; |
| 103 | #endif | 148 | #endif |
| 149 | SSL_CTX_set_options(c, options); | ||
| 104 | SSL_CTX_set_mode(c, SSL_MODE_AUTO_RETRY); | 150 | SSL_CTX_set_mode(c, SSL_MODE_AUTO_RETRY); |
| 105 | if ((s = SSL_new(c)) != NULL) { | 151 | if ((s = SSL_new(c)) != NULL) { |
| 106 | #ifdef SSL_set_tlsext_host_name | 152 | #ifdef SSL_set_tlsext_host_name |
| @@ -149,7 +195,9 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){ | |||
| 149 | # ifdef USE_OPENSSL | 195 | # ifdef USE_OPENSSL |
| 150 | X509 *certificate=NULL; | 196 | X509 *certificate=NULL; |
| 151 | X509_NAME *subj=NULL; | 197 | X509_NAME *subj=NULL; |
| 198 | char timestamp[50] = ""; | ||
| 152 | char cn[MAX_CN_LENGTH]= ""; | 199 | char cn[MAX_CN_LENGTH]= ""; |
| 200 | |||
| 153 | int cnlen =-1; | 201 | int cnlen =-1; |
| 154 | int status=STATE_UNKNOWN; | 202 | int status=STATE_UNKNOWN; |
| 155 | 203 | ||
| @@ -158,7 +206,7 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){ | |||
| 158 | struct tm stamp; | 206 | struct tm stamp; |
| 159 | float time_left; | 207 | float time_left; |
| 160 | int days_left; | 208 | int days_left; |
| 161 | char timestamp[50] = ""; | 209 | int time_remaining; |
| 162 | time_t tm_t; | 210 | time_t tm_t; |
| 163 | 211 | ||
| 164 | certificate=SSL_get_peer_certificate(s); | 212 | certificate=SSL_get_peer_certificate(s); |
| @@ -212,7 +260,8 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){ | |||
| 212 | (tm->data[6 + offset] - '0') * 10 + (tm->data[7 + offset] - '0'); | 260 | (tm->data[6 + offset] - '0') * 10 + (tm->data[7 + offset] - '0'); |
| 213 | stamp.tm_min = | 261 | stamp.tm_min = |
| 214 | (tm->data[8 + offset] - '0') * 10 + (tm->data[9 + offset] - '0'); | 262 | (tm->data[8 + offset] - '0') * 10 + (tm->data[9 + offset] - '0'); |
| 215 | stamp.tm_sec = 0; | 263 | stamp.tm_sec = |
| 264 | (tm->data[10 + offset] - '0') * 10 + (tm->data[11 + offset] - '0'); | ||
| 216 | stamp.tm_isdst = -1; | 265 | stamp.tm_isdst = -1; |
| 217 | 266 | ||
| 218 | time_left = difftime(timegm(&stamp), time(NULL)); | 267 | time_left = difftime(timegm(&stamp), time(NULL)); |
| @@ -223,21 +272,35 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){ | |||
| 223 | if (days_left > 0 && days_left <= days_till_exp_warn) { | 272 | if (days_left > 0 && days_left <= days_till_exp_warn) { |
| 224 | printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, days_left, timestamp); | 273 | printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, days_left, timestamp); |
| 225 | if (days_left > days_till_exp_crit) | 274 | if (days_left > days_till_exp_crit) |
| 226 | return STATE_WARNING; | 275 | status = STATE_WARNING; |
| 227 | else | 276 | else |
| 228 | return STATE_CRITICAL; | 277 | status = STATE_CRITICAL; |
| 278 | } else if (days_left == 0 && time_left > 0) { | ||
| 279 | if (time_left >= 3600) | ||
| 280 | time_remaining = (int) time_left / 3600; | ||
| 281 | else | ||
| 282 | time_remaining = (int) time_left / 60; | ||
| 283 | |||
| 284 | printf (_("%s - Certificate '%s' expires in %u %s (%s)\n"), | ||
| 285 | (days_left>days_till_exp_crit) ? "WARNING" : "CRITICAL", cn, time_remaining, | ||
| 286 | time_left >= 3600 ? "hours" : "minutes", timestamp); | ||
| 287 | |||
| 288 | if ( days_left > days_till_exp_crit) | ||
| 289 | status = STATE_WARNING; | ||
| 290 | else | ||
| 291 | status = STATE_CRITICAL; | ||
| 229 | } else if (time_left < 0) { | 292 | } else if (time_left < 0) { |
| 230 | printf(_("CRITICAL - Certificate '%s' expired on %s.\n"), cn, timestamp); | 293 | printf(_("CRITICAL - Certificate '%s' expired on %s.\n"), cn, timestamp); |
| 231 | status=STATE_CRITICAL; | 294 | status=STATE_CRITICAL; |
| 232 | } else if (days_left == 0) { | 295 | } else if (days_left == 0) { |
| 233 | printf (_("%s - Certificate '%s' expires today (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, timestamp); | 296 | printf (_("%s - Certificate '%s' just expired (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, timestamp); |
| 234 | if (days_left > days_till_exp_crit) | 297 | if (days_left > days_till_exp_crit) |
| 235 | return STATE_WARNING; | 298 | status = STATE_WARNING; |
| 236 | else | 299 | else |
| 237 | return STATE_CRITICAL; | 300 | status = STATE_CRITICAL; |
| 238 | } else { | 301 | } else { |
| 239 | printf(_("OK - Certificate '%s' will expire on %s.\n"), cn, timestamp); | 302 | printf(_("OK - Certificate '%s' will expire on %s.\n"), cn, timestamp); |
| 240 | status=STATE_OK; | 303 | status = STATE_OK; |
| 241 | } | 304 | } |
| 242 | X509_free(certificate); | 305 | X509_free(certificate); |
| 243 | return status; | 306 | return status; |
diff --git a/plugins/t/NPTest.cache.travis b/plugins/t/NPTest.cache.travis index ce798c21..fe8aabdb 100644 --- a/plugins/t/NPTest.cache.travis +++ b/plugins/t/NPTest.cache.travis | |||
| @@ -19,11 +19,13 @@ | |||
| 19 | 'NP_HOST_TCP_HTTP' => 'localhost', | 19 | 'NP_HOST_TCP_HTTP' => 'localhost', |
| 20 | 'NP_HOST_TCP_HTTP2' => 'test.monitoring-plugins.org', | 20 | 'NP_HOST_TCP_HTTP2' => 'test.monitoring-plugins.org', |
| 21 | 'NP_HOST_TCP_IMAP' => 'imap.web.de', | 21 | 'NP_HOST_TCP_IMAP' => 'imap.web.de', |
| 22 | 'NP_HOST_TCP_LDAP' => 'localhost', | ||
| 22 | 'NP_HOST_TCP_POP' => 'pop.web.de', | 23 | 'NP_HOST_TCP_POP' => 'pop.web.de', |
| 23 | 'NP_HOST_TCP_SMTP' => 'localhost', | 24 | 'NP_HOST_TCP_SMTP' => 'localhost', |
| 24 | 'NP_HOST_TCP_SMTP_NOTLS' => '', | 25 | 'NP_HOST_TCP_SMTP_NOTLS' => '', |
| 25 | 'NP_HOST_TCP_SMTP_TLS' => '', | 26 | 'NP_HOST_TCP_SMTP_TLS' => '', |
| 26 | 'NP_INTERNET_ACCESS' => 'yes', | 27 | 'NP_INTERNET_ACCESS' => 'yes', |
| 28 | 'NP_LDAP_BASE_DN' => 'cn=admin,dc=nodomain', | ||
| 27 | 'NP_MOUNTPOINT2_VALID' => '', | 29 | 'NP_MOUNTPOINT2_VALID' => '', |
| 28 | 'NP_MOUNTPOINT_VALID' => '/', | 30 | 'NP_MOUNTPOINT_VALID' => '/', |
| 29 | 'NP_MYSQL_SERVER' => 'localhost', | 31 | 'NP_MYSQL_SERVER' => 'localhost', |
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t index 2539a289..c2caec60 100644 --- a/plugins/t/check_http.t +++ b/plugins/t/check_http.t | |||
| @@ -6,9 +6,10 @@ | |||
| 6 | 6 | ||
| 7 | use strict; | 7 | use strict; |
| 8 | use Test::More; | 8 | use Test::More; |
| 9 | use POSIX qw/mktime strftime/; | ||
| 9 | use NPTest; | 10 | use NPTest; |
| 10 | 11 | ||
| 11 | plan tests => 30; | 12 | plan tests => 42; |
| 12 | 13 | ||
| 13 | my $successOutput = '/OK.*HTTP.*second/'; | 14 | my $successOutput = '/OK.*HTTP.*second/'; |
| 14 | 15 | ||
| @@ -34,6 +35,8 @@ my $host_tcp_http2 = getTestParameter( "NP_HOST_TCP_HTTP2", | |||
| 34 | "A host providing an index page containing the string 'monitoring'", | 35 | "A host providing an index page containing the string 'monitoring'", |
| 35 | "test.monitoring-plugins.org" ); | 36 | "test.monitoring-plugins.org" ); |
| 36 | 37 | ||
| 38 | my $faketime = -x '/usr/bin/faketime' ? 1 : 0; | ||
| 39 | |||
| 37 | 40 | ||
| 38 | $res = NPTest->testCmd( | 41 | $res = NPTest->testCmd( |
| 39 | "./check_http $host_tcp_http -wt 300 -ct 600" | 42 | "./check_http $host_tcp_http -wt 300 -ct 600" |
| @@ -47,10 +50,10 @@ $res = NPTest->testCmd( | |||
| 47 | like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" ); | 50 | like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" ); |
| 48 | 51 | ||
| 49 | $res = NPTest->testCmd( | 52 | $res = NPTest->testCmd( |
| 50 | "./check_http $host_nonresponsive -wt 1 -ct 2" | 53 | "./check_http $host_nonresponsive -wt 1 -ct 2 -t 3" |
| 51 | ); | 54 | ); |
| 52 | cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" ); | 55 | cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" ); |
| 53 | cmp_ok( $res->output, 'eq', "CRITICAL - Socket timeout after 10 seconds", "Output OK"); | 56 | cmp_ok( $res->output, 'eq', "CRITICAL - Socket timeout after 3 seconds", "Output OK"); |
| 54 | 57 | ||
| 55 | $res = NPTest->testCmd( | 58 | $res = NPTest->testCmd( |
| 56 | "./check_http $hostname_invalid -wt 1 -ct 2" | 59 | "./check_http $hostname_invalid -wt 1 -ct 2" |
| @@ -112,6 +115,40 @@ SKIP: { | |||
| 112 | $res = NPTest->testCmd( "./check_http www.verisign.com -C 1" ); | 115 | $res = NPTest->testCmd( "./check_http www.verisign.com -C 1" ); |
| 113 | cmp_ok( $res->output, 'eq', $saved_cert_output, "Old syntax for cert checking still works"); | 116 | cmp_ok( $res->output, 'eq', $saved_cert_output, "Old syntax for cert checking still works"); |
| 114 | 117 | ||
| 118 | # run some certificate checks with faketime | ||
| 119 | SKIP: { | ||
| 120 | skip "No faketime binary found", 12 if !$faketime; | ||
| 121 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC ./check_http -C 1 www.verisign.com"); | ||
| 122 | like($res->output, qr/OK - Certificate 'www.verisign.com' will expire on/, "Catch cert output"); | ||
| 123 | is( $res->return_code, 0, "Catch cert output exit code" ); | ||
| 124 | my($mon,$day,$hour,$min,$sec,$year) = ($res->output =~ /(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)\./); | ||
| 125 | if(!defined $year) { | ||
| 126 | die("parsing date failed from: ".$res); | ||
| 127 | } | ||
| 128 | my $months = {'Jan' => 0, 'Feb' => 1, 'Mar' => 2, 'Apr' => 3, 'May' => 4, 'Jun' => 5, 'Jul' => 6, 'Aug' => 7, 'Sep' => 8, 'Oct' => 9, 'Nov' => 10, 'Dec' => 11}; | ||
| 129 | my $ts = mktime($sec, $min, $hour, $day, $months->{$mon}, $year-1900); | ||
| 130 | my $time = strftime("%Y-%m-%d %H:%M:%S", localtime($ts)); | ||
| 131 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts))."' ./check_http -C 1 www.verisign.com"); | ||
| 132 | like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' just expired/, "Output on expire date"); | ||
| 133 | is( $res->return_code, 2, "Output on expire date" ); | ||
| 134 | |||
| 135 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-1))."' ./check_http -C 1 www.verisign.com"); | ||
| 136 | like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' expires in 0 minutes/, "cert expires in 1 second output"); | ||
| 137 | is( $res->return_code, 2, "cert expires in 1 second exit code" ); | ||
| 138 | |||
| 139 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-120))."' ./check_http -C 1 www.verisign.com"); | ||
| 140 | like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' expires in 2 minutes/, "cert expires in 2 minutes output"); | ||
| 141 | is( $res->return_code, 2, "cert expires in 2 minutes exit code" ); | ||
| 142 | |||
| 143 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-7200))."' ./check_http -C 1 www.verisign.com"); | ||
| 144 | like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' expires in 2 hours/, "cert expires in 2 hours output"); | ||
| 145 | is( $res->return_code, 2, "cert expires in 2 hours exit code" ); | ||
| 146 | |||
| 147 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./check_http -C 1 www.verisign.com"); | ||
| 148 | like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' expired on/, "Certificate expired output"); | ||
| 149 | is( $res->return_code, 2, "Certificate expired exit code" ); | ||
| 150 | }; | ||
| 151 | |||
| 115 | $res = NPTest->testCmd( "./check_http --ssl www.verisign.com -E" ); | 152 | $res = NPTest->testCmd( "./check_http --ssl www.verisign.com -E" ); |
| 116 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); | 153 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); |
| 117 | like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); | 154 | like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); |
diff --git a/plugins/t/check_ldap.t b/plugins/t/check_ldap.t new file mode 100644 index 00000000..b8944d4b --- /dev/null +++ b/plugins/t/check_ldap.t | |||
| @@ -0,0 +1,80 @@ | |||
| 1 | #!/usr/bin/env perl -I .. | ||
| 2 | # | ||
| 3 | # Lightweight Directory Access Protocol (LDAP) Test via check_ldap | ||
| 4 | # | ||
| 5 | # | ||
| 6 | |||
| 7 | use strict; | ||
| 8 | use warnings; | ||
| 9 | use Test::More; | ||
| 10 | use NPTest; | ||
| 11 | |||
| 12 | my $host_tcp_ldap = getTestParameter("NP_HOST_TCP_LDAP", | ||
| 13 | "A host providing the LDAP Service", | ||
| 14 | "localhost" ); | ||
| 15 | |||
| 16 | my $ldap_base_dn = getTestParameter("NP_LDAP_BASE_DN", | ||
| 17 | "A base dn for the LDAP Service", | ||
| 18 | "cn=admin" ); | ||
| 19 | |||
| 20 | my $host_nonresponsive = getTestParameter("host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", | ||
| 21 | "The hostname of system not responsive to network requests" ); | ||
| 22 | |||
| 23 | my $hostname_invalid = getTestParameter("hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | ||
| 24 | "An invalid (not known to DNS) hostname" ); | ||
| 25 | |||
| 26 | my($result, $cmd); | ||
| 27 | my $command = './check_ldap'; | ||
| 28 | |||
| 29 | plan tests => 16; | ||
| 30 | |||
| 31 | SKIP: { | ||
| 32 | skip "NP_HOST_NONRESPONSIVE not set", 2 if ! $host_nonresponsive; | ||
| 33 | |||
| 34 | $result = NPTest->testCmd("$command -H $host_nonresponsive -b ou=blah -t 2 -w 1 -c 1"); | ||
| 35 | is( $result->return_code, 2, "$command -H $host_nonresponsive -b ou=blah -t 5 -w 2 -c 3" ); | ||
| 36 | is( $result->output, 'CRITICAL - Socket timeout after 2 seconds', "output ok" ); | ||
| 37 | }; | ||
| 38 | |||
| 39 | SKIP: { | ||
| 40 | skip "NP_HOSTNAME_INVALID not set", 2 if ! $hostname_invalid; | ||
| 41 | |||
| 42 | $result = NPTest->testCmd("$command -H $hostname_invalid -b ou=blah -t 5"); | ||
| 43 | is( $result->return_code, 2, "$command -H $hostname_invalid -b ou=blah -t 5" ); | ||
| 44 | is( $result->output, 'Could not bind to the LDAP server', "output ok" ); | ||
| 45 | }; | ||
| 46 | |||
| 47 | SKIP: { | ||
| 48 | skip "NP_HOST_TCP_LDAP not set", 12 if ! $host_tcp_ldap; | ||
| 49 | skip "NP_LDAP_BASE_DN not set", 12 if ! $ldap_base_dn; | ||
| 50 | |||
| 51 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3"; | ||
| 52 | $result = NPTest->testCmd($cmd); | ||
| 53 | is( $result->return_code, 0, $cmd ); | ||
| 54 | like( $result->output, '/^LDAP OK - \d+.\d+ seconds response time\|time=\d+\.\d+s;2\.0+;3\.0+;0\.0+$/', "output ok" ); | ||
| 55 | |||
| 56 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -W 10000000 -C 10000001"; | ||
| 57 | $result = NPTest->testCmd($cmd); | ||
| 58 | is( $result->return_code, 0, $cmd ); | ||
| 59 | like( $result->output, '/^LDAP OK - found \d+ entries in \d+\.\d+ seconds\|time=\d\.\d+s;2\.0+;3\.0+;0\.0+ entries=\d+\.0+;10000000;10000001;0\.0+$/', "output ok" ); | ||
| 60 | |||
| 61 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -W 10000000: -C 10000001:"; | ||
| 62 | $result = NPTest->testCmd($cmd); | ||
| 63 | is( $result->return_code, 2, $cmd ); | ||
| 64 | like( $result->output, '/^LDAP CRITICAL - found \d+ entries in \d+\.\d+ seconds\|time=\d\.\d+s;2\.0+;3\.0+;0\.0+ entries=\d+\.0+;10000000:;10000001:;0\.0+$/', "output ok" ); | ||
| 65 | |||
| 66 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -W 0 -C 0"; | ||
| 67 | $result = NPTest->testCmd($cmd); | ||
| 68 | is( $result->return_code, 2, $cmd ); | ||
| 69 | like( $result->output, '/^LDAP CRITICAL - found \d+ entries in \d+\.\d+ seconds\|time=\d\.\d+s;2\.0+;3\.0+;0\.0+ entries=\d+\.0+;0;0;0\.0+$/', "output ok" ); | ||
| 70 | |||
| 71 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -W 10000000: -C 10000001"; | ||
| 72 | $result = NPTest->testCmd($cmd); | ||
| 73 | is( $result->return_code, 1, $cmd ); | ||
| 74 | like( $result->output, '/^LDAP WARNING - found \d+ entries in \d+\.\d+ seconds\|time=\d\.\d+s;2\.0+;3\.0+;0\.0+ entries=\d+\.0+;10000000:;10000001;0\.0+$/', "output ok" ); | ||
| 75 | |||
| 76 | $cmd = "$command -H $host_tcp_ldap -b $ldap_base_dn -t 5 -w 2 -c 3 -3 -C 10000001"; | ||
| 77 | $result = NPTest->testCmd($cmd); | ||
| 78 | is( $result->return_code, 0, $cmd ); | ||
| 79 | like( $result->output, '/^LDAP OK - found \d+ entries in \d+\.\d+ seconds\|time=\d\.\d+s;2\.0+;3\.0+;0\.0+ entries=\d+\.0+;;10000001;0\.0+$/', "output ok" ); | ||
| 80 | }; | ||
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t index d93a0ecf..e72d243a 100755 --- a/plugins/tests/check_http.t +++ b/plugins/tests/check_http.t | |||
| @@ -186,21 +186,21 @@ SKIP: { | |||
| 186 | 186 | ||
| 187 | $result = NPTest->testCmd( "$command -p $port_https -S -C 14" ); | 187 | $result = NPTest->testCmd( "$command -p $port_https -S -C 14" ); |
| 188 | is( $result->return_code, 0, "$command -p $port_https -S -C 14" ); | 188 | is( $result->return_code, 0, "$command -p $port_https -S -C 14" ); |
| 189 | is( $result->output, 'OK - Certificate \'Ton Voon\' will expire on Sun Mar 3 21:41:00 2019.', "output ok" ); | 189 | is( $result->output, 'OK - Certificate \'Ton Voon\' will expire on Sun Mar 3 21:41:28 2019.', "output ok" ); |
| 190 | 190 | ||
| 191 | $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" ); | 191 | $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" ); |
| 192 | is( $result->return_code, 1, "$command -p $port_https -S -C 14000" ); | 192 | is( $result->return_code, 1, "$command -p $port_https -S -C 14000" ); |
| 193 | like( $result->output, '/WARNING - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:00 2019\)./', "output ok" ); | 193 | like( $result->output, '/WARNING - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:28 2019\)./', "output ok" ); |
| 194 | 194 | ||
| 195 | # Expired cert tests | 195 | # Expired cert tests |
| 196 | $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" ); | 196 | $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" ); |
| 197 | is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" ); | 197 | is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" ); |
| 198 | like( $result->output, '/CRITICAL - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:00 2019\)./', "output ok" ); | 198 | like( $result->output, '/CRITICAL - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:28 2019\)./', "output ok" ); |
| 199 | 199 | ||
| 200 | $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" ); | 200 | $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" ); |
| 201 | is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" ); | 201 | is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" ); |
| 202 | is( $result->output, | 202 | is( $result->output, |
| 203 | 'CRITICAL - Certificate \'Ton Voon\' expired on Thu Mar 5 00:13:00 2009.', | 203 | 'CRITICAL - Certificate \'Ton Voon\' expired on Thu Mar 5 00:13:16 2009.', |
| 204 | "output ok" ); | 204 | "output ok" ); |
| 205 | 205 | ||
| 206 | } | 206 | } |
diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t index 2fd033d2..73a68b20 100755 --- a/plugins/tests/check_snmp.t +++ b/plugins/tests/check_snmp.t | |||
| @@ -128,7 +128,7 @@ sleep 1; | |||
| 128 | 128 | ||
| 129 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -w 600" ); | 129 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -w 600" ); |
| 130 | is($res->return_code, 1, "WARNING - due to going above rate calculation" ); | 130 | is($res->return_code, 1, "WARNING - due to going above rate calculation" ); |
| 131 | is($res->output, "SNMP RATE WARNING - *666* | iso.3.6.1.4.1.8072.3.2.67.10=666 "); | 131 | is($res->output, "SNMP RATE WARNING - *666* | iso.3.6.1.4.1.8072.3.2.67.10=666;600 "); |
| 132 | 132 | ||
| 133 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -w 600" ); | 133 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -w 600" ); |
| 134 | is($res->return_code, 3, "UNKNOWN - basically the divide by zero error" ); | 134 | is($res->return_code, 3, "UNKNOWN - basically the divide by zero error" ); |
| @@ -209,7 +209,7 @@ is($res->output, 'SNMP OK - "stringtests" | ', "OK as inverted string no match" | |||
| 209 | 209 | ||
| 210 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.12 -w 4:5" ); | 210 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.12 -w 4:5" ); |
| 211 | is($res->return_code, 1, "Numeric in string test" ); | 211 | is($res->return_code, 1, "Numeric in string test" ); |
| 212 | is($res->output, 'SNMP WARNING - *3.5* | iso.3.6.1.4.1.8072.3.2.67.12=3.5 ', "WARNING threshold checks for string masquerading as number" ); | 212 | is($res->output, 'SNMP WARNING - *3.5* | iso.3.6.1.4.1.8072.3.2.67.12=3.5;4:5 ', "WARNING threshold checks for string masquerading as number" ); |
| 213 | 213 | ||
| 214 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.13" ); | 214 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.13" ); |
| 215 | is($res->return_code, 0, "Not really numeric test" ); | 215 | is($res->return_code, 0, "Not really numeric test" ); |
| @@ -225,29 +225,29 @@ is($res->output, 'SNMP OK - "CUSTOM CHECK OK: foo is 12345" | ', "String check w | |||
| 225 | 225 | ||
| 226 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" ); | 226 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" ); |
| 227 | is($res->return_code, 0, "Negative integer check OK" ); | 227 | is($res->return_code, 0, "Negative integer check OK" ); |
| 228 | is($res->output, 'SNMP OK - -2 | iso.3.6.1.4.1.8072.3.2.67.16=-2 ', "Negative integer check OK output" ); | 228 | is($res->output, 'SNMP OK - -2 | iso.3.6.1.4.1.8072.3.2.67.16=-2;-2:;-3: ', "Negative integer check OK output" ); |
| 229 | 229 | ||
| 230 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" ); | 230 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" ); |
| 231 | is($res->return_code, 1, "Negative integer check WARNING" ); | 231 | is($res->return_code, 1, "Negative integer check WARNING" ); |
| 232 | is($res->output, 'SNMP WARNING - *-3* | iso.3.6.1.4.1.8072.3.2.67.16=-3 ', "Negative integer check WARNING output" ); | 232 | is($res->output, 'SNMP WARNING - *-3* | iso.3.6.1.4.1.8072.3.2.67.16=-3;-2:;-3: ', "Negative integer check WARNING output" ); |
| 233 | 233 | ||
| 234 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" ); | 234 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" ); |
| 235 | is($res->return_code, 2, "Negative integer check CRITICAL" ); | 235 | is($res->return_code, 2, "Negative integer check CRITICAL" ); |
| 236 | is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.16=-4 ', "Negative integer check CRITICAL output" ); | 236 | is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.16=-4;-2:;-3: ', "Negative integer check CRITICAL output" ); |
| 237 | 237 | ||
| 238 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.17 -w -3: -c -6:" ); | 238 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.17 -w -3: -c -6:" ); |
| 239 | is($res->return_code, 1, "Negative integer as string, WARNING" ); | 239 | is($res->return_code, 1, "Negative integer as string, WARNING" ); |
| 240 | is($res->output, 'SNMP WARNING - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4 ', "Negative integer as string, WARNING output" ); | 240 | is($res->output, 'SNMP WARNING - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4;-3:;-6: ', "Negative integer as string, WARNING output" ); |
| 241 | 241 | ||
| 242 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.17 -w -2: -c -3:" ); | 242 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.17 -w -2: -c -3:" ); |
| 243 | is($res->return_code, 2, "Negative integer as string, CRITICAL" ); | 243 | is($res->return_code, 2, "Negative integer as string, CRITICAL" ); |
| 244 | is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4 ', "Negative integer as string, CRITICAL output" ); | 244 | is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4;-2:;-3: ', "Negative integer as string, CRITICAL output" ); |
| 245 | 245 | ||
| 246 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.18 -c ~:-6.5" ); | 246 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.18 -c '~:-6.5'" ); |
| 247 | is($res->return_code, 0, "Negative float OK" ); | 247 | is($res->return_code, 0, "Negative float OK" ); |
| 248 | is($res->output, 'SNMP OK - -6.6 | iso.3.6.1.4.1.8072.3.2.67.18=-6.6 ', "Negative float OK output" ); | 248 | is($res->output, 'SNMP OK - -6.6 | iso.3.6.1.4.1.8072.3.2.67.18=-6.6;;~:-6.5 ', "Negative float OK output" ); |
| 249 | 249 | ||
| 250 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.18 -w ~:-6.65 -c ~:-6.55" ); | 250 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.18 -w '~:-6.65' -c '~:-6.55'" ); |
| 251 | is($res->return_code, 1, "Negative float WARNING" ); | 251 | is($res->return_code, 1, "Negative float WARNING" ); |
| 252 | is($res->output, 'SNMP WARNING - *-6.6* | iso.3.6.1.4.1.8072.3.2.67.18=-6.6 ', "Negative float WARNING output" ); | 252 | is($res->output, 'SNMP WARNING - *-6.6* | iso.3.6.1.4.1.8072.3.2.67.18=-6.6;~:-6.65;~:-6.55 ', "Negative float WARNING output" ); |
| 253 | 253 | ||
diff --git a/plugins/utils.c b/plugins/utils.c index 58b153d8..a864e4aa 100644 --- a/plugins/utils.c +++ b/plugins/utils.c | |||
| @@ -144,8 +144,6 @@ usage5 (void) | |||
| 144 | void | 144 | void |
| 145 | print_revision (const char *command_name, const char *revision) | 145 | print_revision (const char *command_name, const char *revision) |
| 146 | { | 146 | { |
| 147 | char plugin_revision[STRLEN]; | ||
| 148 | |||
| 149 | printf ("%s v%s (%s %s)\n", | 147 | printf ("%s v%s (%s %s)\n", |
| 150 | command_name, revision, PACKAGE, VERSION); | 148 | command_name, revision, PACKAGE, VERSION); |
| 151 | } | 149 | } |
| @@ -630,3 +628,43 @@ char *fperfdata (const char *label, | |||
| 630 | 628 | ||
| 631 | return data; | 629 | return data; |
| 632 | } | 630 | } |
| 631 | |||
| 632 | char *sperfdata (const char *label, | ||
| 633 | double val, | ||
| 634 | const char *uom, | ||
| 635 | char *warn, | ||
| 636 | char *crit, | ||
| 637 | int minp, | ||
| 638 | double minv, | ||
| 639 | int maxp, | ||
| 640 | double maxv) | ||
| 641 | { | ||
| 642 | char *data = NULL; | ||
| 643 | if (strpbrk (label, "'= ")) | ||
| 644 | xasprintf (&data, "'%s'=", label); | ||
| 645 | else | ||
| 646 | xasprintf (&data, "%s=", label); | ||
| 647 | |||
| 648 | xasprintf (&data, "%s%f", data, val); | ||
| 649 | xasprintf (&data, "%s%s;", data, uom); | ||
| 650 | |||
| 651 | if (warn!=NULL) | ||
| 652 | xasprintf (&data, "%s%s", data, warn); | ||
| 653 | |||
| 654 | xasprintf (&data, "%s;", data); | ||
| 655 | |||
| 656 | if (crit!=NULL) | ||
| 657 | xasprintf (&data, "%s%s", data, crit); | ||
| 658 | |||
| 659 | xasprintf (&data, "%s;", data); | ||
| 660 | |||
| 661 | if (minp) | ||
| 662 | xasprintf (&data, "%s%f", data, minv); | ||
| 663 | |||
| 664 | if (maxp) { | ||
| 665 | xasprintf (&data, "%s;", data); | ||
| 666 | xasprintf (&data, "%s%f", data, maxv); | ||
| 667 | } | ||
| 668 | |||
| 669 | return data; | ||
| 670 | } | ||
diff --git a/tools/update-thanks b/tools/update-thanks new file mode 100755 index 00000000..27932f94 --- /dev/null +++ b/tools/update-thanks | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Copyright (c) 2014 Monitoring Plugins Development Team | ||
| 4 | # | ||
| 5 | # Originally written by Holger Weiss <holger@zedat.fu-berlin.de>. | ||
| 6 | # | ||
| 7 | # This file is free software; the Monitoring Plugins Development Team gives | ||
| 8 | # unlimited permission to copy and/or distribute it, with or without | ||
| 9 | # modifications, as long as this notice is preserved. | ||
| 10 | # | ||
| 11 | # This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 12 | # ANY WARRANTY, to the extent permitted by law; without even the implied | ||
| 13 | # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| 14 | |||
| 15 | set -e | ||
| 16 | set -u | ||
| 17 | |||
| 18 | tempfile=$(mktemp '/tmp/.plugins.XXXXXX') | ||
| 19 | trap 'rm -f $tempfile' EXIT INT TERM | ||
| 20 | |||
| 21 | if [ ! -e THANKS.in ] | ||
| 22 | then | ||
| 23 | echo >&2 'Please change into the "monitoring-plugins" repository.' | ||
| 24 | exit 2 | ||
| 25 | fi | ||
| 26 | |||
| 27 | case $# in | ||
| 28 | 1) since=$1; git cat-file -e "$since";; | ||
| 29 | 0) since=$(git tag -l 'v*' | tail -n 1);; | ||
| 30 | *) echo >&2 "Usage: $0 [<since>]"; exit 2;; | ||
| 31 | esac | ||
| 32 | |||
| 33 | git log --pretty='%an' "$since.." | sort -u | while read first last rest | ||
| 34 | do | ||
| 35 | if [ -n "$first" -a -n "$last" -a -z "$rest" ] | ||
| 36 | then | ||
| 37 | if ! grep -q "^$first $last$" AUTHORS THANKS.in | ||
| 38 | then | ||
| 39 | echo "$first $last" >> THANKS.in | ||
| 40 | fi | ||
| 41 | else | ||
| 42 | echo "$first $last $rest" | sed 's/ *$//' >> "$tempfile" | ||
| 43 | fi | ||
| 44 | done | ||
| 45 | |||
| 46 | if ! git diff --quiet THANKS.in | ||
| 47 | then | ||
| 48 | echo 'Please check/commit the changes in the THANKS.in file.' | ||
| 49 | fi | ||
| 50 | |||
| 51 | if [ -s "$tempfile" ] | ||
| 52 | then | ||
| 53 | echo 'The following authors were NOT added to the THANKS.in file:' | ||
| 54 | echo | ||
| 55 | cat "$tempfile" | ||
| 56 | fi | ||
