diff options
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | THANKS.in | 5 | ||||
-rw-r--r-- | gl/Makefile.am | 11 | ||||
-rw-r--r-- | gl/m4/gnulib-cache.m4 | 3 | ||||
-rw-r--r-- | gl/m4/gnulib-comp.m4 | 15 | ||||
-rw-r--r-- | gl/m4/strcasestr.m4 | 142 | ||||
-rw-r--r-- | gl/strcasestr.c | 82 | ||||
-rw-r--r-- | plugins-root/check_dhcp.c | 13 | ||||
-rw-r--r-- | plugins/check_by_ssh.c | 7 | ||||
-rw-r--r-- | plugins/check_dig.c | 6 | ||||
-rw-r--r-- | plugins/check_disk.c | 9 | ||||
-rw-r--r-- | plugins/check_dns.c | 8 | ||||
-rw-r--r-- | plugins/check_http.c | 38 | ||||
-rw-r--r-- | plugins/check_ide_smart.c | 26 | ||||
-rw-r--r-- | plugins/check_load.c | 2 | ||||
-rw-r--r-- | plugins/check_ntp.c | 6 | ||||
-rw-r--r-- | plugins/check_ntp_time.c | 6 | ||||
-rw-r--r-- | plugins/check_snmp.c | 16 | ||||
-rw-r--r-- | plugins/check_users.c | 60 | ||||
-rw-r--r-- | plugins/negate.c | 4 | ||||
-rw-r--r-- | plugins/sslutils.c | 15 | ||||
-rw-r--r-- | plugins/t/NPTest.cache.travis | 4 | ||||
-rw-r--r-- | plugins/t/check_http.t | 34 | ||||
-rw-r--r-- | plugins/t/check_snmp.t | 8 | ||||
-rw-r--r-- | plugins/t/check_users.t | 4 | ||||
-rwxr-xr-x | plugins/tests/check_http.t | 10 | ||||
-rw-r--r-- | plugins/utils.c | 41 | ||||
-rw-r--r-- | plugins/utils.h | 34 |
29 files changed, 460 insertions, 154 deletions
@@ -21,3 +21,4 @@ Ton Voon | |||
21 | Jan Wagner | 21 | Jan Wagner |
22 | Holger Weiss | 22 | Holger Weiss |
23 | Michael Wirtgen | 23 | Michael Wirtgen |
24 | Oliver Skibbe | ||
@@ -12,6 +12,9 @@ This file documents the major additions and syntax changes between releases. | |||
12 | to force TLSv1.1 and TLSv1.2 connections, respectively | 12 | to force TLSv1.1 and TLSv1.2 connections, respectively |
13 | The check_http -S/--ssl option now allows for specifying the desired | 13 | The check_http -S/--ssl option now allows for specifying the desired |
14 | protocol with a "+" suffix to also accept newer versions | 14 | protocol with a "+" suffix to also accept newer versions |
15 | check_users: add support for range thresholds (John C. Frickson) | ||
16 | check_snmp: add ipv6 support (abrist) | ||
17 | check_http: report certificate expire date in UTC (pirtoo / ylfingr) | ||
15 | 18 | ||
16 | FIXES | 19 | FIXES |
17 | Let check_real terminate lines with CRLF when talking to the server, as | 20 | Let check_real terminate lines with CRLF when talking to the server, as |
@@ -19,6 +22,7 @@ This file documents the major additions and syntax changes between releases. | |||
19 | Fix check_procs on HP-UX | 22 | Fix check_procs on HP-UX |
20 | check_smtp's -e/--expect option can now be combined with -S/--starttls | 23 | check_smtp's -e/--expect option can now be combined with -S/--starttls |
21 | Fix incorrect performance data thresholds emitted by check_ups | 24 | Fix incorrect performance data thresholds emitted by check_ups |
25 | check_http: fix host header port handling (odenbach) | ||
22 | 26 | ||
23 | WARNINGS | 27 | WARNINGS |
24 | The format of the performance data emitted by check_mrtgtraf has been | 28 | The format of the performance data emitted by check_mrtgtraf has been |
@@ -336,3 +336,8 @@ Nick Peelman | |||
336 | Sebastian Herbszt | 336 | Sebastian Herbszt |
337 | Christopher Schultz | 337 | Christopher Schultz |
338 | Matthias Hähnel | 338 | Matthias Hähnel |
339 | Roberto Greiner | ||
340 | Peter (pirtoo) | ||
341 | ylfingr | ||
342 | Christian Kujau | ||
343 | Christopher Odenbach | ||
diff --git a/gl/Makefile.am b/gl/Makefile.am index 54abb4c7..15135c8b 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am | |||
@@ -21,7 +21,7 @@ | |||
21 | # the same distribution terms as the rest of that program. | 21 | # the same distribution terms as the rest of that program. |
22 | # | 22 | # |
23 | # Generated by gnulib-tool. | 23 | # Generated by gnulib-tool. |
24 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt-gnu gettext idpriv-droptemp mountlist regex setenv strcase strsep timegm unsetenv vasprintf vsnprintf | 24 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt-gnu gettext idpriv-droptemp mountlist regex setenv strcase strcasestr strsep timegm unsetenv vasprintf vsnprintf |
25 | 25 | ||
26 | AUTOMAKE_OPTIONS = 1.9.6 gnits subdir-objects | 26 | AUTOMAKE_OPTIONS = 1.9.6 gnits subdir-objects |
27 | 27 | ||
@@ -1553,6 +1553,15 @@ EXTRA_libgnu_a_SOURCES += strcasecmp.c strncasecmp.c | |||
1553 | 1553 | ||
1554 | ## end gnulib module strcase | 1554 | ## end gnulib module strcase |
1555 | 1555 | ||
1556 | ## begin gnulib module strcasestr-simple | ||
1557 | |||
1558 | |||
1559 | EXTRA_DIST += str-two-way.h strcasestr.c | ||
1560 | |||
1561 | EXTRA_libgnu_a_SOURCES += strcasestr.c | ||
1562 | |||
1563 | ## end gnulib module strcasestr-simple | ||
1564 | |||
1556 | ## begin gnulib module streq | 1565 | ## begin gnulib module streq |
1557 | 1566 | ||
1558 | 1567 | ||
diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4 index d6fca2a3..90ad4aaa 100644 --- a/gl/m4/gnulib-cache.m4 +++ b/gl/m4/gnulib-cache.m4 | |||
@@ -27,7 +27,7 @@ | |||
27 | 27 | ||
28 | 28 | ||
29 | # Specification in the form of a command-line invocation: | 29 | # Specification in the form of a command-line invocation: |
30 | # gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt-gnu gettext idpriv-droptemp mountlist regex setenv strcase strsep timegm unsetenv vasprintf vsnprintf | 30 | # gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt-gnu gettext idpriv-droptemp mountlist regex setenv strcase strcasestr strsep timegm unsetenv vasprintf vsnprintf |
31 | 31 | ||
32 | # Specification in the form of a few gnulib-tool.m4 macro invocations: | 32 | # Specification in the form of a few gnulib-tool.m4 macro invocations: |
33 | gl_LOCAL_DIR([]) | 33 | gl_LOCAL_DIR([]) |
@@ -48,6 +48,7 @@ gl_MODULES([ | |||
48 | regex | 48 | regex |
49 | setenv | 49 | setenv |
50 | strcase | 50 | strcase |
51 | strcasestr | ||
51 | strsep | 52 | strsep |
52 | timegm | 53 | timegm |
53 | unsetenv | 54 | unsetenv |
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index 67a81566..9a4f5027 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 | |||
@@ -121,6 +121,8 @@ AC_DEFUN([gl_EARLY], | |||
121 | # Code from module stdio: | 121 | # Code from module stdio: |
122 | # Code from module stdlib: | 122 | # Code from module stdlib: |
123 | # Code from module strcase: | 123 | # Code from module strcase: |
124 | # Code from module strcasestr: | ||
125 | # Code from module strcasestr-simple: | ||
124 | # Code from module streq: | 126 | # Code from module streq: |
125 | # Code from module strerror: | 127 | # Code from module strerror: |
126 | # Code from module strerror-override: | 128 | # Code from module strerror-override: |
@@ -390,6 +392,17 @@ AC_DEFUN([gl_INIT], | |||
390 | AC_LIBOBJ([strncasecmp]) | 392 | AC_LIBOBJ([strncasecmp]) |
391 | gl_PREREQ_STRNCASECMP | 393 | gl_PREREQ_STRNCASECMP |
392 | fi | 394 | fi |
395 | gl_FUNC_STRCASESTR | ||
396 | if test $HAVE_STRCASESTR = 0 || test $REPLACE_STRCASESTR = 1; then | ||
397 | AC_LIBOBJ([strcasestr]) | ||
398 | gl_PREREQ_STRCASESTR | ||
399 | fi | ||
400 | gl_FUNC_STRCASESTR_SIMPLE | ||
401 | if test $HAVE_STRCASESTR = 0 || test $REPLACE_STRCASESTR = 1; then | ||
402 | AC_LIBOBJ([strcasestr]) | ||
403 | gl_PREREQ_STRCASESTR | ||
404 | fi | ||
405 | gl_STRING_MODULE_INDICATOR([strcasestr]) | ||
393 | gl_FUNC_STRERROR | 406 | gl_FUNC_STRERROR |
394 | if test $REPLACE_STRERROR = 1; then | 407 | if test $REPLACE_STRERROR = 1; then |
395 | AC_LIBOBJ([strerror]) | 408 | AC_LIBOBJ([strerror]) |
@@ -723,6 +736,7 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
723 | lib/stdlib.in.h | 736 | lib/stdlib.in.h |
724 | lib/str-two-way.h | 737 | lib/str-two-way.h |
725 | lib/strcasecmp.c | 738 | lib/strcasecmp.c |
739 | lib/strcasestr.c | ||
726 | lib/streq.h | 740 | lib/streq.h |
727 | lib/strerror-override.c | 741 | lib/strerror-override.c |
728 | lib/strerror-override.h | 742 | lib/strerror-override.h |
@@ -866,6 +880,7 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
866 | m4/stdio_h.m4 | 880 | m4/stdio_h.m4 |
867 | m4/stdlib_h.m4 | 881 | m4/stdlib_h.m4 |
868 | m4/strcase.m4 | 882 | m4/strcase.m4 |
883 | m4/strcasestr.m4 | ||
869 | m4/strerror.m4 | 884 | m4/strerror.m4 |
870 | m4/string_h.m4 | 885 | m4/string_h.m4 |
871 | m4/strings_h.m4 | 886 | m4/strings_h.m4 |
diff --git a/gl/m4/strcasestr.m4 b/gl/m4/strcasestr.m4 new file mode 100644 index 00000000..8681a6a4 --- /dev/null +++ b/gl/m4/strcasestr.m4 | |||
@@ -0,0 +1,142 @@ | |||
1 | # strcasestr.m4 serial 21 | ||
2 | dnl Copyright (C) 2005, 2007-2013 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | dnl Check that strcasestr is present and works. | ||
8 | AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE], | ||
9 | [ | ||
10 | AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) | ||
11 | |||
12 | dnl Persuade glibc <string.h> to declare strcasestr(). | ||
13 | AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) | ||
14 | |||
15 | AC_REQUIRE([gl_FUNC_MEMCHR]) | ||
16 | AC_CHECK_FUNCS([strcasestr]) | ||
17 | if test $ac_cv_func_strcasestr = no; then | ||
18 | HAVE_STRCASESTR=0 | ||
19 | else | ||
20 | if test "$gl_cv_func_memchr_works" != yes; then | ||
21 | REPLACE_STRCASESTR=1 | ||
22 | else | ||
23 | dnl Detect http://sourceware.org/bugzilla/show_bug.cgi?id=12092. | ||
24 | AC_CACHE_CHECK([whether strcasestr works], | ||
25 | [gl_cv_func_strcasestr_works_always], | ||
26 | [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ | ||
27 | #include <string.h> /* for strcasestr */ | ||
28 | #define P "_EF_BF_BD" | ||
29 | #define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P | ||
30 | #define NEEDLE P P P P P | ||
31 | ]], [[return !!strcasestr (HAYSTACK, NEEDLE); | ||
32 | ]])], | ||
33 | [gl_cv_func_strcasestr_works_always=yes], | ||
34 | [gl_cv_func_strcasestr_works_always=no], | ||
35 | [dnl glibc 2.12 and cygwin 1.7.7 have a known bug. uClibc is not | ||
36 | dnl affected, since it uses different source code for strcasestr | ||
37 | dnl than glibc. | ||
38 | dnl Assume that it works on all other platforms, even if it is not | ||
39 | dnl linear. | ||
40 | AC_EGREP_CPP([Lucky user], | ||
41 | [ | ||
42 | #ifdef __GNU_LIBRARY__ | ||
43 | #include <features.h> | ||
44 | #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \ | ||
45 | || defined __UCLIBC__ | ||
46 | Lucky user | ||
47 | #endif | ||
48 | #elif defined __CYGWIN__ | ||
49 | #include <cygwin/version.h> | ||
50 | #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7) | ||
51 | Lucky user | ||
52 | #endif | ||
53 | #else | ||
54 | Lucky user | ||
55 | #endif | ||
56 | ], | ||
57 | [gl_cv_func_strcasestr_works_always="guessing yes"], | ||
58 | [gl_cv_func_strcasestr_works_always="guessing no"]) | ||
59 | ]) | ||
60 | ]) | ||
61 | case "$gl_cv_func_strcasestr_works_always" in | ||
62 | *yes) ;; | ||
63 | *) | ||
64 | REPLACE_STRCASESTR=1 | ||
65 | ;; | ||
66 | esac | ||
67 | fi | ||
68 | fi | ||
69 | ]) # gl_FUNC_STRCASESTR_SIMPLE | ||
70 | |||
71 | dnl Additionally, check that strcasestr is efficient. | ||
72 | AC_DEFUN([gl_FUNC_STRCASESTR], | ||
73 | [ | ||
74 | AC_REQUIRE([gl_FUNC_STRCASESTR_SIMPLE]) | ||
75 | if test $HAVE_STRCASESTR = 1 && test $REPLACE_STRCASESTR = 0; then | ||
76 | AC_CACHE_CHECK([whether strcasestr works in linear time], | ||
77 | [gl_cv_func_strcasestr_linear], | ||
78 | [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ | ||
79 | #include <signal.h> /* for signal */ | ||
80 | #include <string.h> /* for strcasestr */ | ||
81 | #include <stdlib.h> /* for malloc */ | ||
82 | #include <unistd.h> /* for alarm */ | ||
83 | static void quit (int sig) { exit (sig + 128); } | ||
84 | ]], [[ | ||
85 | int result = 0; | ||
86 | size_t m = 1000000; | ||
87 | char *haystack = (char *) malloc (2 * m + 2); | ||
88 | char *needle = (char *) malloc (m + 2); | ||
89 | /* Failure to compile this test due to missing alarm is okay, | ||
90 | since all such platforms (mingw) also lack strcasestr. */ | ||
91 | signal (SIGALRM, quit); | ||
92 | alarm (5); | ||
93 | /* Check for quadratic performance. */ | ||
94 | if (haystack && needle) | ||
95 | { | ||
96 | memset (haystack, 'A', 2 * m); | ||
97 | haystack[2 * m] = 'B'; | ||
98 | haystack[2 * m + 1] = 0; | ||
99 | memset (needle, 'A', m); | ||
100 | needle[m] = 'B'; | ||
101 | needle[m + 1] = 0; | ||
102 | if (!strcasestr (haystack, needle)) | ||
103 | result |= 1; | ||
104 | } | ||
105 | return result; | ||
106 | ]])], | ||
107 | [gl_cv_func_strcasestr_linear=yes], [gl_cv_func_strcasestr_linear=no], | ||
108 | [dnl Only glibc > 2.12 and cygwin > 1.7.7 are known to have a | ||
109 | dnl strcasestr that works in linear time. | ||
110 | AC_EGREP_CPP([Lucky user], | ||
111 | [ | ||
112 | #include <features.h> | ||
113 | #ifdef __GNU_LIBRARY__ | ||
114 | #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \ | ||
115 | && !defined __UCLIBC__ | ||
116 | Lucky user | ||
117 | #endif | ||
118 | #endif | ||
119 | #ifdef __CYGWIN__ | ||
120 | #include <cygwin/version.h> | ||
121 | #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7) | ||
122 | Lucky user | ||
123 | #endif | ||
124 | #endif | ||
125 | ], | ||
126 | [gl_cv_func_strcasestr_linear="guessing yes"], | ||
127 | [gl_cv_func_strcasestr_linear="guessing no"]) | ||
128 | ]) | ||
129 | ]) | ||
130 | case "$gl_cv_func_strcasestr_linear" in | ||
131 | *yes) ;; | ||
132 | *) | ||
133 | REPLACE_STRCASESTR=1 | ||
134 | ;; | ||
135 | esac | ||
136 | fi | ||
137 | ]) # gl_FUNC_STRCASESTR | ||
138 | |||
139 | # Prerequisites of lib/strcasestr.c. | ||
140 | AC_DEFUN([gl_PREREQ_STRCASESTR], [ | ||
141 | : | ||
142 | ]) | ||
diff --git a/gl/strcasestr.c b/gl/strcasestr.c new file mode 100644 index 00000000..53474a45 --- /dev/null +++ b/gl/strcasestr.c | |||
@@ -0,0 +1,82 @@ | |||
1 | /* Case-insensitive searching in a string. | ||
2 | Copyright (C) 2005-2013 Free Software Foundation, Inc. | ||
3 | Written by Bruno Haible <bruno@clisp.org>, 2005. | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 3, or (at your option) | ||
8 | any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, see <http://www.gnu.org/licenses/>. */ | ||
17 | |||
18 | #include <config.h> | ||
19 | |||
20 | /* Specification. */ | ||
21 | #include <string.h> | ||
22 | |||
23 | #include <ctype.h> | ||
24 | #include <stdbool.h> | ||
25 | #include <strings.h> | ||
26 | |||
27 | #define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) | ||
28 | |||
29 | /* Two-Way algorithm. */ | ||
30 | #define RETURN_TYPE char * | ||
31 | #define AVAILABLE(h, h_l, j, n_l) \ | ||
32 | (!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \ | ||
33 | && ((h_l) = (j) + (n_l))) | ||
34 | #define CANON_ELEMENT(c) TOLOWER (c) | ||
35 | #define CMP_FUNC(p1, p2, l) \ | ||
36 | strncasecmp ((const char *) (p1), (const char *) (p2), l) | ||
37 | #include "str-two-way.h" | ||
38 | |||
39 | /* Find the first occurrence of NEEDLE in HAYSTACK, using | ||
40 | case-insensitive comparison. This function gives unspecified | ||
41 | results in multibyte locales. */ | ||
42 | char * | ||
43 | strcasestr (const char *haystack_start, const char *needle_start) | ||
44 | { | ||
45 | const char *haystack = haystack_start; | ||
46 | const char *needle = needle_start; | ||
47 | size_t needle_len; /* Length of NEEDLE. */ | ||
48 | size_t haystack_len; /* Known minimum length of HAYSTACK. */ | ||
49 | bool ok = true; /* True if NEEDLE is prefix of HAYSTACK. */ | ||
50 | |||
51 | /* Determine length of NEEDLE, and in the process, make sure | ||
52 | HAYSTACK is at least as long (no point processing all of a long | ||
53 | NEEDLE if HAYSTACK is too short). */ | ||
54 | while (*haystack && *needle) | ||
55 | { | ||
56 | ok &= (TOLOWER ((unsigned char) *haystack) | ||
57 | == TOLOWER ((unsigned char) *needle)); | ||
58 | haystack++; | ||
59 | needle++; | ||
60 | } | ||
61 | if (*needle) | ||
62 | return NULL; | ||
63 | if (ok) | ||
64 | return (char *) haystack_start; | ||
65 | needle_len = needle - needle_start; | ||
66 | haystack = haystack_start + 1; | ||
67 | haystack_len = needle_len - 1; | ||
68 | |||
69 | /* Perform the search. Abstract memory is considered to be an array | ||
70 | of 'unsigned char' values, not an array of 'char' values. See | ||
71 | ISO C 99 section 6.2.6.1. */ | ||
72 | if (needle_len < LONG_NEEDLE_THRESHOLD) | ||
73 | return two_way_short_needle ((const unsigned char *) haystack, | ||
74 | haystack_len, | ||
75 | (const unsigned char *) needle_start, | ||
76 | needle_len); | ||
77 | return two_way_long_needle ((const unsigned char *) haystack, haystack_len, | ||
78 | (const unsigned char *) needle_start, | ||
79 | needle_len); | ||
80 | } | ||
81 | |||
82 | #undef LONG_NEEDLE_THRESHOLD | ||
diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c index d8afb172..88b7ca10 100644 --- a/plugins-root/check_dhcp.c +++ b/plugins-root/check_dhcp.c | |||
@@ -463,10 +463,9 @@ int send_dhcp_discover(int sock){ | |||
463 | discover_packet.hlen=ETHERNET_HARDWARE_ADDRESS_LENGTH; | 463 | discover_packet.hlen=ETHERNET_HARDWARE_ADDRESS_LENGTH; |
464 | 464 | ||
465 | /* | 465 | /* |
466 | * transaction ID is supposed to be random. We won't use the address so | 466 | * transaction ID is supposed to be random. |
467 | * we don't care about high entropy here. time(2) is good enough. | ||
468 | */ | 467 | */ |
469 | srand(time(NULL)); | 468 | srand(time(NULL)^getpid()); |
470 | packet_xid=random(); | 469 | packet_xid=random(); |
471 | discover_packet.xid=htonl(packet_xid); | 470 | discover_packet.xid=htonl(packet_xid); |
472 | 471 | ||
@@ -692,17 +691,11 @@ int receive_dhcp_packet(void *buffer, int buffer_size, int sock, int timeout, st | |||
692 | } | 691 | } |
693 | 692 | ||
694 | else{ | 693 | else{ |
695 | |||
696 | /* why do we need to peek first? i don't know, its a hack. without it, the source address of the first packet received was | ||
697 | not being interpreted correctly. sigh... */ | ||
698 | bzero(&source_address,sizeof(source_address)); | 694 | bzero(&source_address,sizeof(source_address)); |
699 | address_size=sizeof(source_address); | 695 | address_size=sizeof(source_address); |
700 | recv_result=recvfrom(sock,(char *)buffer,buffer_size,MSG_PEEK,(struct sockaddr *)&source_address,&address_size); | 696 | recv_result=recvfrom(sock,(char *)buffer,buffer_size,MSG_PEEK,(struct sockaddr *)&source_address,&address_size); |
701 | if(verbose) | 697 | if(verbose) |
702 | printf("recv_result_1: %d\n",recv_result); | 698 | printf("recv_result: %d\n",recv_result); |
703 | recv_result=recvfrom(sock,(char *)buffer,buffer_size,0,(struct sockaddr *)&source_address,&address_size); | ||
704 | if(verbose) | ||
705 | printf("recv_result_2: %d\n",recv_result); | ||
706 | 699 | ||
707 | if(recv_result==-1){ | 700 | if(recv_result==-1){ |
708 | if(verbose){ | 701 | if(verbose){ |
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c index 04bce38d..13d8bc3b 100644 --- a/plugins/check_by_ssh.c +++ b/plugins/check_by_ssh.c | |||
@@ -100,6 +100,13 @@ main (int argc, char **argv) | |||
100 | 100 | ||
101 | result = cmd_run_array (commargv, &chld_out, &chld_err, 0); | 101 | result = cmd_run_array (commargv, &chld_out, &chld_err, 0); |
102 | 102 | ||
103 | if (verbose) { | ||
104 | for(i = 0; i < chld_out.lines; i++) | ||
105 | printf("stdout: %s\n", chld_out.line[i]); | ||
106 | for(i = 0; i < chld_err.lines; i++) | ||
107 | printf("stderr: %s\n", chld_err.line[i]); | ||
108 | } | ||
109 | |||
103 | if (skip_stdout == -1) /* --skip-stdout specified without argument */ | 110 | if (skip_stdout == -1) /* --skip-stdout specified without argument */ |
104 | skip_stdout = chld_out.lines; | 111 | skip_stdout = chld_out.lines; |
105 | if (skip_stderr == -1) /* --skip-stderr specified without argument */ | 112 | if (skip_stderr == -1) /* --skip-stderr specified without argument */ |
diff --git a/plugins/check_dig.c b/plugins/check_dig.c index db4b20eb..da4f0ded 100644 --- a/plugins/check_dig.c +++ b/plugins/check_dig.c | |||
@@ -48,7 +48,7 @@ void print_usage (void); | |||
48 | 48 | ||
49 | #define UNDEFINED 0 | 49 | #define UNDEFINED 0 |
50 | #define DEFAULT_PORT 53 | 50 | #define DEFAULT_PORT 53 |
51 | #define DEFAULT_TRIES 3 | 51 | #define DEFAULT_TRIES 2 |
52 | 52 | ||
53 | char *query_address = NULL; | 53 | char *query_address = NULL; |
54 | char *record_type = "A"; | 54 | char *record_type = "A"; |
@@ -94,7 +94,7 @@ main (int argc, char **argv) | |||
94 | timeout_interval_dig = timeout_interval / number_tries + number_tries; | 94 | timeout_interval_dig = timeout_interval / number_tries + number_tries; |
95 | 95 | ||
96 | /* get the command to run */ | 96 | /* get the command to run */ |
97 | xasprintf (&command_line, "%s %s %s -p %d @%s %s %s +tries=%d +time=%d", | 97 | xasprintf (&command_line, "%s %s %s -p %d @%s %s %s +retry=%d +time=%d", |
98 | PATH_TO_DIG, dig_args, query_transport, server_port, dns_server, query_address, record_type, number_tries, timeout_interval_dig); | 98 | PATH_TO_DIG, dig_args, query_transport, server_port, dns_server, query_address, record_type, number_tries, timeout_interval_dig); |
99 | 99 | ||
100 | alarm (timeout_interval); | 100 | alarm (timeout_interval); |
@@ -125,7 +125,7 @@ main (int argc, char **argv) | |||
125 | if (verbose) | 125 | if (verbose) |
126 | printf ("%s\n", chld_out.line[i]); | 126 | printf ("%s\n", chld_out.line[i]); |
127 | 127 | ||
128 | if (strstr (chld_out.line[i], (expected_address == NULL ? query_address : expected_address)) != NULL) { | 128 | if (strcasestr (chld_out.line[i], (expected_address == NULL ? query_address : expected_address)) != NULL) { |
129 | msg = chld_out.line[i]; | 129 | msg = chld_out.line[i]; |
130 | result = STATE_OK; | 130 | result = STATE_OK; |
131 | 131 | ||
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 874a0ee0..e73a0083 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
@@ -58,9 +58,6 @@ const char *email = "devel@monitoring-plugins.org"; | |||
58 | # define ERROR -1 | 58 | # define ERROR -1 |
59 | #endif | 59 | #endif |
60 | 60 | ||
61 | /* If nonzero, show inode information. */ | ||
62 | static int inode_format = 1; | ||
63 | |||
64 | /* If nonzero, show even filesystems with zero size or | 61 | /* If nonzero, show even filesystems with zero size or |
65 | uninteresting types. */ | 62 | uninteresting types. */ |
66 | static int show_all_fs = 1; | 63 | static int show_all_fs = 1; |
@@ -178,7 +175,7 @@ main (int argc, char **argv) | |||
178 | int temp_result; | 175 | int temp_result; |
179 | 176 | ||
180 | struct mount_entry *me; | 177 | struct mount_entry *me; |
181 | struct fs_usage fsp, tmpfsp; | 178 | struct fs_usage fsp; |
182 | struct parameter_list *temp_list, *path; | 179 | struct parameter_list *temp_list, *path; |
183 | 180 | ||
184 | #ifdef __CYGWIN__ | 181 | #ifdef __CYGWIN__ |
@@ -423,9 +420,7 @@ process_arguments (int argc, char **argv) | |||
423 | int c, err; | 420 | int c, err; |
424 | struct parameter_list *se; | 421 | struct parameter_list *se; |
425 | struct parameter_list *temp_list = NULL, *previous = NULL; | 422 | struct parameter_list *temp_list = NULL, *previous = NULL; |
426 | struct parameter_list *temp_path_select_list = NULL; | 423 | struct mount_entry *me; |
427 | struct mount_entry *me, *temp_me; | ||
428 | int result = OK; | ||
429 | regex_t re; | 424 | regex_t re; |
430 | int cflags = REG_NOSUB | REG_EXTENDED; | 425 | int cflags = REG_NOSUB | REG_EXTENDED; |
431 | int default_cflags = cflags; | 426 | int default_cflags = cflags; |
diff --git a/plugins/check_dns.c b/plugins/check_dns.c index d6bd2c0f..54ce7d16 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c | |||
@@ -81,7 +81,6 @@ main (int argc, char **argv) | |||
81 | double elapsed_time; | 81 | double elapsed_time; |
82 | long microsec; | 82 | long microsec; |
83 | struct timeval tv; | 83 | struct timeval tv; |
84 | int multi_address; | ||
85 | int parse_address = FALSE; /* This flag scans for Address: but only after Name: */ | 84 | int parse_address = FALSE; /* This flag scans for Address: but only after Name: */ |
86 | output chld_out, chld_err; | 85 | output chld_out, chld_err; |
87 | size_t i; | 86 | size_t i; |
@@ -127,7 +126,7 @@ main (int argc, char **argv) | |||
127 | if (verbose) | 126 | if (verbose) |
128 | puts(chld_out.line[i]); | 127 | puts(chld_out.line[i]); |
129 | 128 | ||
130 | if (strstr (chld_out.line[i], ".in-addr.arpa")) { | 129 | if (strcasestr (chld_out.line[i], ".in-addr.arpa")) { |
131 | if ((temp_buffer = strstr (chld_out.line[i], "name = "))) | 130 | if ((temp_buffer = strstr (chld_out.line[i], "name = "))) |
132 | addresses[n_addresses++] = strdup (temp_buffer + 7); | 131 | addresses[n_addresses++] = strdup (temp_buffer + 7); |
133 | else { | 132 | else { |
@@ -249,11 +248,6 @@ main (int argc, char **argv) | |||
249 | elapsed_time = (double)microsec / 1.0e6; | 248 | elapsed_time = (double)microsec / 1.0e6; |
250 | 249 | ||
251 | if (result == STATE_OK) { | 250 | if (result == STATE_OK) { |
252 | if (strchr (address, ',') == NULL) | ||
253 | multi_address = FALSE; | ||
254 | else | ||
255 | multi_address = TRUE; | ||
256 | |||
257 | result = get_status(elapsed_time, time_thresholds); | 251 | result = get_status(elapsed_time, time_thresholds); |
258 | if (result == STATE_OK) { | 252 | if (result == STATE_OK) { |
259 | printf ("DNS %s: ", _("OK")); | 253 | printf ("DNS %s: ", _("OK")); |
diff --git a/plugins/check_http.c b/plugins/check_http.c index a2b76240..60fe4d52 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -91,10 +91,12 @@ struct timeval tv_temp; | |||
91 | 91 | ||
92 | int specify_port = FALSE; | 92 | int specify_port = FALSE; |
93 | int server_port = HTTP_PORT; | 93 | int server_port = HTTP_PORT; |
94 | int virtual_port = 0; | ||
94 | char server_port_text[6] = ""; | 95 | char server_port_text[6] = ""; |
95 | char server_type[6] = "http"; | 96 | char server_type[6] = "http"; |
96 | char *server_address; | 97 | char *server_address; |
97 | char *host_name; | 98 | char *host_name; |
99 | int host_name_length; | ||
98 | char *server_url; | 100 | char *server_url; |
99 | char *user_agent; | 101 | char *user_agent; |
100 | int server_url_length; | 102 | int server_url_length; |
@@ -391,11 +393,25 @@ process_arguments (int argc, char **argv) | |||
391 | case 'H': /* Host Name (virtual host) */ | 393 | case 'H': /* Host Name (virtual host) */ |
392 | host_name = strdup (optarg); | 394 | host_name = strdup (optarg); |
393 | if (host_name[0] == '[') { | 395 | if (host_name[0] == '[') { |
394 | if ((p = strstr (host_name, "]:")) != NULL) /* [IPv6]:port */ | 396 | if ((p = strstr (host_name, "]:")) != NULL) { /* [IPv6]:port */ |
395 | server_port = atoi (p + 2); | 397 | virtual_port = atoi (p + 2); |
398 | /* cut off the port */ | ||
399 | host_name_length = strlen (host_name) - strlen (p) - 1; | ||
400 | free (host_name); | ||
401 | host_name = strndup (optarg, host_name_length); | ||
402 | if (specify_port == FALSE) | ||
403 | server_port = virtual_port; | ||
404 | } | ||
396 | } else if ((p = strchr (host_name, ':')) != NULL | 405 | } else if ((p = strchr (host_name, ':')) != NULL |
397 | && strchr (++p, ':') == NULL) /* IPv4:port or host:port */ | 406 | && strchr (++p, ':') == NULL) { /* IPv4:port or host:port */ |
398 | server_port = atoi (p); | 407 | virtual_port = atoi (p); |
408 | /* cut off the port */ | ||
409 | host_name_length = strlen (host_name) - strlen (p) - 1; | ||
410 | free (host_name); | ||
411 | host_name = strndup (optarg, host_name_length); | ||
412 | if (specify_port == FALSE) | ||
413 | server_port = virtual_port; | ||
414 | } | ||
399 | break; | 415 | break; |
400 | case 'I': /* Server IP-address */ | 416 | case 'I': /* Server IP-address */ |
401 | server_address = strdup (optarg); | 417 | server_address = strdup (optarg); |
@@ -550,9 +566,12 @@ process_arguments (int argc, char **argv) | |||
550 | if (http_method == NULL) | 566 | if (http_method == NULL) |
551 | http_method = strdup ("GET"); | 567 | http_method = strdup ("GET"); |
552 | 568 | ||
553 | if (client_cert && !client_privkey) | 569 | if (client_cert && !client_privkey) |
554 | usage4 (_("If you use a client certificate you must also specify a private key file")); | 570 | usage4 (_("If you use a client certificate you must also specify a private key file")); |
555 | 571 | ||
572 | if (virtual_port == 0) | ||
573 | virtual_port = server_port; | ||
574 | |||
556 | return TRUE; | 575 | return TRUE; |
557 | } | 576 | } |
558 | 577 | ||
@@ -958,13 +977,13 @@ check_http (void) | |||
958 | * 14.23). Some server applications/configurations cause trouble if the | 977 | * 14.23). Some server applications/configurations cause trouble if the |
959 | * (default) port is explicitly specified in the "Host:" header line. | 978 | * (default) port is explicitly specified in the "Host:" header line. |
960 | */ | 979 | */ |
961 | if ((use_ssl == FALSE && server_port == HTTP_PORT) || | 980 | if ((use_ssl == FALSE && virtual_port == HTTP_PORT) || |
962 | (use_ssl == TRUE && server_port == HTTPS_PORT) || | 981 | (use_ssl == TRUE && virtual_port == HTTPS_PORT) || |
963 | (server_address != NULL && strcmp(http_method, "CONNECT") == 0 | 982 | (server_address != NULL && strcmp(http_method, "CONNECT") == 0 |
964 | && host_name != NULL && use_ssl == TRUE)) | 983 | && host_name != NULL && use_ssl == TRUE)) |
965 | xasprintf (&buf, "%sHost: %s\r\n", buf, host_name); | 984 | xasprintf (&buf, "%sHost: %s\r\n", buf, host_name); |
966 | else | 985 | else |
967 | xasprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, server_port); | 986 | xasprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, virtual_port); |
968 | } | 987 | } |
969 | } | 988 | } |
970 | 989 | ||
@@ -1425,6 +1444,9 @@ redir (char *pos, char *status_line) | |||
1425 | MAX_PORT, server_type, server_address, server_port, server_url, | 1444 | MAX_PORT, server_type, server_address, server_port, server_url, |
1426 | display_html ? "</A>" : ""); | 1445 | display_html ? "</A>" : ""); |
1427 | 1446 | ||
1447 | /* reset virtual port */ | ||
1448 | virtual_port = server_port; | ||
1449 | |||
1428 | if (verbose) | 1450 | if (verbose) |
1429 | printf (_("Redirection to %s://%s:%d%s\n"), server_type, | 1451 | printf (_("Redirection to %s://%s:%d%s\n"), server_type, |
1430 | host_name ? host_name : server_address, server_port, server_url); | 1452 | host_name ? host_name : server_address, server_port, server_url); |
diff --git a/plugins/check_ide_smart.c b/plugins/check_ide_smart.c index 8d540ca1..46621318 100644 --- a/plugins/check_ide_smart.c +++ b/plugins/check_ide_smart.c | |||
@@ -166,7 +166,6 @@ enum SmartCommand | |||
166 | 166 | ||
167 | char *get_offline_text (int); | 167 | char *get_offline_text (int); |
168 | int smart_read_values (int, values_t *); | 168 | int smart_read_values (int, values_t *); |
169 | int values_not_passed (values_t *, thresholds_t *); | ||
170 | int nagios (values_t *, thresholds_t *); | 169 | int nagios (values_t *, thresholds_t *); |
171 | void print_value (value_t *, threshold_t *); | 170 | void print_value (value_t *, threshold_t *); |
172 | void print_values (values_t *, thresholds_t *); | 171 | void print_values (values_t *, thresholds_t *); |
@@ -340,31 +339,6 @@ smart_read_values (int fd, values_t * values) | |||
340 | 339 | ||
341 | 340 | ||
342 | int | 341 | int |
343 | values_not_passed (values_t * p, thresholds_t * t) | ||
344 | { | ||
345 | value_t * value = p->values; | ||
346 | threshold_t * threshold = t->thresholds; | ||
347 | int failed = 0; | ||
348 | int passed = 0; | ||
349 | int i; | ||
350 | for (i = 0; i < NR_ATTRIBUTES; i++) { | ||
351 | if (value->id && threshold->id && value->id == threshold->id) { | ||
352 | if (value->value < threshold->threshold) { | ||
353 | ++failed; | ||
354 | } | ||
355 | else { | ||
356 | ++passed; | ||
357 | } | ||
358 | } | ||
359 | ++value; | ||
360 | ++threshold; | ||
361 | } | ||
362 | return (passed ? -failed : 2); | ||
363 | } | ||
364 | |||
365 | |||
366 | |||
367 | int | ||
368 | nagios (values_t * p, thresholds_t * t) | 342 | nagios (values_t * p, thresholds_t * t) |
369 | { | 343 | { |
370 | value_t * value = p->values; | 344 | value_t * value = p->values; |
diff --git a/plugins/check_load.c b/plugins/check_load.c index a96435f4..b1cc498f 100644 --- a/plugins/check_load.c +++ b/plugins/check_load.c | |||
@@ -160,7 +160,7 @@ main (int argc, char **argv) | |||
160 | sscanf (input_buffer, "%*[^l]load averages: %lf, %lf, %lf", &la1, &la5, &la15); | 160 | sscanf (input_buffer, "%*[^l]load averages: %lf, %lf, %lf", &la1, &la5, &la15); |
161 | } | 161 | } |
162 | else { | 162 | else { |
163 | printf (_("could not parse load from uptime: %s\n"), result, PATH_TO_UPTIME); | 163 | printf (_("could not parse load from uptime %s: %s\n"), PATH_TO_UPTIME, result); |
164 | return STATE_UNKNOWN; | 164 | return STATE_UNKNOWN; |
165 | } | 165 | } |
166 | 166 | ||
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c index 75efc289..5ac6c65b 100644 --- a/plugins/check_ntp.c +++ b/plugins/check_ntp.c | |||
@@ -297,7 +297,7 @@ void setup_request(ntp_message *p){ | |||
297 | * this is done by filtering servers based on stratum, dispersion, and | 297 | * this is done by filtering servers based on stratum, dispersion, and |
298 | * finally round-trip delay. */ | 298 | * finally round-trip delay. */ |
299 | int best_offset_server(const ntp_server_results *slist, int nservers){ | 299 | int best_offset_server(const ntp_server_results *slist, int nservers){ |
300 | int i=0, cserver=0, best_server=-1; | 300 | int cserver=0, best_server=-1; |
301 | 301 | ||
302 | /* for each server */ | 302 | /* for each server */ |
303 | for(cserver=0; cserver<nservers; cserver++){ | 303 | for(cserver=0; cserver<nservers; cserver++){ |
@@ -356,7 +356,7 @@ int best_offset_server(const ntp_server_results *slist, int nservers){ | |||
356 | * we have to do it in a way that our lazy macros don't handle currently :( */ | 356 | * we have to do it in a way that our lazy macros don't handle currently :( */ |
357 | double offset_request(const char *host, int *status){ | 357 | double offset_request(const char *host, int *status){ |
358 | int i=0, j=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0; | 358 | int i=0, j=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0; |
359 | int servers_completed=0, one_written=0, one_read=0, servers_readable=0, best_index=-1; | 359 | int servers_completed=0, one_read=0, servers_readable=0, best_index=-1; |
360 | time_t now_time=0, start_ts=0; | 360 | time_t now_time=0, start_ts=0; |
361 | ntp_message *req=NULL; | 361 | ntp_message *req=NULL; |
362 | double avg_offset=0.; | 362 | double avg_offset=0.; |
@@ -421,7 +421,6 @@ double offset_request(const char *host, int *status){ | |||
421 | * been touched in the past second or so and is still lacking | 421 | * been touched in the past second or so and is still lacking |
422 | * some responses. for each of these servers, send a new request, | 422 | * some responses. for each of these servers, send a new request, |
423 | * and update the "waiting" timestamp with the current time. */ | 423 | * and update the "waiting" timestamp with the current time. */ |
424 | one_written=0; | ||
425 | now_time=time(NULL); | 424 | now_time=time(NULL); |
426 | 425 | ||
427 | for(i=0; i<num_hosts; i++){ | 426 | for(i=0; i<num_hosts; i++){ |
@@ -431,7 +430,6 @@ double offset_request(const char *host, int *status){ | |||
431 | setup_request(&req[i]); | 430 | setup_request(&req[i]); |
432 | write(socklist[i], &req[i], sizeof(ntp_message)); | 431 | write(socklist[i], &req[i], sizeof(ntp_message)); |
433 | servers[i].waiting=now_time; | 432 | servers[i].waiting=now_time; |
434 | one_written=1; | ||
435 | break; | 433 | break; |
436 | } | 434 | } |
437 | } | 435 | } |
diff --git a/plugins/check_ntp_time.c b/plugins/check_ntp_time.c index 295f86f6..1cc8cbfb 100644 --- a/plugins/check_ntp_time.c +++ b/plugins/check_ntp_time.c | |||
@@ -244,7 +244,7 @@ void setup_request(ntp_message *p){ | |||
244 | * this is done by filtering servers based on stratum, dispersion, and | 244 | * this is done by filtering servers based on stratum, dispersion, and |
245 | * finally round-trip delay. */ | 245 | * finally round-trip delay. */ |
246 | int best_offset_server(const ntp_server_results *slist, int nservers){ | 246 | int best_offset_server(const ntp_server_results *slist, int nservers){ |
247 | int i=0, cserver=0, best_server=-1; | 247 | int cserver=0, best_server=-1; |
248 | 248 | ||
249 | /* for each server */ | 249 | /* for each server */ |
250 | for(cserver=0; cserver<nservers; cserver++){ | 250 | for(cserver=0; cserver<nservers; cserver++){ |
@@ -303,7 +303,7 @@ int best_offset_server(const ntp_server_results *slist, int nservers){ | |||
303 | * we have to do it in a way that our lazy macros don't handle currently :( */ | 303 | * we have to do it in a way that our lazy macros don't handle currently :( */ |
304 | double offset_request(const char *host, int *status){ | 304 | double offset_request(const char *host, int *status){ |
305 | int i=0, j=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0; | 305 | int i=0, j=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0; |
306 | int servers_completed=0, one_written=0, one_read=0, servers_readable=0, best_index=-1; | 306 | int servers_completed=0, one_read=0, servers_readable=0, best_index=-1; |
307 | time_t now_time=0, start_ts=0; | 307 | time_t now_time=0, start_ts=0; |
308 | ntp_message *req=NULL; | 308 | ntp_message *req=NULL; |
309 | double avg_offset=0.; | 309 | double avg_offset=0.; |
@@ -368,7 +368,6 @@ double offset_request(const char *host, int *status){ | |||
368 | * been touched in the past second or so and is still lacking | 368 | * been touched in the past second or so and is still lacking |
369 | * some responses. For each of these servers, send a new request, | 369 | * some responses. For each of these servers, send a new request, |
370 | * and update the "waiting" timestamp with the current time. */ | 370 | * and update the "waiting" timestamp with the current time. */ |
371 | one_written=0; | ||
372 | now_time=time(NULL); | 371 | now_time=time(NULL); |
373 | 372 | ||
374 | for(i=0; i<num_hosts; i++){ | 373 | for(i=0; i<num_hosts; i++){ |
@@ -378,7 +377,6 @@ double offset_request(const char *host, int *status){ | |||
378 | setup_request(&req[i]); | 377 | setup_request(&req[i]); |
379 | write(socklist[i], &req[i], sizeof(ntp_message)); | 378 | write(socklist[i], &req[i], sizeof(ntp_message)); |
380 | servers[i].waiting=now_time; | 379 | servers[i].waiting=now_time; |
381 | one_written=1; | ||
382 | break; | 380 | break; |
383 | } | 381 | } |
384 | } | 382 | } |
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 9839d6e8..da9638c4 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
@@ -152,7 +152,7 @@ state_data *previous_state; | |||
152 | double *previous_value; | 152 | double *previous_value; |
153 | size_t previous_size = OID_COUNT_STEP; | 153 | size_t previous_size = OID_COUNT_STEP; |
154 | int perf_labels = 1; | 154 | int perf_labels = 1; |
155 | 155 | char* ip_version = ""; | |
156 | 156 | ||
157 | static char *fix_snmp_range(char *th) | 157 | static char *fix_snmp_range(char *th) |
158 | { | 158 | { |
@@ -680,6 +680,8 @@ process_arguments (int argc, char **argv) | |||
680 | {"offset", required_argument, 0, L_OFFSET}, | 680 | {"offset", required_argument, 0, L_OFFSET}, |
681 | {"invert-search", no_argument, 0, L_INVERT_SEARCH}, | 681 | {"invert-search", no_argument, 0, L_INVERT_SEARCH}, |
682 | {"perf-oids", no_argument, 0, 'O'}, | 682 | {"perf-oids", no_argument, 0, 'O'}, |
683 | {"ipv4", no_argument, 0, '4'}, | ||
684 | {"ipv6", no_argument, 0, '6'}, | ||
683 | {0, 0, 0, 0} | 685 | {0, 0, 0, 0} |
684 | }; | 686 | }; |
685 | 687 | ||
@@ -697,7 +699,7 @@ process_arguments (int argc, char **argv) | |||
697 | } | 699 | } |
698 | 700 | ||
699 | while (1) { | 701 | while (1) { |
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:", | 702 | c = getopt_long (argc, argv, "nhvVO46t: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:", |
701 | longopts, &option); | 703 | longopts, &option); |
702 | 704 | ||
703 | if (c == -1 || c == EOF) | 705 | if (c == -1 || c == EOF) |
@@ -922,6 +924,13 @@ process_arguments (int argc, char **argv) | |||
922 | case 'O': | 924 | case 'O': |
923 | perf_labels=0; | 925 | perf_labels=0; |
924 | break; | 926 | break; |
927 | case '4': | ||
928 | break; | ||
929 | case '6': | ||
930 | xasprintf(&ip_version, "udp6:"); | ||
931 | if(verbose>2) | ||
932 | printf("IPv6 detected! Will pass \"udp6:\" to snmpget.\n"); | ||
933 | break; | ||
925 | } | 934 | } |
926 | } | 935 | } |
927 | 936 | ||
@@ -1127,6 +1136,7 @@ print_help (void) | |||
1127 | 1136 | ||
1128 | printf (UT_HELP_VRSN); | 1137 | printf (UT_HELP_VRSN); |
1129 | printf (UT_EXTRA_OPTS); | 1138 | printf (UT_EXTRA_OPTS); |
1139 | printf (UT_IPv46); | ||
1130 | 1140 | ||
1131 | printf (UT_HOST_PORT, 'p', DEFAULT_PORT); | 1141 | printf (UT_HOST_PORT, 'p', DEFAULT_PORT); |
1132 | 1142 | ||
@@ -1245,5 +1255,5 @@ print_usage (void) | |||
1245 | printf ("[-C community] [-s string] [-r regex] [-R regexi] [-t timeout] [-e retries]\n"); | 1255 | printf ("[-C community] [-s string] [-r regex] [-R regexi] [-t timeout] [-e retries]\n"); |
1246 | printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n"); | 1256 | printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n"); |
1247 | printf ("[-m miblist] [-P snmp version] [-N context] [-L seclevel] [-U secname]\n"); | 1257 | printf ("[-m miblist] [-P snmp version] [-N context] [-L seclevel] [-U secname]\n"); |
1248 | printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd]\n"); | 1258 | printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd] [-4|6]\n"); |
1249 | } | 1259 | } |
diff --git a/plugins/check_users.c b/plugins/check_users.c index 54415a48..f6f4b362 100644 --- a/plugins/check_users.c +++ b/plugins/check_users.c | |||
@@ -54,15 +54,15 @@ int process_arguments (int, char **); | |||
54 | void print_help (void); | 54 | void print_help (void); |
55 | void print_usage (void); | 55 | void print_usage (void); |
56 | 56 | ||
57 | int wusers = -1; | 57 | char *warning_range = NULL; |
58 | int cusers = -1; | 58 | char *critical_range = NULL; |
59 | thresholds *thlds = NULL; | ||
59 | 60 | ||
60 | int | 61 | int |
61 | main (int argc, char **argv) | 62 | main (int argc, char **argv) |
62 | { | 63 | { |
63 | int users = -1; | 64 | int users = -1; |
64 | int result = STATE_UNKNOWN; | 65 | int result = STATE_UNKNOWN; |
65 | char *perf; | ||
66 | #if HAVE_WTSAPI32_H | 66 | #if HAVE_WTSAPI32_H |
67 | WTS_SESSION_INFO *wtsinfo; | 67 | WTS_SESSION_INFO *wtsinfo; |
68 | DWORD wtscount; | 68 | DWORD wtscount; |
@@ -77,8 +77,6 @@ main (int argc, char **argv) | |||
77 | bindtextdomain (PACKAGE, LOCALEDIR); | 77 | bindtextdomain (PACKAGE, LOCALEDIR); |
78 | textdomain (PACKAGE); | 78 | textdomain (PACKAGE); |
79 | 79 | ||
80 | perf = strdup (""); | ||
81 | |||
82 | /* Parse extra opts if any */ | 80 | /* Parse extra opts if any */ |
83 | argv = np_extra_opts (&argc, argv, progname); | 81 | argv = np_extra_opts (&argc, argv, progname); |
84 | 82 | ||
@@ -160,23 +158,15 @@ main (int argc, char **argv) | |||
160 | #endif | 158 | #endif |
161 | 159 | ||
162 | /* check the user count against warning and critical thresholds */ | 160 | /* check the user count against warning and critical thresholds */ |
163 | if (users > cusers) | 161 | result = get_status((double)users, thlds); |
164 | result = STATE_CRITICAL; | ||
165 | else if (users > wusers) | ||
166 | result = STATE_WARNING; | ||
167 | else if (users >= 0) | ||
168 | result = STATE_OK; | ||
169 | 162 | ||
170 | if (result == STATE_UNKNOWN) | 163 | if (result == STATE_UNKNOWN) |
171 | printf ("%s\n", _("Unable to read output")); | 164 | printf ("%s\n", _("Unable to read output")); |
172 | else { | 165 | else { |
173 | xasprintf (&perf, "%s", perfdata ("users", users, "", | 166 | printf (_("USERS %s - %d users currently logged in |%s\n"), |
174 | TRUE, wusers, | 167 | state_text(result), users, |
175 | TRUE, cusers, | 168 | sperfdata_int("users", users, "", warning_range, |
176 | TRUE, 0, | 169 | critical_range, TRUE, 0, FALSE, 0)); |
177 | FALSE, 0)); | ||
178 | printf (_("USERS %s - %d users currently logged in |%s\n"), state_text (result), | ||
179 | users, perf); | ||
180 | } | 170 | } |
181 | 171 | ||
182 | return result; | 172 | return result; |
@@ -215,33 +205,27 @@ process_arguments (int argc, char **argv) | |||
215 | print_revision (progname, NP_VERSION); | 205 | print_revision (progname, NP_VERSION); |
216 | exit (STATE_UNKNOWN); | 206 | exit (STATE_UNKNOWN); |
217 | case 'c': /* critical */ | 207 | case 'c': /* critical */ |
218 | if (!is_intnonneg (optarg)) | 208 | critical_range = optarg; |
219 | usage4 (_("Critical threshold must be a positive integer")); | ||
220 | else | ||
221 | cusers = atoi (optarg); | ||
222 | break; | 209 | break; |
223 | case 'w': /* warning */ | 210 | case 'w': /* warning */ |
224 | if (!is_intnonneg (optarg)) | 211 | warning_range = optarg; |
225 | usage4 (_("Warning threshold must be a positive integer")); | ||
226 | else | ||
227 | wusers = atoi (optarg); | ||
228 | break; | 212 | break; |
229 | } | 213 | } |
230 | } | 214 | } |
231 | 215 | ||
232 | c = optind; | 216 | c = optind; |
233 | if (wusers == -1 && argc > c) { | 217 | if (warning_range == NULL && argc > c) |
234 | if (is_intnonneg (argv[c]) == FALSE) | 218 | warning_range = argv[c++]; |
235 | usage4 (_("Warning threshold must be a positive integer")); | 219 | if (critical_range == NULL && argc > c) |
236 | else | 220 | critical_range = argv[c++]; |
237 | wusers = atoi (argv[c++]); | 221 | |
238 | } | 222 | /* this will abort in case of invalid ranges */ |
239 | if (cusers == -1 && argc > c) { | 223 | set_thresholds (&thlds, warning_range, critical_range); |
240 | if (is_intnonneg (argv[c]) == FALSE) | 224 | |
241 | usage4 (_("Warning threshold must be a positive integer")); | 225 | if (thlds->warning->end < 0) |
242 | else | 226 | usage4 (_("Warning threshold must be a positive integer")); |
243 | cusers = atoi (argv[c]); | 227 | if (thlds->critical->end < 0) |
244 | } | 228 | usage4 (_("Critical threshold must be a positive integer")); |
245 | 229 | ||
246 | return OK; | 230 | return OK; |
247 | } | 231 | } |
diff --git a/plugins/negate.c b/plugins/negate.c index beaed1ea..b320e356 100644 --- a/plugins/negate.c +++ b/plugins/negate.c | |||
@@ -59,8 +59,8 @@ static int state[4] = { | |||
59 | int | 59 | int |
60 | main (int argc, char **argv) | 60 | main (int argc, char **argv) |
61 | { | 61 | { |
62 | int found = 0, result = STATE_UNKNOWN; | 62 | int result = STATE_UNKNOWN; |
63 | char *buf, *sub; | 63 | char *sub; |
64 | char **command_line; | 64 | char **command_line; |
65 | output chld_out, chld_err; | 65 | output chld_out, chld_err; |
66 | int i; | 66 | int i; |
diff --git a/plugins/sslutils.c b/plugins/sslutils.c index 4f9c793c..b412ef3d 100644 --- a/plugins/sslutils.c +++ b/plugins/sslutils.c | |||
@@ -197,6 +197,7 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){ | |||
197 | X509_NAME *subj=NULL; | 197 | X509_NAME *subj=NULL; |
198 | char timestamp[50] = ""; | 198 | char timestamp[50] = ""; |
199 | char cn[MAX_CN_LENGTH]= ""; | 199 | char cn[MAX_CN_LENGTH]= ""; |
200 | char *tz; | ||
200 | 201 | ||
201 | int cnlen =-1; | 202 | int cnlen =-1; |
202 | int status=STATE_UNKNOWN; | 203 | int status=STATE_UNKNOWN; |
@@ -264,10 +265,18 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){ | |||
264 | (tm->data[10 + offset] - '0') * 10 + (tm->data[11 + offset] - '0'); | 265 | (tm->data[10 + offset] - '0') * 10 + (tm->data[11 + offset] - '0'); |
265 | stamp.tm_isdst = -1; | 266 | stamp.tm_isdst = -1; |
266 | 267 | ||
267 | time_left = difftime(timegm(&stamp), time(NULL)); | 268 | tm_t = timegm(&stamp); |
269 | time_left = difftime(tm_t, time(NULL)); | ||
268 | days_left = time_left / 86400; | 270 | days_left = time_left / 86400; |
269 | tm_t = mktime (&stamp); | 271 | tz = getenv("TZ"); |
270 | strftime(timestamp, 50, "%c", localtime(&tm_t)); | 272 | setenv("TZ", "GMT", 1); |
273 | tzset(); | ||
274 | strftime(timestamp, 50, "%c %z", localtime(&tm_t)); | ||
275 | if (tz) | ||
276 | setenv("TZ", tz, 1); | ||
277 | else | ||
278 | unsetenv("TZ"); | ||
279 | tzset(); | ||
271 | 280 | ||
272 | if (days_left > 0 && days_left <= days_till_exp_warn) { | 281 | if (days_left > 0 && days_left <= days_till_exp_warn) { |
273 | printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, days_left, timestamp); | 282 | printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, days_left, timestamp); |
diff --git a/plugins/t/NPTest.cache.travis b/plugins/t/NPTest.cache.travis index fe8aabdb..5d9c5ff7 100644 --- a/plugins/t/NPTest.cache.travis +++ b/plugins/t/NPTest.cache.travis | |||
@@ -11,7 +11,7 @@ | |||
11 | 'NP_HOST_NONRESPONSIVE' => '10.0.0.1', | 11 | 'NP_HOST_NONRESPONSIVE' => '10.0.0.1', |
12 | 'NP_HOST_RESPONSIVE' => 'localhost', | 12 | 'NP_HOST_RESPONSIVE' => 'localhost', |
13 | 'NP_HOST_SMB' => '', | 13 | 'NP_HOST_SMB' => '', |
14 | 'NP_HOST_SNMP' => '', | 14 | 'NP_HOST_SNMP' => 'localhost', |
15 | 'NP_HOST_TCP_FTP' => '', | 15 | 'NP_HOST_TCP_FTP' => '', |
16 | 'NP_HOST_TCP_HPJD' => '', | 16 | 'NP_HOST_TCP_HPJD' => '', |
17 | 'NP_HOST_HPJD_PORT_INVALID' => '161', | 17 | 'NP_HOST_HPJD_PORT_INVALID' => '161', |
@@ -39,7 +39,7 @@ | |||
39 | 'NP_SMB_SHARE_SPC' => '', | 39 | 'NP_SMB_SHARE_SPC' => '', |
40 | 'NP_SMB_VALID_USER' => '', | 40 | 'NP_SMB_VALID_USER' => '', |
41 | 'NP_SMB_VALID_USER_PASS' => '', | 41 | 'NP_SMB_VALID_USER_PASS' => '', |
42 | 'NP_SNMP_COMMUNITY' => '', | 42 | 'NP_SNMP_COMMUNITY' => 'public', |
43 | 'NP_SSH_CONFIGFILE' => '~/.ssh/config', | 43 | 'NP_SSH_CONFIGFILE' => '~/.ssh/config', |
44 | 'NP_SSH_HOST' => 'localhost', | 44 | 'NP_SSH_HOST' => 'localhost', |
45 | 'NP_SSH_IDENTITY' => '~/.ssh/id_dsa', | 45 | 'NP_SSH_IDENTITY' => '~/.ssh/id_dsa', |
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t index c2caec60..5a90f02a 100644 --- a/plugins/t/check_http.t +++ b/plugins/t/check_http.t | |||
@@ -9,7 +9,7 @@ use Test::More; | |||
9 | use POSIX qw/mktime strftime/; | 9 | use POSIX qw/mktime strftime/; |
10 | use NPTest; | 10 | use NPTest; |
11 | 11 | ||
12 | plan tests => 42; | 12 | plan tests => 49; |
13 | 13 | ||
14 | my $successOutput = '/OK.*HTTP.*second/'; | 14 | my $successOutput = '/OK.*HTTP.*second/'; |
15 | 15 | ||
@@ -64,6 +64,32 @@ cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" ); | |||
64 | # Is also possible to get a socket timeout if DNS is not responding fast enough | 64 | # Is also possible to get a socket timeout if DNS is not responding fast enough |
65 | like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK"); | 65 | like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK"); |
66 | 66 | ||
67 | # host header checks | ||
68 | $res = NPTest->testCmd("./check_http -v -H $host_tcp_http"); | ||
69 | like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" ); | ||
70 | |||
71 | $res = NPTest->testCmd("./check_http -v -H $host_tcp_http -p 80"); | ||
72 | like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" ); | ||
73 | |||
74 | $res = NPTest->testCmd("./check_http -v -H $host_tcp_http:8080 -p 80"); | ||
75 | like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" ); | ||
76 | |||
77 | $res = NPTest->testCmd("./check_http -v -H $host_tcp_http:8080 -p 80"); | ||
78 | like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" ); | ||
79 | |||
80 | SKIP: { | ||
81 | skip "No internet access", 3 if $internet_access eq "no"; | ||
82 | |||
83 | $res = NPTest->testCmd("./check_http -v -H www.verisign.com -S"); | ||
84 | like( $res->output, '/^Host: www.verisign.com\s*$/ms', "Host Header OK" ); | ||
85 | |||
86 | $res = NPTest->testCmd("./check_http -v -H www.verisign.com:8080 -S -p 443"); | ||
87 | like( $res->output, '/^Host: www.verisign.com:8080\s*$/ms', "Host Header OK" ); | ||
88 | |||
89 | $res = NPTest->testCmd("./check_http -v -H www.verisign.com:443 -S -p 443"); | ||
90 | like( $res->output, '/^Host: www.verisign.com\s*$/ms', "Host Header OK" ); | ||
91 | }; | ||
92 | |||
67 | SKIP: { | 93 | SKIP: { |
68 | skip "No host serving monitoring in index file", 7 unless $host_tcp_http2; | 94 | skip "No host serving monitoring in index file", 7 unless $host_tcp_http2; |
69 | 95 | ||
@@ -121,9 +147,9 @@ SKIP: { | |||
121 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC ./check_http -C 1 www.verisign.com"); | 147 | $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"); | 148 | 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" ); | 149 | 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+)\./); | 150 | my($mon,$day,$hour,$min,$sec,$year) = ($res->output =~ /(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)/); |
125 | if(!defined $year) { | 151 | if(!defined $year) { |
126 | die("parsing date failed from: ".$res); | 152 | die("parsing date failed from: ".$res->output); |
127 | } | 153 | } |
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}; | 154 | 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); | 155 | my $ts = mktime($sec, $min, $hour, $day, $months->{$mon}, $year-1900); |
@@ -154,7 +180,7 @@ SKIP: { | |||
154 | like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); | 180 | like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); |
155 | 181 | ||
156 | $res = NPTest->testCmd( | 182 | $res = NPTest->testCmd( |
157 | "./check_http --ssl www.e-paycobalt.com" | 183 | "./check_http --ssl -H www.e-paycobalt.com" |
158 | ); | 184 | ); |
159 | cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" ); | 185 | cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" ); |
160 | 186 | ||
diff --git a/plugins/t/check_snmp.t b/plugins/t/check_snmp.t index aefd872a..eff46ea1 100644 --- a/plugins/t/check_snmp.t +++ b/plugins/t/check_snmp.t | |||
@@ -10,7 +10,7 @@ use NPTest; | |||
10 | 10 | ||
11 | BEGIN { | 11 | BEGIN { |
12 | plan skip_all => 'check_snmp is not compiled' unless -x "./check_snmp"; | 12 | plan skip_all => 'check_snmp is not compiled' unless -x "./check_snmp"; |
13 | plan tests => 61; | 13 | plan tests => 63; |
14 | } | 14 | } |
15 | 15 | ||
16 | my $res; | 16 | my $res; |
@@ -45,7 +45,7 @@ is( $res->return_code, 3, "Invalid protocol" ); | |||
45 | like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" ); | 45 | like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" ); |
46 | 46 | ||
47 | SKIP: { | 47 | SKIP: { |
48 | skip "no snmp host defined", 48 if ( ! $host_snmp ); | 48 | skip "no snmp host defined", 50 if ( ! $host_snmp ); |
49 | 49 | ||
50 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:"); | 50 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:"); |
51 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying uptime" ); | 51 | cmp_ok( $res->return_code, '==', 0, "Exit OK when querying uptime" ); |
@@ -153,6 +153,10 @@ SKIP: { | |||
153 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0"); | 153 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0"); |
154 | cmp_ok( $res->return_code, '==', 0, "Timetick used as a string"); | 154 | cmp_ok( $res->return_code, '==', 0, "Timetick used as a string"); |
155 | like($res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "Timetick used as a string, result printed rather than parsed"); | 155 | like($res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "Timetick used as a string, result printed rather than parsed"); |
156 | |||
157 | $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o HOST-RESOURCES-MIB::hrSWRunParameters.1"); | ||
158 | cmp_ok( $res->return_code, '==', 0, "Timetick used as a string"); | ||
159 | is( $res->output, 'SNMP OK - "" | ', "snmp response without datatype" ); | ||
156 | } | 160 | } |
157 | 161 | ||
158 | SKIP: { | 162 | SKIP: { |
diff --git a/plugins/t/check_users.t b/plugins/t/check_users.t index 39044bb5..088f3b52 100644 --- a/plugins/t/check_users.t +++ b/plugins/t/check_users.t | |||
@@ -13,7 +13,7 @@ use Test; | |||
13 | use NPTest; | 13 | use NPTest; |
14 | 14 | ||
15 | use vars qw($tests); | 15 | use vars qw($tests); |
16 | BEGIN {$tests = 4; plan tests => $tests} | 16 | BEGIN {$tests = 8; plan tests => $tests} |
17 | 17 | ||
18 | my $successOutput = '/^USERS OK - [0-9]+ users currently logged in/'; | 18 | my $successOutput = '/^USERS OK - [0-9]+ users currently logged in/'; |
19 | my $failureOutput = '/^USERS CRITICAL - [0-9]+ users currently logged in/'; | 19 | my $failureOutput = '/^USERS CRITICAL - [0-9]+ users currently logged in/'; |
@@ -22,6 +22,8 @@ my $t; | |||
22 | 22 | ||
23 | $t += checkCmd( "./check_users 1000 1000", 0, $successOutput ); | 23 | $t += checkCmd( "./check_users 1000 1000", 0, $successOutput ); |
24 | $t += checkCmd( "./check_users 0 0", 2, $failureOutput ); | 24 | $t += checkCmd( "./check_users 0 0", 2, $failureOutput ); |
25 | $t += checkCmd( "./check_users -w 0:1000 -c 0:1000", 0, $successOutput ); | ||
26 | $t += checkCmd( "./check_users -w 0:0 -c 0:0", 2, $failureOutput ); | ||
25 | 27 | ||
26 | exit(0) if defined($Test::Harness::VERSION); | 28 | exit(0) if defined($Test::Harness::VERSION); |
27 | exit($tests - $t); | 29 | exit($tests - $t); |
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t index e72d243a..1bc0ecb7 100755 --- a/plugins/tests/check_http.t +++ b/plugins/tests/check_http.t | |||
@@ -17,6 +17,8 @@ use Test::More; | |||
17 | use NPTest; | 17 | use NPTest; |
18 | use FindBin qw($Bin); | 18 | use FindBin qw($Bin); |
19 | 19 | ||
20 | $ENV{'LC_TIME'} = "C"; | ||
21 | |||
20 | my $common_tests = 70; | 22 | my $common_tests = 70; |
21 | my $ssl_only_tests = 8; | 23 | my $ssl_only_tests = 8; |
22 | # Check that all dependent modules are available | 24 | # Check that all dependent modules are available |
@@ -186,21 +188,21 @@ SKIP: { | |||
186 | 188 | ||
187 | $result = NPTest->testCmd( "$command -p $port_https -S -C 14" ); | 189 | $result = NPTest->testCmd( "$command -p $port_https -S -C 14" ); |
188 | is( $result->return_code, 0, "$command -p $port_https -S -C 14" ); | 190 | 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:28 2019.', "output ok" ); | 191 | is( $result->output, 'OK - Certificate \'Ton Voon\' will expire on Sun Mar 3 21:41:28 2019 +0000.', "output ok" ); |
190 | 192 | ||
191 | $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" ); | 193 | $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" ); |
192 | is( $result->return_code, 1, "$command -p $port_https -S -C 14000" ); | 194 | 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:28 2019\)./', "output ok" ); | 195 | like( $result->output, '/WARNING - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:28 2019 \+0000\)./', "output ok" ); |
194 | 196 | ||
195 | # Expired cert tests | 197 | # Expired cert tests |
196 | $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" ); | 198 | $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" ); | 199 | 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:28 2019\)./', "output ok" ); | 200 | like( $result->output, '/CRITICAL - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:28 2019 \+0000\)./', "output ok" ); |
199 | 201 | ||
200 | $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" ); | 202 | $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" ); | 203 | is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" ); |
202 | is( $result->output, | 204 | is( $result->output, |
203 | 'CRITICAL - Certificate \'Ton Voon\' expired on Thu Mar 5 00:13:16 2009.', | 205 | 'CRITICAL - Certificate \'Ton Voon\' expired on Thu Mar 5 00:13:16 2009 +0000.', |
204 | "output ok" ); | 206 | "output ok" ); |
205 | 207 | ||
206 | } | 208 | } |
diff --git a/plugins/utils.c b/plugins/utils.c index a864e4aa..231af92b 100644 --- a/plugins/utils.c +++ b/plugins/utils.c | |||
@@ -668,3 +668,44 @@ char *sperfdata (const char *label, | |||
668 | 668 | ||
669 | return data; | 669 | return data; |
670 | } | 670 | } |
671 | |||
672 | char *sperfdata_int (const char *label, | ||
673 | int val, | ||
674 | const char *uom, | ||
675 | char *warn, | ||
676 | char *crit, | ||
677 | int minp, | ||
678 | int minv, | ||
679 | int maxp, | ||
680 | int maxv) | ||
681 | { | ||
682 | char *data = NULL; | ||
683 | if (strpbrk (label, "'= ")) | ||
684 | xasprintf (&data, "'%s'=", label); | ||
685 | else | ||
686 | xasprintf (&data, "%s=", label); | ||
687 | |||
688 | xasprintf (&data, "%s%d", data, val); | ||
689 | xasprintf (&data, "%s%s;", data, uom); | ||
690 | |||
691 | if (warn!=NULL) | ||
692 | xasprintf (&data, "%s%s", data, warn); | ||
693 | |||
694 | xasprintf (&data, "%s;", data); | ||
695 | |||
696 | if (crit!=NULL) | ||
697 | xasprintf (&data, "%s%s", data, crit); | ||
698 | |||
699 | xasprintf (&data, "%s;", data); | ||
700 | |||
701 | if (minp) | ||
702 | xasprintf (&data, "%s%d", data, minv); | ||
703 | |||
704 | if (maxp) { | ||
705 | xasprintf (&data, "%s;", data); | ||
706 | xasprintf (&data, "%s%d", data, maxv); | ||
707 | } | ||
708 | |||
709 | return data; | ||
710 | } | ||
711 | |||
diff --git a/plugins/utils.h b/plugins/utils.h index 4c4aaccc..a436e1ca 100644 --- a/plugins/utils.h +++ b/plugins/utils.h | |||
@@ -94,29 +94,17 @@ const char *state_text (int); | |||
94 | #define max(a,b) (((a)>(b))?(a):(b)) | 94 | #define max(a,b) (((a)>(b))?(a):(b)) |
95 | #define min(a,b) (((a)<(b))?(a):(b)) | 95 | #define min(a,b) (((a)<(b))?(a):(b)) |
96 | 96 | ||
97 | char *perfdata (const char *, | 97 | char *perfdata (const char *, long int, const char *, int, long int, |
98 | long int, | 98 | int, long int, int, long int, int, long int); |
99 | const char *, | 99 | |
100 | int, | 100 | char *fperfdata (const char *, double, const char *, int, double, |
101 | long int, | 101 | int, double, int, double, int, double); |
102 | int, | 102 | |
103 | long int, | 103 | char *sperfdata (const char *, double, const char *, char *, char *, |
104 | int, | 104 | int, double, int, double); |
105 | long int, | 105 | |
106 | int, | 106 | char *sperfdata_int (const char *, int, const char *, char *, char *, |
107 | long int); | 107 | int, int, int, int); |
108 | |||
109 | char *fperfdata (const char *, | ||
110 | double, | ||
111 | const char *, | ||
112 | int, | ||
113 | double, | ||
114 | int, | ||
115 | double, | ||
116 | int, | ||
117 | double, | ||
118 | int, | ||
119 | double); | ||
120 | 108 | ||
121 | /* The idea here is that, although not every plugin will use all of these, | 109 | /* The idea here is that, although not every plugin will use all of these, |
122 | most will or should. Therefore, for consistency, these very common | 110 | most will or should. Therefore, for consistency, these very common |