summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--NEWS5
-rw-r--r--REQUIREMENTS12
-rw-r--r--THANKS.in5
-rw-r--r--configure.ac35
-rwxr-xr-xplugins-scripts/check_ifoperstatus.pl2
-rwxr-xr-xplugins-scripts/check_ifstatus.pl2
-rw-r--r--plugins/check_by_ssh.c7
-rw-r--r--plugins/check_dig.c4
-rw-r--r--plugins/check_disk.c9
-rw-r--r--plugins/check_dns.c6
-rw-r--r--plugins/check_http.c46
-rw-r--r--plugins/check_ide_smart.c26
-rw-r--r--plugins/check_load.c2
-rw-r--r--plugins/check_ntp.c6
-rw-r--r--plugins/check_ntp_time.c8
-rw-r--r--plugins/check_radius.c36
-rw-r--r--plugins/check_smtp.c12
-rw-r--r--plugins/check_snmp.c16
-rw-r--r--plugins/check_tcp.c4
-rw-r--r--plugins/check_users.c60
-rw-r--r--plugins/common.h7
-rw-r--r--plugins/negate.c4
-rw-r--r--plugins/netutils.c15
-rw-r--r--plugins/netutils.h7
-rw-r--r--plugins/sslutils.c15
-rw-r--r--plugins/t/NPTest.cache.travis4
-rw-r--r--plugins/t/check_http.t32
-rw-r--r--plugins/t/check_snmp.t8
-rw-r--r--plugins/t/check_users.t4
-rwxr-xr-xplugins/tests/check_http.t10
-rw-r--r--plugins/utils.c41
-rw-r--r--plugins/utils.h34
33 files changed, 289 insertions, 197 deletions
diff --git a/.travis.yml b/.travis.yml
index 29290fd..dcf13d5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -20,7 +20,7 @@ before_install:
20 # - mysql -e "create database IF NOT EXISTS test;" -uroot 20 # - mysql -e "create database IF NOT EXISTS test;" -uroot
21 21
22install: 22install:
23 - 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 23 - sudo apt-get install -qq --no-install-recommends perl autotools-dev libdbi-dev libldap2-dev libpq-dev libmysqlclient-dev libradcli-dev libkrb5-dev libnet-snmp-perl procps
24 - sudo apt-get install -qq --no-install-recommends libdbi0-dev libdbd-sqlite3 libssl-dev dnsutils snmp-mibs-downloader libsnmp-perl snmpd 24 - sudo apt-get install -qq --no-install-recommends libdbi0-dev libdbd-sqlite3 libssl-dev dnsutils snmp-mibs-downloader libsnmp-perl snmpd
25 - sudo apt-get install -qq --no-install-recommends fping snmp netcat smbclient fping pure-ftpd apache2 postfix libhttp-daemon-ssl-perl 25 - sudo apt-get install -qq --no-install-recommends fping snmp netcat smbclient fping pure-ftpd apache2 postfix libhttp-daemon-ssl-perl
26 - sudo apt-get install -qq --no-install-recommends libdbd-sybase-perl libnet-dns-perl 26 - sudo apt-get install -qq --no-install-recommends libdbd-sybase-perl libnet-dns-perl
diff --git a/NEWS b/NEWS
index 2a9ea62..8a8df6a 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,10 @@ 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)
18 check_radius now supports the radcli library
15 19
16 FIXES 20 FIXES
17 Let check_real terminate lines with CRLF when talking to the server, as 21 Let check_real terminate lines with CRLF when talking to the server, as
@@ -19,6 +23,7 @@ This file documents the major additions and syntax changes between releases.
19 Fix check_procs on HP-UX 23 Fix check_procs on HP-UX
20 check_smtp's -e/--expect option can now be combined with -S/--starttls 24 check_smtp's -e/--expect option can now be combined with -S/--starttls
21 Fix incorrect performance data thresholds emitted by check_ups 25 Fix incorrect performance data thresholds emitted by check_ups
26 check_http: fix host header port handling (odenbach)
22 27
23 WARNINGS 28 WARNINGS
24 The format of the performance data emitted by check_mrtgtraf has been 29 The format of the performance data emitted by check_mrtgtraf has been
diff --git a/REQUIREMENTS b/REQUIREMENTS
index 303fd62..ac7b593 100644
--- a/REQUIREMENTS
+++ b/REQUIREMENTS
@@ -50,16 +50,18 @@ check_dbi:
50 http://libdbi.sourceforge.net/ 50 http://libdbi.sourceforge.net/
51 51
52check_radius: 52check_radius:
53 - Requires the FreeRADIUS Client library available from: 53 - Requires the radcli library available from:
54 http://radcli.github.io/radcli/
55 - As an alternative, the FreeRADIUS Client library may be used:
54 http://freeradius.org/freeradius-client/ 56 http://freeradius.org/freeradius-client/
55 - As an alternative, the radiusclient-ng library may be used: 57 - As another alternative, the radiusclient-ng library may be used:
56 http://sourceforge.net/projects/radiusclient-ng.berlios/ 58 http://sourceforge.net/projects/radiusclient-ng.berlios/
57 - This plugin also works with the original radiusclient library from 59 - This plugin also works with the original radiusclient library from
58 ftp://ftp.cityline.net/pub/radiusclient/ 60 ftp://ftp.cityline.net/pub/radiusclient/
59 RPM (rpmfind): radiusclient 0.3.2, radiusclient-devel-0.3.2 61 RPM (rpmfind): radiusclient 0.3.2, radiusclient-devel-0.3.2
60 However, you probably want to use the FreeRADIUS Client library, as 62 However, you probably want to use either radcli or the FreeRADIUS
61 both radiusclient and radiusclient-ng are unmaintained and have known 63 Client library, as both radiusclient and radiusclient-ng are
62 issues. 64 unmaintained and have known issues.
63 65
64check_snmp: 66check_snmp:
65 - Requires the NET-SNMP package available from 67 - Requires the NET-SNMP package available from
diff --git a/THANKS.in b/THANKS.in
index 59c90fe..f48a8bd 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -336,3 +336,8 @@ Nick Peelman
336Sebastian Herbszt 336Sebastian Herbszt
337Christopher Schultz 337Christopher Schultz
338Matthias Hähnel 338Matthias Hähnel
339Roberto Greiner
340Peter (pirtoo)
341ylfingr
342Christian Kujau
343Christopher Odenbach
diff --git a/configure.ac b/configure.ac
index 0a554af..367e82a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -273,26 +273,33 @@ AC_ARG_WITH([radius], [AS_HELP_STRING([--without-radius], [Skips the radius plug
273dnl Check for radius libraries 273dnl Check for radius libraries
274AS_IF([test "x$with_radius" != "xno"], [ 274AS_IF([test "x$with_radius" != "xno"], [
275 _SAVEDLIBS="$LIBS" 275 _SAVEDLIBS="$LIBS"
276 AC_CHECK_LIB(freeradius-client,rc_read_config) 276 AC_CHECK_LIB(radcli,rc_read_config)
277 if test "$ac_cv_lib_freeradius_client_rc_read_config" = "yes"; then 277 if test "$ac_cv_lib_radcli_rc_read_config" = "yes"; then
278 EXTRAS="$EXTRAS check_radius\$(EXEEXT)" 278 EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
279 RADIUSLIBS="-lfreeradius-client" 279 RADIUSLIBS="-lradcli"
280 AC_SUBST(RADIUSLIBS) 280 AC_SUBST(RADIUSLIBS)
281 else 281 else
282 AC_CHECK_LIB(radiusclient-ng,rc_read_config) 282 AC_CHECK_LIB(freeradius-client,rc_read_config)
283 if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then 283 if test "$ac_cv_lib_freeradius_client_rc_read_config" = "yes"; then
284 EXTRAS="$EXTRAS check_radius\$(EXEEXT)" 284 EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
285 RADIUSLIBS="-lradiusclient-ng" 285 RADIUSLIBS="-lfreeradius-client"
286 AC_SUBST(RADIUSLIBS) 286 AC_SUBST(RADIUSLIBS)
287 else 287 else
288 AC_CHECK_LIB(radiusclient,rc_read_config) 288 AC_CHECK_LIB(radiusclient-ng,rc_read_config)
289 if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then 289 if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then
290 EXTRAS="$EXTRAS check_radius\$(EXEEXT)" 290 EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
291 RADIUSLIBS="-lradiusclient" 291 RADIUSLIBS="-lradiusclient-ng"
292 AC_SUBST(RADIUSLIBS) 292 AC_SUBST(RADIUSLIBS)
293 else 293 else
294 AC_MSG_WARN([Skipping radius plugin]) 294 AC_CHECK_LIB(radiusclient,rc_read_config)
295 AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).]) 295 if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
296 EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
297 RADIUSLIBS="-lradiusclient"
298 AC_SUBST(RADIUSLIBS)
299 else
300 AC_MSG_WARN([Skipping radius plugin])
301 AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
302 fi
296 fi 303 fi
297 fi 304 fi
298 fi 305 fi
@@ -493,15 +500,15 @@ if ! test x"$with_openssl" = x"no"; then
493 dnl Check for crypto lib 500 dnl Check for crypto lib
494 _SAVEDLIBS="$LIBS" 501 _SAVEDLIBS="$LIBS"
495 LIBS="-L${with_openssl}/lib" 502 LIBS="-L${with_openssl}/lib"
496 AC_CHECK_LIB(crypto,CRYPTO_lock) 503 AC_CHECK_LIB(crypto,CRYPTO_new_ex_data)
497 if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then 504 if test "$ac_cv_lib_crypto_CRYPTO_new_ex_data" = "yes"; then
498 dnl Check for SSL lib 505 dnl Check for SSL lib
499 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto) 506 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
500 fi 507 fi
501 LIBS="$_SAVEDLIBS" 508 LIBS="$_SAVEDLIBS"
502 509
503 dnl test headers and libs to decide whether check_http should use SSL 510 dnl test headers and libs to decide whether check_http should use SSL
504 if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then 511 if test "$ac_cv_lib_crypto_CRYPTO_new_ex_data" = "yes"; then
505 if test "$ac_cv_lib_ssl_main" = "yes"; then 512 if test "$ac_cv_lib_ssl_main" = "yes"; then
506 if test "$FOUNDINCLUDE" = "yes"; then 513 if test "$FOUNDINCLUDE" = "yes"; then
507 FOUNDOPENSSL="yes" 514 FOUNDOPENSSL="yes"
diff --git a/plugins-scripts/check_ifoperstatus.pl b/plugins-scripts/check_ifoperstatus.pl
index 3eed4bc..9ede163 100755
--- a/plugins-scripts/check_ifoperstatus.pl
+++ b/plugins-scripts/check_ifoperstatus.pl
@@ -325,7 +325,7 @@ sub print_help() {
325 printf " (Implies the use of -I)\n"; 325 printf " (Implies the use of -I)\n";
326 printf " -w (--warn =i|w|c) ignore|warn|crit if the interface is dormant (default critical)\n"; 326 printf " -w (--warn =i|w|c) ignore|warn|crit if the interface is dormant (default critical)\n";
327 printf " -D (--admin-down =i|w|c) same for administratively down interfaces (default warning)\n"; 327 printf " -D (--admin-down =i|w|c) same for administratively down interfaces (default warning)\n";
328 printf " -M (--maxmsgsize) Max message size - usefull only for v1 or v2c\n"; 328 printf " -M (--maxmsgsize) Max message size - useful only for v1 or v2c\n";
329 printf " -t (--timeout) seconds before the plugin times out (default=$TIMEOUT)\n"; 329 printf " -t (--timeout) seconds before the plugin times out (default=$TIMEOUT)\n";
330 printf " -V (--version) Plugin version\n"; 330 printf " -V (--version) Plugin version\n";
331 printf " -h (--help) usage help \n\n"; 331 printf " -h (--help) usage help \n\n";
diff --git a/plugins-scripts/check_ifstatus.pl b/plugins-scripts/check_ifstatus.pl
index 9f2f7c3..32984e5 100755
--- a/plugins-scripts/check_ifstatus.pl
+++ b/plugins-scripts/check_ifstatus.pl
@@ -280,7 +280,7 @@ sub print_help() {
280 printf " in hex with 0x prefix generated by using \"snmpkey\" utility\n"; 280 printf " in hex with 0x prefix generated by using \"snmpkey\" utility\n";
281 printf " privacy password and authEngineID\n"; 281 printf " privacy password and authEngineID\n";
282 printf " -P (--privproto) privacy protocol (DES or AES; default: DES)\n"; 282 printf " -P (--privproto) privacy protocol (DES or AES; default: DES)\n";
283 printf " -M (--maxmsgsize) Max message size - usefull only for v1 or v2c\n"; 283 printf " -M (--maxmsgsize) Max message size - useful only for v1 or v2c\n";
284 printf " -t (--timeout) seconds before the plugin times out (default=$TIMEOUT)\n"; 284 printf " -t (--timeout) seconds before the plugin times out (default=$TIMEOUT)\n";
285 printf " -V (--version) Plugin version\n"; 285 printf " -V (--version) Plugin version\n";
286 printf " -h (--help) usage help \n\n"; 286 printf " -h (--help) usage help \n\n";
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index 04bce38..13d8bc3 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 473d4b9..da4f0de 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
53char *query_address = NULL; 53char *query_address = NULL;
54char *record_type = "A"; 54char *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);
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 8e793c9..4b5ba5f 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. */
62static 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. */
66static int show_all_fs = 1; 63static int show_all_fs = 1;
@@ -179,7 +176,7 @@ main (int argc, char **argv)
179 int temp_result; 176 int temp_result;
180 177
181 struct mount_entry *me; 178 struct mount_entry *me;
182 struct fs_usage fsp, tmpfsp; 179 struct fs_usage fsp;
183 struct parameter_list *temp_list, *path; 180 struct parameter_list *temp_list, *path;
184 181
185#ifdef __CYGWIN__ 182#ifdef __CYGWIN__
@@ -434,9 +431,7 @@ process_arguments (int argc, char **argv)
434 int c, err; 431 int c, err;
435 struct parameter_list *se; 432 struct parameter_list *se;
436 struct parameter_list *temp_list = NULL, *previous = NULL; 433 struct parameter_list *temp_list = NULL, *previous = NULL;
437 struct parameter_list *temp_path_select_list = NULL; 434 struct mount_entry *me;
438 struct mount_entry *me, *temp_me;
439 int result = OK;
440 regex_t re; 435 regex_t re;
441 int cflags = REG_NOSUB | REG_EXTENDED; 436 int cflags = REG_NOSUB | REG_EXTENDED;
442 int default_cflags = cflags; 437 int default_cflags = cflags;
diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index 48601f0..54ce7d1 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;
@@ -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 2038f4a..2347a6f 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -91,10 +91,12 @@ struct timeval tv_temp;
91 91
92int specify_port = FALSE; 92int specify_port = FALSE;
93int server_port = HTTP_PORT; 93int server_port = HTTP_PORT;
94int virtual_port = 0;
94char server_port_text[6] = ""; 95char server_port_text[6] = "";
95char server_type[6] = "http"; 96char server_type[6] = "http";
96char *server_address; 97char *server_address;
97char *host_name; 98char *host_name;
99int host_name_length;
98char *server_url; 100char *server_url;
99char *user_agent; 101char *user_agent;
100int server_url_length; 102int 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
@@ -922,8 +941,8 @@ check_http (void)
922 elapsed_time_ssl = (double)microsec_ssl / 1.0e6; 941 elapsed_time_ssl = (double)microsec_ssl / 1.0e6;
923 if (check_cert == TRUE) { 942 if (check_cert == TRUE) {
924 result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit); 943 result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit);
925 np_net_ssl_cleanup();
926 if (sd) close(sd); 944 if (sd) close(sd);
945 np_net_ssl_cleanup();
927 return result; 946 return result;
928 } 947 }
929 } 948 }
@@ -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
@@ -1022,6 +1041,10 @@ check_http (void)
1022 microsec_firstbyte = deltime (tv_temp); 1041 microsec_firstbyte = deltime (tv_temp);
1023 elapsed_time_firstbyte = (double)microsec_firstbyte / 1.0e6; 1042 elapsed_time_firstbyte = (double)microsec_firstbyte / 1.0e6;
1024 } 1043 }
1044 while (pos = memchr(buffer, '\0', i)) {
1045 /* replace nul character with a blank */
1046 *pos = ' ';
1047 }
1025 buffer[i] = '\0'; 1048 buffer[i] = '\0';
1026 xasprintf (&full_page_new, "%s%s", full_page, buffer); 1049 xasprintf (&full_page_new, "%s%s", full_page, buffer);
1027 free (full_page); 1050 free (full_page);
@@ -1063,10 +1086,10 @@ check_http (void)
1063 die (STATE_CRITICAL, _("HTTP CRITICAL - No data received from host\n")); 1086 die (STATE_CRITICAL, _("HTTP CRITICAL - No data received from host\n"));
1064 1087
1065 /* close the connection */ 1088 /* close the connection */
1089 if (sd) close(sd);
1066#ifdef HAVE_SSL 1090#ifdef HAVE_SSL
1067 np_net_ssl_cleanup(); 1091 np_net_ssl_cleanup();
1068#endif 1092#endif
1069 if (sd) close(sd);
1070 1093
1071 /* Save check time */ 1094 /* Save check time */
1072 microsec = deltime (tv); 1095 microsec = deltime (tv);
@@ -1421,6 +1444,9 @@ redir (char *pos, char *status_line)
1421 MAX_PORT, server_type, server_address, server_port, server_url, 1444 MAX_PORT, server_type, server_address, server_port, server_url,
1422 display_html ? "</A>" : ""); 1445 display_html ? "</A>" : "");
1423 1446
1447 /* reset virtual port */
1448 virtual_port = server_port;
1449
1424 if (verbose) 1450 if (verbose)
1425 printf (_("Redirection to %s://%s:%d%s\n"), server_type, 1451 printf (_("Redirection to %s://%s:%d%s\n"), server_type,
1426 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 8d540ca..4662131 100644
--- a/plugins/check_ide_smart.c
+++ b/plugins/check_ide_smart.c
@@ -166,7 +166,6 @@ enum SmartCommand
166 166
167char *get_offline_text (int); 167char *get_offline_text (int);
168int smart_read_values (int, values_t *); 168int smart_read_values (int, values_t *);
169int values_not_passed (values_t *, thresholds_t *);
170int nagios (values_t *, thresholds_t *); 169int nagios (values_t *, thresholds_t *);
171void print_value (value_t *, threshold_t *); 170void print_value (value_t *, threshold_t *);
172void print_values (values_t *, thresholds_t *); 171void print_values (values_t *, thresholds_t *);
@@ -340,31 +339,6 @@ smart_read_values (int fd, values_t * values)
340 339
341 340
342int 341int
343values_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
367int
368nagios (values_t * p, thresholds_t * t) 342nagios (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 a96435f..b1cc498 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 75efc28..5ac6c65 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. */
299int best_offset_server(const ntp_server_results *slist, int nservers){ 299int 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 :( */
357double offset_request(const char *host, int *status){ 357double 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 295f86f..391b2df 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. */
246int best_offset_server(const ntp_server_results *slist, int nservers){ 246int 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 :( */
304double offset_request(const char *host, int *status){ 304double 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 }
@@ -635,7 +633,7 @@ void print_help(void){
635 printf("%s\n", _("Notes:")); 633 printf("%s\n", _("Notes:"));
636 printf(" %s\n", _("If you'd rather want to monitor an NTP server, please use")); 634 printf(" %s\n", _("If you'd rather want to monitor an NTP server, please use"));
637 printf(" %s\n", _("check_ntp_peer.")); 635 printf(" %s\n", _("check_ntp_peer."));
638 printf(" %s\n", _("--time-offset is usefull for compensating for servers with known")); 636 printf(" %s\n", _("--time-offset is useful for compensating for servers with known"));
639 printf(" %s\n", _("and expected clock skew.")); 637 printf(" %s\n", _("and expected clock skew."));
640 printf("\n"); 638 printf("\n");
641 printf(UT_THRESHOLDS_NOTES); 639 printf(UT_THRESHOLDS_NOTES);
diff --git a/plugins/check_radius.c b/plugins/check_radius.c
index 03cbb8b..b3b8c82 100644
--- a/plugins/check_radius.c
+++ b/plugins/check_radius.c
@@ -36,7 +36,9 @@ const char *email = "devel@monitoring-plugins.org";
36#include "utils.h" 36#include "utils.h"
37#include "netutils.h" 37#include "netutils.h"
38 38
39#if defined(HAVE_LIBFREERADIUS_CLIENT) 39#if defined(HAVE_LIBRADCLI)
40#include <radcli/radcli.h>
41#elif defined(HAVE_LIBFREERADIUS_CLIENT)
40#include <freeradius-client.h> 42#include <freeradius-client.h>
41#elif defined(HAVE_LIBRADIUSCLIENT_NG) 43#elif defined(HAVE_LIBRADIUSCLIENT_NG)
42#include <radiusclient-ng.h> 44#include <radiusclient-ng.h>
@@ -48,22 +50,24 @@ int process_arguments (int, char **);
48void print_help (void); 50void print_help (void);
49void print_usage (void); 51void print_usage (void);
50 52
51#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) 53#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI)
52#define my_rc_conf_str(a) rc_conf_str(rch,a) 54#define my_rc_conf_str(a) rc_conf_str(rch,a)
55#if defined(HAVE_LIBRADCLI)
56#define my_rc_send_server(a,b) rc_send_server(rch,a,b,AUTH)
57#else
53#define my_rc_send_server(a,b) rc_send_server(rch,a,b) 58#define my_rc_send_server(a,b) rc_send_server(rch,a,b)
54#ifdef HAVE_LIBFREERADIUS_CLIENT 59#endif
60#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADCLI)
55#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,(a)->secret,e,f) 61#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,(a)->secret,e,f)
56#else 62#else
57#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,e,f) 63#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,e,f)
58#endif 64#endif
59#define my_rc_own_ipaddress() rc_own_ipaddress(rch)
60#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(rch,a,b,c,-1,d) 65#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(rch,a,b,c,-1,d)
61#define my_rc_read_dictionary(a) rc_read_dictionary(rch, a) 66#define my_rc_read_dictionary(a) rc_read_dictionary(rch, a)
62#else 67#else
63#define my_rc_conf_str(a) rc_conf_str(a) 68#define my_rc_conf_str(a) rc_conf_str(a)
64#define my_rc_send_server(a,b) rc_send_server(a, b) 69#define my_rc_send_server(a,b) rc_send_server(a, b)
65#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(a,b,c,d,e,f) 70#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(a,b,c,d,e,f)
66#define my_rc_own_ipaddress() rc_own_ipaddress()
67#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(a, b, c, d) 71#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(a, b, c, d)
68#define my_rc_read_dictionary(a) rc_read_dictionary(a) 72#define my_rc_read_dictionary(a) rc_read_dictionary(a)
69#endif 73#endif
@@ -76,7 +80,7 @@ void print_usage (void);
76 80
77int my_rc_read_config(char *); 81int my_rc_read_config(char *);
78 82
79#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) 83#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI)
80rc_handle *rch = NULL; 84rc_handle *rch = NULL;
81#endif 85#endif
82 86
@@ -90,7 +94,6 @@ char *config_file = NULL;
90unsigned short port = PW_AUTH_UDP_PORT; 94unsigned short port = PW_AUTH_UDP_PORT;
91int retries = 1; 95int retries = 1;
92int verbose = FALSE; 96int verbose = FALSE;
93ENV *env = NULL;
94 97
95/****************************************************************************** 98/******************************************************************************
96 99
@@ -150,6 +153,8 @@ Please note that all tags must be lowercase to use the DocBook XML DTD.
150int 153int
151main (int argc, char **argv) 154main (int argc, char **argv)
152{ 155{
156 struct sockaddr_storage ss;
157 char name[HOST_NAME_MAX];
153 char msg[BUFFER_LEN]; 158 char msg[BUFFER_LEN];
154 SEND_DATA data; 159 SEND_DATA data;
155 int result = STATE_UNKNOWN; 160 int result = STATE_UNKNOWN;
@@ -185,15 +190,14 @@ main (int argc, char **argv)
185 die (STATE_UNKNOWN, _("Invalid NAS-Identifier\n")); 190 die (STATE_UNKNOWN, _("Invalid NAS-Identifier\n"));
186 } 191 }
187 192
188 if (nasipaddress != NULL) { 193 if (nasipaddress == NULL) {
189 if (rc_good_ipaddr (nasipaddress)) 194 if (gethostname (name, sizeof(name)) != 0)
190 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n")); 195 die (STATE_UNKNOWN, _("gethostname() failed!\n"));
191 if ((client_id = rc_get_ipaddr(nasipaddress)) == 0) 196 nasipaddress = name;
192 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
193 } else {
194 if ((client_id = my_rc_own_ipaddress ()) == 0)
195 die (STATE_UNKNOWN, _("Can't find local IP for NAS-IP-Address\n"));
196 } 197 }
198 if (!dns_lookup (nasipaddress, &ss, AF_INET)) /* TODO: Support IPv6. */
199 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
200 client_id = ntohl (((struct sockaddr_in *)&ss)->sin_addr.s_addr);
197 if (my_rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) == NULL) 201 if (my_rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) == NULL)
198 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n")); 202 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
199 203
@@ -399,7 +403,7 @@ print_usage (void)
399 403
400int my_rc_read_config(char * a) 404int my_rc_read_config(char * a)
401{ 405{
402#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) 406#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI)
403 rch = rc_read_config(a); 407 rch = rc_read_config(a);
404 return (rch == NULL) ? 1 : 0; 408 return (rch == NULL) ? 1 : 0;
405#else 409#else
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index 1996c6d..587a724 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -59,10 +59,6 @@ enum {
59#define SMTP_STARTTLS "STARTTLS\r\n" 59#define SMTP_STARTTLS "STARTTLS\r\n"
60#define SMTP_AUTH_LOGIN "AUTH LOGIN\r\n" 60#define SMTP_AUTH_LOGIN "AUTH LOGIN\r\n"
61 61
62#ifndef HOST_MAX_BYTES
63#define HOST_MAX_BYTES 255
64#endif
65
66#define EHLO_SUPPORTS_STARTTLS 1 62#define EHLO_SUPPORTS_STARTTLS 1
67 63
68int process_arguments (int, char **); 64int process_arguments (int, char **);
@@ -239,8 +235,8 @@ main (int argc, char **argv)
239 result = np_net_ssl_init(sd); 235 result = np_net_ssl_init(sd);
240 if(result != STATE_OK) { 236 if(result != STATE_OK) {
241 printf (_("CRITICAL - Cannot create SSL context.\n")); 237 printf (_("CRITICAL - Cannot create SSL context.\n"));
242 np_net_ssl_cleanup();
243 close(sd); 238 close(sd);
239 np_net_ssl_cleanup();
244 return STATE_CRITICAL; 240 return STATE_CRITICAL;
245 } else { 241 } else {
246 ssl_established = 1; 242 ssl_established = 1;
@@ -764,10 +760,12 @@ recvlines(char *buf, size_t bufsize)
764int 760int
765my_close (void) 761my_close (void)
766{ 762{
763 int result;
764 result = close(sd);
767#ifdef HAVE_SSL 765#ifdef HAVE_SSL
768 np_net_ssl_cleanup(); 766 np_net_ssl_cleanup();
769#endif 767#endif
770 return close(sd); 768 return result;
771} 769}
772 770
773 771
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 9839d6e..da9638c 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -152,7 +152,7 @@ state_data *previous_state;
152double *previous_value; 152double *previous_value;
153size_t previous_size = OID_COUNT_STEP; 153size_t previous_size = OID_COUNT_STEP;
154int perf_labels = 1; 154int perf_labels = 1;
155 155char* ip_version = "";
156 156
157static char *fix_snmp_range(char *th) 157static 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_tcp.c b/plugins/check_tcp.c
index 6dc9aa9..61333bd 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -247,8 +247,8 @@ main (int argc, char **argv)
247 } 247 }
248 } 248 }
249 if(result != STATE_OK){ 249 if(result != STATE_OK){
250 np_net_ssl_cleanup();
251 if(sd) close(sd); 250 if(sd) close(sd);
251 np_net_ssl_cleanup();
252 return result; 252 return result;
253 } 253 }
254#endif /* HAVE_SSL */ 254#endif /* HAVE_SSL */
@@ -321,10 +321,10 @@ main (int argc, char **argv)
321 if (server_quit != NULL) { 321 if (server_quit != NULL) {
322 my_send(server_quit, strlen(server_quit)); 322 my_send(server_quit, strlen(server_quit));
323 } 323 }
324 if (sd) close (sd);
324#ifdef HAVE_SSL 325#ifdef HAVE_SSL
325 np_net_ssl_cleanup(); 326 np_net_ssl_cleanup();
326#endif 327#endif
327 if (sd) close (sd);
328 328
329 microsec = deltime (tv); 329 microsec = deltime (tv);
330 elapsed_time = (double)microsec / 1.0e6; 330 elapsed_time = (double)microsec / 1.0e6;
diff --git a/plugins/check_users.c b/plugins/check_users.c
index 54415a4..f6f4b36 100644
--- a/plugins/check_users.c
+++ b/plugins/check_users.c
@@ -54,15 +54,15 @@ int process_arguments (int, char **);
54void print_help (void); 54void print_help (void);
55void print_usage (void); 55void print_usage (void);
56 56
57int wusers = -1; 57char *warning_range = NULL;
58int cusers = -1; 58char *critical_range = NULL;
59thresholds *thlds = NULL;
59 60
60int 61int
61main (int argc, char **argv) 62main (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/common.h b/plugins/common.h
index 01003b3..8719b50 100644
--- a/plugins/common.h
+++ b/plugins/common.h
@@ -161,6 +161,13 @@
161# endif 161# endif
162#endif 162#endif
163 163
164/* openssl 1.1 does not set OPENSSL_NO_SSL2 by default but ships without ssl2 */
165#ifdef OPENSSL_VERSION_NUMBER
166# if OPENSSL_VERSION_NUMBER >= 0x10100000
167# define OPENSSL_NO_SSL2
168# endif
169#endif
170
164/* 171/*
165 * 172 *
166 * Standard Values 173 * Standard Values
diff --git a/plugins/negate.c b/plugins/negate.c
index beaed1e..b320e35 100644
--- a/plugins/negate.c
+++ b/plugins/negate.c
@@ -59,8 +59,8 @@ static int state[4] = {
59int 59int
60main (int argc, char **argv) 60main (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/netutils.c b/plugins/netutils.c
index 705aaf0..1bb4f07 100644
--- a/plugins/netutils.c
+++ b/plugins/netutils.c
@@ -359,20 +359,21 @@ is_addr (const char *address)
359} 359}
360 360
361int 361int
362resolve_host_or_addr (const char *address, int family) 362dns_lookup (const char *in, struct sockaddr_storage *ss, int family)
363{ 363{
364 struct addrinfo hints; 364 struct addrinfo hints;
365 struct addrinfo *res; 365 struct addrinfo *res;
366 int retval; 366 int retval;
367 367
368 memset (&hints, 0, sizeof (hints)); 368 memset (&hints, 0, sizeof(struct addrinfo));
369 hints.ai_family = family; 369 hints.ai_family = family;
370 retval = getaddrinfo (address, NULL, &hints, &res);
371 370
371 retval = getaddrinfo (in, NULL, &hints, &res);
372 if (retval != 0) 372 if (retval != 0)
373 return FALSE; 373 return FALSE;
374 else { 374
375 freeaddrinfo (res); 375 if (ss != NULL)
376 return TRUE; 376 memcpy (ss, res->ai_addr, res->ai_addrlen);
377 } 377 freeaddrinfo (res);
378 return TRUE;
378} 379}
diff --git a/plugins/netutils.h b/plugins/netutils.h
index 2766029..d7ee0dd 100644
--- a/plugins/netutils.h
+++ b/plugins/netutils.h
@@ -45,6 +45,10 @@
45# endif /* UNIX_PATH_MAX */ 45# endif /* UNIX_PATH_MAX */
46#endif /* HAVE_SYS_UN_H */ 46#endif /* HAVE_SYS_UN_H */
47 47
48#ifndef HOST_MAX_BYTES
49# define HOST_MAX_BYTES 255
50#endif
51
48/* process_request and wrapper macros */ 52/* process_request and wrapper macros */
49#define process_tcp_request(addr, port, sbuf, rbuf, rsize) \ 53#define process_tcp_request(addr, port, sbuf, rbuf, rsize) \
50 process_request(addr, port, IPPROTO_TCP, sbuf, rbuf, rsize) 54 process_request(addr, port, IPPROTO_TCP, sbuf, rbuf, rsize)
@@ -71,8 +75,9 @@ int send_request (int sd, int proto, const char *send_buffer, char *recv_buffer,
71/* "is_*" wrapper macros and functions */ 75/* "is_*" wrapper macros and functions */
72int is_host (const char *); 76int is_host (const char *);
73int is_addr (const char *); 77int is_addr (const char *);
74int resolve_host_or_addr (const char *, int); 78int dns_lookup (const char *, struct sockaddr_storage *, int);
75void host_or_die(const char *str); 79void host_or_die(const char *str);
80#define resolve_host_or_addr(addr, family) dns_lookup(addr, NULL, family)
76#define is_inet_addr(addr) resolve_host_or_addr(addr, AF_INET) 81#define is_inet_addr(addr) resolve_host_or_addr(addr, AF_INET)
77#ifdef USE_IPV6 82#ifdef USE_IPV6
78# define is_inet6_addr(addr) resolve_host_or_addr(addr, AF_INET6) 83# define is_inet6_addr(addr) resolve_host_or_addr(addr, AF_INET6)
diff --git a/plugins/sslutils.c b/plugins/sslutils.c
index 4f9c793..b412ef3 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 fe8aabd..5d9c5ff 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 2b906e3..5a90f02 100644
--- a/plugins/t/check_http.t
+++ b/plugins/t/check_http.t
@@ -9,7 +9,7 @@ use Test::More;
9use POSIX qw/mktime strftime/; 9use POSIX qw/mktime strftime/;
10use NPTest; 10use NPTest;
11 11
12plan tests => 42; 12plan tests => 49;
13 13
14my $successOutput = '/OK.*HTTP.*second/'; 14my $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
65like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK"); 65like( $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");
69like( $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");
72like( $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");
75like( $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");
78like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" );
79
80SKIP: {
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
67SKIP: { 93SKIP: {
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);
diff --git a/plugins/t/check_snmp.t b/plugins/t/check_snmp.t
index aefd872..eff46ea 100644
--- a/plugins/t/check_snmp.t
+++ b/plugins/t/check_snmp.t
@@ -10,7 +10,7 @@ use NPTest;
10 10
11BEGIN { 11BEGIN {
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
16my $res; 16my $res;
@@ -45,7 +45,7 @@ is( $res->return_code, 3, "Invalid protocol" );
45like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" ); 45like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" );
46 46
47SKIP: { 47SKIP: {
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
158SKIP: { 162SKIP: {
diff --git a/plugins/t/check_users.t b/plugins/t/check_users.t
index 39044bb..088f3b5 100644
--- a/plugins/t/check_users.t
+++ b/plugins/t/check_users.t
@@ -13,7 +13,7 @@ use Test;
13use NPTest; 13use NPTest;
14 14
15use vars qw($tests); 15use vars qw($tests);
16BEGIN {$tests = 4; plan tests => $tests} 16BEGIN {$tests = 8; plan tests => $tests}
17 17
18my $successOutput = '/^USERS OK - [0-9]+ users currently logged in/'; 18my $successOutput = '/^USERS OK - [0-9]+ users currently logged in/';
19my $failureOutput = '/^USERS CRITICAL - [0-9]+ users currently logged in/'; 19my $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
26exit(0) if defined($Test::Harness::VERSION); 28exit(0) if defined($Test::Harness::VERSION);
27exit($tests - $t); 29exit($tests - $t);
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t
index e72d243..1bc0ecb 100755
--- a/plugins/tests/check_http.t
+++ b/plugins/tests/check_http.t
@@ -17,6 +17,8 @@ use Test::More;
17use NPTest; 17use NPTest;
18use FindBin qw($Bin); 18use FindBin qw($Bin);
19 19
20$ENV{'LC_TIME'} = "C";
21
20my $common_tests = 70; 22my $common_tests = 70;
21my $ssl_only_tests = 8; 23my $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 a864e4a..231af92 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
672char *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 4c4aacc..a436e1c 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
97char *perfdata (const char *, 97char *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, 100char *fperfdata (const char *, double, const char *, int, double,
101 long int, 101 int, double, int, double, int, double);
102 int, 102
103 long int, 103char *sperfdata (const char *, double, const char *, char *, char *,
104 int, 104 int, double, int, double);
105 long int, 105
106 int, 106char *sperfdata_int (const char *, int, const char *, char *, char *,
107 long int); 107 int, int, int, int);
108
109char *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