summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorGreg Cox <gcox@fibbsbozza.local>2014-07-29 18:52:12 -0400
committerGreg Cox <gcox@fibbsbozza.local>2014-07-29 18:52:12 -0400
commit4273dd06ff3e52094d6b267d00e8c51dd74de364 (patch)
tree425d127da5dbec7013999ed01b469fc3f72992d9 /plugins
parentf05e7016320f4671fbf86cc5abc277efea20f79e (diff)
parent6f3d5825b203b75aef8d68bf0d117e7a1a4c0616 (diff)
downloadmonitoring-plugins-4273dd06ff3e52094d6b267d00e8c51dd74de364.tar.gz
Merge remote-tracking branch 'upstream/master'
Conflicts: plugins/netutils.c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_apt.c3
-rw-r--r--plugins/check_dbi.c6
-rw-r--r--plugins/check_dns.c18
-rw-r--r--plugins/check_hpjd.c30
-rw-r--r--plugins/check_http.c10
-rw-r--r--plugins/check_ide_smart.c2
-rw-r--r--plugins/check_mrtg.c2
-rw-r--r--plugins/check_mysql.c22
-rw-r--r--plugins/check_nt.c4
-rw-r--r--plugins/check_ntp.c13
-rw-r--r--plugins/check_ntp_peer.c49
-rw-r--r--plugins/check_ntp_time.c15
-rw-r--r--plugins/check_radius.c49
-rw-r--r--plugins/check_real.c1
-rw-r--r--plugins/check_ssh.c24
-rw-r--r--plugins/check_tcp.c12
-rw-r--r--plugins/check_ups.c6
-rw-r--r--plugins/negate.c11
-rw-r--r--plugins/netutils.c15
-rw-r--r--plugins/netutils.h4
-rw-r--r--plugins/runcmd.c2
-rw-r--r--plugins/sslutils.c11
-rw-r--r--plugins/t/NPTest.cache.travis56
-rw-r--r--plugins/t/check_dns.t3
-rw-r--r--plugins/t/check_fping.t14
-rw-r--r--plugins/t/check_hpjd.t35
-rw-r--r--plugins/t/check_jabber.t6
-rw-r--r--plugins/t/check_ntp.t14
-rw-r--r--plugins/t/check_procs.t2
-rw-r--r--plugins/t/check_snmp.t2
-rw-r--r--plugins/t/check_udp.t2
-rwxr-xr-xplugins/tests/check_http.t35
-rwxr-xr-xplugins/tests/check_procs.t29
-rwxr-xr-xplugins/tests/check_snmp.t2
34 files changed, 363 insertions, 146 deletions
diff --git a/plugins/check_apt.c b/plugins/check_apt.c
index 4c76a512..07622c2f 100644
--- a/plugins/check_apt.c
+++ b/plugins/check_apt.c
@@ -223,6 +223,9 @@ int run_upgrade(int *pkgcount, int *secpkgcount){
223 regex_t ireg, ereg, sreg; 223 regex_t ireg, ereg, sreg;
224 char *cmdline=NULL, rerrbuf[64]; 224 char *cmdline=NULL, rerrbuf[64];
225 225
226 /* initialize ereg as it is possible it is printed while uninitialized */
227 memset(&ereg, "\0", sizeof(ereg.buffer));
228
226 if(upgrade==NO_UPGRADE) return STATE_OK; 229 if(upgrade==NO_UPGRADE) return STATE_OK;
227 230
228 /* compile the regexps */ 231 /* compile the regexps */
diff --git a/plugins/check_dbi.c b/plugins/check_dbi.c
index c6244fd2..a3d033f4 100644
--- a/plugins/check_dbi.c
+++ b/plugins/check_dbi.c
@@ -215,7 +215,7 @@ main (int argc, char **argv)
215 } 215 }
216 216
217 if (dbi_conn_connect (conn) < 0) { 217 if (dbi_conn_connect (conn) < 0) {
218 np_dbi_print_error (conn, "UNKOWN - failed to connect to database"); 218 np_dbi_print_error (conn, "UNKNOWN - failed to connect to database");
219 return STATE_UNKNOWN; 219 return STATE_UNKNOWN;
220 } 220 }
221 221
@@ -241,7 +241,7 @@ main (int argc, char **argv)
241 printf ("Selecting database '%s'\n", np_dbi_database); 241 printf ("Selecting database '%s'\n", np_dbi_database);
242 242
243 if (dbi_conn_select_db (conn, np_dbi_database)) { 243 if (dbi_conn_select_db (conn, np_dbi_database)) {
244 np_dbi_print_error (conn, "UNKOWN - failed to select database '%s'", 244 np_dbi_print_error (conn, "UNKNOWN - failed to select database '%s'",
245 np_dbi_database); 245 np_dbi_database);
246 return STATE_UNKNOWN; 246 return STATE_UNKNOWN;
247 } 247 }
@@ -456,7 +456,7 @@ process_arguments (int argc, char **argv)
456 new = realloc (np_dbi_options, 456 new = realloc (np_dbi_options,
457 (np_dbi_options_num + 1) * sizeof (*new)); 457 (np_dbi_options_num + 1) * sizeof (*new));
458 if (! new) { 458 if (! new) {
459 printf ("UNKOWN - failed to reallocate memory\n"); 459 printf ("UNKNOWN - failed to reallocate memory\n");
460 exit (STATE_UNKNOWN); 460 exit (STATE_UNKNOWN);
461 } 461 }
462 462
diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index eebe72cc..31a953d7 100644
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
@@ -242,7 +242,23 @@ main (int argc, char **argv)
242 } 242 }
243 printf (ngettext("%.3f second response time", "%.3f seconds response time", elapsed_time), elapsed_time); 243 printf (ngettext("%.3f second response time", "%.3f seconds response time", elapsed_time), elapsed_time);
244 printf (_(". %s returns %s"), query_address, address); 244 printf (_(". %s returns %s"), query_address, address);
245 printf ("|%s\n", fperfdata ("time", elapsed_time, "s", FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); 245 if ((time_thresholds->warning != NULL) && (time_thresholds->critical != NULL)) {
246 printf ("|%s\n", fperfdata ("time", elapsed_time, "s",
247 TRUE, time_thresholds->warning->end,
248 TRUE, time_thresholds->critical->end,
249 TRUE, 0, FALSE, 0));
250 } else if ((time_thresholds->warning == NULL) && (time_thresholds->critical != NULL)) {
251 printf ("|%s\n", fperfdata ("time", elapsed_time, "s",
252 FALSE, 0,
253 TRUE, time_thresholds->critical->end,
254 TRUE, 0, FALSE, 0));
255 } else if ((time_thresholds->warning != NULL) && (time_thresholds->critical == NULL)) {
256 printf ("|%s\n", fperfdata ("time", elapsed_time, "s",
257 TRUE, time_thresholds->warning->end,
258 FALSE, 0,
259 TRUE, 0, FALSE, 0));
260 } else
261 printf ("|%s\n", fperfdata ("time", elapsed_time, "s", FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0));
246 } 262 }
247 else if (result == STATE_WARNING) 263 else if (result == STATE_WARNING)
248 printf (_("DNS WARNING - %s\n"), 264 printf (_("DNS WARNING - %s\n"),
diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c
index 1e7605ba..5fe06984 100644
--- a/plugins/check_hpjd.c
+++ b/plugins/check_hpjd.c
@@ -39,7 +39,7 @@ const char *email = "devel@monitoring-plugins.org";
39#include "netutils.h" 39#include "netutils.h"
40 40
41#define DEFAULT_COMMUNITY "public" 41#define DEFAULT_COMMUNITY "public"
42 42#define DEFAULT_PORT "161"
43 43
44const char *option_summary = "-H host [-C community]\n"; 44const char *option_summary = "-H host [-C community]\n";
45 45
@@ -66,6 +66,7 @@ void print_usage (void);
66 66
67char *community = NULL; 67char *community = NULL;
68char *address = NULL; 68char *address = NULL;
69char *port = NULL;
69 70
70int 71int
71main (int argc, char **argv) 72main (int argc, char **argv)
@@ -119,8 +120,8 @@ main (int argc, char **argv)
119 HPJD_GD_DOOR_OPEN, HPJD_GD_PAPER_OUTPUT, HPJD_GD_STATUS_DISPLAY); 120 HPJD_GD_DOOR_OPEN, HPJD_GD_PAPER_OUTPUT, HPJD_GD_STATUS_DISPLAY);
120 121
121 /* get the command to run */ 122 /* get the command to run */
122 sprintf (command_line, "%s -OQa -m : -v 1 -c %s %s %s", PATH_TO_SNMPGET, community, 123 sprintf (command_line, "%s -OQa -m : -v 1 -c %s %s:%hd %s", PATH_TO_SNMPGET, community,
123 address, query_string); 124 address, port, query_string);
124 125
125 /* run the command */ 126 /* run the command */
126 child_process = spopen (command_line); 127 child_process = spopen (command_line);
@@ -313,7 +314,7 @@ process_arguments (int argc, char **argv)
313 {"community", required_argument, 0, 'C'}, 314 {"community", required_argument, 0, 'C'},
314/* {"critical", required_argument,0,'c'}, */ 315/* {"critical", required_argument,0,'c'}, */
315/* {"warning", required_argument,0,'w'}, */ 316/* {"warning", required_argument,0,'w'}, */
316/* {"port", required_argument,0,'P'}, */ 317 {"port", required_argument,0,'p'},
317 {"version", no_argument, 0, 'V'}, 318 {"version", no_argument, 0, 'V'},
318 {"help", no_argument, 0, 'h'}, 319 {"help", no_argument, 0, 'h'},
319 {0, 0, 0, 0} 320 {0, 0, 0, 0}
@@ -324,7 +325,7 @@ process_arguments (int argc, char **argv)
324 325
325 326
326 while (1) { 327 while (1) {
327 c = getopt_long (argc, argv, "+hVH:C:", longopts, &option); 328 c = getopt_long (argc, argv, "+hVH:C:p:", longopts, &option);
328 329
329 if (c == -1 || c == EOF || c == 1) 330 if (c == -1 || c == EOF || c == 1)
330 break; 331 break;
@@ -341,6 +342,12 @@ process_arguments (int argc, char **argv)
341 case 'C': /* community */ 342 case 'C': /* community */
342 community = strscpy (community, optarg); 343 community = strscpy (community, optarg);
343 break; 344 break;
345 case 'p':
346 if (!is_intpos(optarg))
347 usage2 (_("Port must be a positive short integer"), optarg);
348 else
349 port = atoi(optarg);
350 break;
344 case 'V': /* version */ 351 case 'V': /* version */
345 print_revision (progname, NP_VERSION); 352 print_revision (progname, NP_VERSION);
346 exit (STATE_OK); 353 exit (STATE_OK);
@@ -369,6 +376,13 @@ process_arguments (int argc, char **argv)
369 community = strdup (DEFAULT_COMMUNITY); 376 community = strdup (DEFAULT_COMMUNITY);
370 } 377 }
371 378
379 if (port == NULL) {
380 if (argv[c] != NULL )
381 port = argv[c];
382 else
383 port = atoi (DEFAULT_PORT);
384 }
385
372 return validate_arguments (); 386 return validate_arguments ();
373} 387}
374 388
@@ -402,6 +416,10 @@ print_help (void)
402 printf (" %s", _("The SNMP community name ")); 416 printf (" %s", _("The SNMP community name "));
403 printf (_("(default=%s)"), DEFAULT_COMMUNITY); 417 printf (_("(default=%s)"), DEFAULT_COMMUNITY);
404 printf ("\n"); 418 printf ("\n");
419 printf (" %s\n", "-p, --port=STRING");
420 printf (" %s", _("Specify the port to check "));
421 printf (_("(default=%s)"), DEFAULT_PORT);
422 printf ("\n");
405 423
406 printf (UT_SUPPORT); 424 printf (UT_SUPPORT);
407} 425}
@@ -412,5 +430,5 @@ void
412print_usage (void) 430print_usage (void)
413{ 431{
414 printf ("%s\n", _("Usage:")); 432 printf ("%s\n", _("Usage:"));
415 printf ("%s -H host [-C community]\n", progname); 433 printf ("%s -H host [-C community] [-p port]\n", progname);
416} 434}
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 92861d97..51679975 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -1243,6 +1243,7 @@ redir (char *pos, char *status_line)
1243 if (addr == NULL) 1243 if (addr == NULL)
1244 die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate addr\n")); 1244 die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate addr\n"));
1245 1245
1246 memset(addr, 0, MAX_IPV4_HOSTLENGTH);
1246 url = malloc (strcspn (pos, "\r\n")); 1247 url = malloc (strcspn (pos, "\r\n"));
1247 if (url == NULL) 1248 if (url == NULL)
1248 die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate URL\n")); 1249 die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate URL\n"));
@@ -1333,8 +1334,8 @@ redir (char *pos, char *status_line)
1333 max_depth, type, addr, i, url, (display_html ? "</A>" : "")); 1334 max_depth, type, addr, i, url, (display_html ? "</A>" : ""));
1334 1335
1335 if (server_port==i && 1336 if (server_port==i &&
1336 !strcmp(server_address, addr) && 1337 !strncmp(server_address, addr, MAX_IPV4_HOSTLENGTH) &&
1337 (host_name && !strcmp(host_name, addr)) && 1338 (host_name && !strncmp(host_name, addr, MAX_IPV4_HOSTLENGTH)) &&
1338 !strcmp(server_url, url)) 1339 !strcmp(server_url, url))
1339 die (STATE_WARNING, 1340 die (STATE_WARNING,
1340 _("HTTP WARNING - redirection creates an infinite loop - %s://%s:%d%s%s\n"), 1341 _("HTTP WARNING - redirection creates an infinite loop - %s://%s:%d%s%s\n"),
@@ -1343,11 +1344,11 @@ redir (char *pos, char *status_line)
1343 strcpy (server_type, type); 1344 strcpy (server_type, type);
1344 1345
1345 free (host_name); 1346 free (host_name);
1346 host_name = strdup (addr); 1347 host_name = strndup (addr, MAX_IPV4_HOSTLENGTH);
1347 1348
1348 if (!(followsticky & STICKY_HOST)) { 1349 if (!(followsticky & STICKY_HOST)) {
1349 free (server_address); 1350 free (server_address);
1350 server_address = strdup (addr); 1351 server_address = strndup (addr, MAX_IPV4_HOSTLENGTH);
1351 } 1352 }
1352 if (!(followsticky & STICKY_PORT)) { 1353 if (!(followsticky & STICKY_PORT)) {
1353 server_port = i; 1354 server_port = i;
@@ -1366,6 +1367,7 @@ redir (char *pos, char *status_line)
1366 printf (_("Redirection to %s://%s:%d%s\n"), server_type, 1367 printf (_("Redirection to %s://%s:%d%s\n"), server_type,
1367 host_name ? host_name : server_address, server_port, server_url); 1368 host_name ? host_name : server_address, server_port, server_url);
1368 1369
1370 free(addr);
1369 check_http (); 1371 check_http ();
1370} 1372}
1371 1373
diff --git a/plugins/check_ide_smart.c b/plugins/check_ide_smart.c
index 55faacce..47605e96 100644
--- a/plugins/check_ide_smart.c
+++ b/plugins/check_ide_smart.c
@@ -419,7 +419,7 @@ nagios (values_t * p, thresholds_t * t)
419 status=STATE_OK; 419 status=STATE_OK;
420 break; 420 break;
421 default: 421 default:
422 printf (_("ERROR - Status '%d' unkown. %d/%d tests passed\n"), status, 422 printf (_("ERROR - Status '%d' unknown. %d/%d tests passed\n"), status,
423 passed, total); 423 passed, total);
424 status = STATE_UNKNOWN; 424 status = STATE_UNKNOWN;
425 break; 425 break;
diff --git a/plugins/check_mrtg.c b/plugins/check_mrtg.c
index ed75f4ce..cf3fe044 100644
--- a/plugins/check_mrtg.c
+++ b/plugins/check_mrtg.c
@@ -356,7 +356,7 @@ print_help (void)
356 printf (" %s\n", _("This plugin is useful for monitoring MRTG data that does not correspond to")); 356 printf (" %s\n", _("This plugin is useful for monitoring MRTG data that does not correspond to"));
357 printf (" %s\n", _("bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth).")); 357 printf (" %s\n", _("bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth)."));
358 printf (" %s\n", _("It can be used to monitor any kind of data that MRTG is monitoring - errors,")); 358 printf (" %s\n", _("It can be used to monitor any kind of data that MRTG is monitoring - errors,"));
359 printf (" %s\n", _("packets/sec, etc. I use MRTG in conjuction with the Novell NLM that allows")); 359 printf (" %s\n", _("packets/sec, etc. I use MRTG in conjunction with the Novell NLM that allows"));
360 printf (" %s\n", _("me to track processor utilization, user connections, drive space, etc and")); 360 printf (" %s\n", _("me to track processor utilization, user connections, drive space, etc and"));
361 printf (" %s\n\n", _("this plugin works well for monitoring that kind of data as well.")); 361 printf (" %s\n\n", _("this plugin works well for monitoring that kind of data as well."));
362 362
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index 4f09e5f8..216626bc 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -42,6 +42,7 @@ const char *email = "devel@monitoring-plugins.org";
42#include "netutils.h" 42#include "netutils.h"
43 43
44#include <mysql.h> 44#include <mysql.h>
45#include <mysqld_error.h>
45#include <errmsg.h> 46#include <errmsg.h>
46 47
47char *db_user = NULL; 48char *db_user = NULL;
@@ -59,6 +60,7 @@ char *opt_file = NULL;
59char *opt_group = NULL; 60char *opt_group = NULL;
60unsigned int db_port = MYSQL_PORT; 61unsigned int db_port = MYSQL_PORT;
61int check_slave = 0, warn_sec = 0, crit_sec = 0; 62int check_slave = 0, warn_sec = 0, crit_sec = 0;
63int ignore_auth = 0;
62int verbose = 0; 64int verbose = 0;
63 65
64static double warning_time = 0; 66static double warning_time = 0;
@@ -136,7 +138,16 @@ main (int argc, char **argv)
136 mysql_ssl_set(&mysql,key,cert,ca_cert,ca_dir,ciphers); 138 mysql_ssl_set(&mysql,key,cert,ca_cert,ca_dir,ciphers);
137 /* establish a connection to the server and error checking */ 139 /* establish a connection to the server and error checking */
138 if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) { 140 if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) {
139 if (mysql_errno (&mysql) == CR_UNKNOWN_HOST) 141 if (ignore_auth && mysql_errno (&mysql) == ER_ACCESS_DENIED_ERROR)
142 {
143 printf("MySQL OK - Version: %s (protocol %d)\n",
144 mysql_get_server_info(&mysql),
145 mysql_get_proto_info(&mysql)
146 );
147 mysql_close (&mysql);
148 return STATE_OK;
149 }
150 else if (mysql_errno (&mysql) == CR_UNKNOWN_HOST)
140 die (STATE_WARNING, "%s\n", mysql_error (&mysql)); 151 die (STATE_WARNING, "%s\n", mysql_error (&mysql));
141 else if (mysql_errno (&mysql) == CR_VERSION_ERROR) 152 else if (mysql_errno (&mysql) == CR_VERSION_ERROR)
142 die (STATE_WARNING, "%s\n", mysql_error (&mysql)); 153 die (STATE_WARNING, "%s\n", mysql_error (&mysql));
@@ -341,6 +352,7 @@ process_arguments (int argc, char **argv)
341 {"critical", required_argument, 0, 'c'}, 352 {"critical", required_argument, 0, 'c'},
342 {"warning", required_argument, 0, 'w'}, 353 {"warning", required_argument, 0, 'w'},
343 {"check-slave", no_argument, 0, 'S'}, 354 {"check-slave", no_argument, 0, 'S'},
355 {"ignore-auth", no_argument, 0, 'n'},
344 {"verbose", no_argument, 0, 'v'}, 356 {"verbose", no_argument, 0, 'v'},
345 {"version", no_argument, 0, 'V'}, 357 {"version", no_argument, 0, 'V'},
346 {"help", no_argument, 0, 'h'}, 358 {"help", no_argument, 0, 'h'},
@@ -357,7 +369,7 @@ process_arguments (int argc, char **argv)
357 return ERROR; 369 return ERROR;
358 370
359 while (1) { 371 while (1) {
360 c = getopt_long (argc, argv, "hlvVSP:p:u:d:H:s:c:w:a:k:C:D:L:f:g:", longopts, &option); 372 c = getopt_long (argc, argv, "hlvVnSP:p:u:d:H:s:c:w:a:k:C:D:L:f:g:", longopts, &option);
361 373
362 if (c == -1 || c == EOF) 374 if (c == -1 || c == EOF)
363 break; 375 break;
@@ -419,6 +431,9 @@ process_arguments (int argc, char **argv)
419 case 'S': 431 case 'S':
420 check_slave = 1; /* check-slave */ 432 check_slave = 1; /* check-slave */
421 break; 433 break;
434 case 'n':
435 ignore_auth = 1; /* ignore-auth */
436 break;
422 case 'w': 437 case 'w':
423 warning = optarg; 438 warning = optarg;
424 warning_time = strtod (warning, NULL); 439 warning_time = strtod (warning, NULL);
@@ -506,6 +521,9 @@ print_help (void)
506 printf (UT_EXTRA_OPTS); 521 printf (UT_EXTRA_OPTS);
507 522
508 printf (UT_HOST_PORT, 'P', myport); 523 printf (UT_HOST_PORT, 'P', myport);
524 printf (" %s\n", "-n, --ignore-auth");
525 printf (" %s\n", _("Ignore authentication failure and check for mysql connectivity only"));
526
509 printf (" %s\n", "-s, --socket=STRING"); 527 printf (" %s\n", "-s, --socket=STRING");
510 printf (" %s\n", _("Use the specified socket (has no effect if -H is used)")); 528 printf (" %s\n", _("Use the specified socket (has no effect if -H is used)"));
511 529
diff --git a/plugins/check_nt.c b/plugins/check_nt.c
index cacf6651..fefbfb7a 100644
--- a/plugins/check_nt.c
+++ b/plugins/check_nt.c
@@ -293,10 +293,10 @@ int main(int argc, char **argv){
293 293
294 /* Divisor should be 1048567, not 3044515, as we are measuring "Commit Charge" here, 294 /* Divisor should be 1048567, not 3044515, as we are measuring "Commit Charge" here,
295 which equals RAM + Pagefiles. */ 295 which equals RAM + Pagefiles. */
296 xasprintf(&output_message,_("Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)"), 296 xasprintf(&output_message,_("Memory usage: total:%.2f MB - used: %.2f MB (%.0f%%) - free: %.2f MB (%.0f%%)"),
297 mem_commitLimit / 1048567, mem_commitByte / 1048567, percent_used_space, 297 mem_commitLimit / 1048567, mem_commitByte / 1048567, percent_used_space,
298 (mem_commitLimit - mem_commitByte) / 1048567, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100); 298 (mem_commitLimit - mem_commitByte) / 1048567, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100);
299 xasprintf(&perfdata,_("'Memory usage'=%.2fMb;%.2f;%.2f;0.00;%.2f"), mem_commitByte / 1048567, 299 xasprintf(&perfdata,_("'Memory usage'=%.2fMB;%.2f;%.2f;0.00;%.2f"), mem_commitByte / 1048567,
300 warning_used_space / 1048567, critical_used_space / 1048567, mem_commitLimit / 1048567); 300 warning_used_space / 1048567, critical_used_space / 1048567, mem_commitLimit / 1048567);
301 301
302 return_code=STATE_OK; 302 return_code=STATE_OK;
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c
index 0a7640a7..09a923eb 100644
--- a/plugins/check_ntp.c
+++ b/plugins/check_ntp.c
@@ -517,13 +517,14 @@ setup_control_request(ntp_control_message *p, uint8_t opcode, uint16_t seq){
517double jitter_request(const char *host, int *status){ 517double jitter_request(const char *host, int *status){
518 int conn=-1, i, npeers=0, num_candidates=0, syncsource_found=0; 518 int conn=-1, i, npeers=0, num_candidates=0, syncsource_found=0;
519 int run=0, min_peer_sel=PEER_INCLUDED, num_selected=0, num_valid=0; 519 int run=0, min_peer_sel=PEER_INCLUDED, num_selected=0, num_valid=0;
520 int peers_size=0, peer_offset=0; 520 int peers_size=0, peer_offset=0, bytes_read=0;
521 ntp_assoc_status_pair *peers=NULL; 521 ntp_assoc_status_pair *peers=NULL;
522 ntp_control_message req; 522 ntp_control_message req;
523 const char *getvar = "jitter"; 523 const char *getvar = "jitter";
524 double rval = 0.0, jitter = -1.0; 524 double rval = 0.0, jitter = -1.0;
525 char *startofvalue=NULL, *nptr=NULL; 525 char *startofvalue=NULL, *nptr=NULL;
526 void *tmp; 526 void *tmp;
527 int ntp_cm_ints = sizeof(uint16_t) * 5 + sizeof(uint8_t) * 2;
527 528
528 /* Long-winded explanation: 529 /* Long-winded explanation:
529 * Getting the jitter requires a number of steps: 530 * Getting the jitter requires a number of steps:
@@ -608,7 +609,15 @@ double jitter_request(const char *host, int *status){
608 609
609 req.count = htons(MAX_CM_SIZE); 610 req.count = htons(MAX_CM_SIZE);
610 DBG(printf("recieving READVAR response...\n")); 611 DBG(printf("recieving READVAR response...\n"));
611 read(conn, &req, SIZEOF_NTPCM(req)); 612
613 /* cov-66524 - req.data not null terminated before usage. Also covers verifying struct was returned correctly*/
614 if ((bytes_read = read(conn, &req, SIZEOF_NTPCM(req))) == -1)
615 die(STATE_UNKNOWN, _("Cannot read from socket: %s"), strerror(errno));
616 if (bytes_read != ntp_cm_ints + req.count)
617 die(STATE_UNKNOWN, _("Invalid NTP response: %d bytes read does not equal %d plus %d data segment"), bytes_read, ntp_cm_ints, req.count);
618 /* else null terminate */
619 strncpy(req.data[req.count], "\0", 1);
620
612 DBG(print_ntp_control_message(&req)); 621 DBG(print_ntp_control_message(&req));
613 622
614 if(req.op&REM_ERROR && strstr(getvar, "jitter")) { 623 if(req.op&REM_ERROR && strstr(getvar, "jitter")) {
diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c
index 8dc19788..d3ae5999 100644
--- a/plugins/check_ntp_peer.c
+++ b/plugins/check_ntp_peer.c
@@ -560,7 +560,7 @@ char *perfd_truechimers (int num_truechimers)
560} 560}
561 561
562int main(int argc, char *argv[]){ 562int main(int argc, char *argv[]){
563 int result, offset_result, stratum, num_truechimers; 563 int result, offset_result, stratum, num_truechimers, oresult, jresult, sresult, tresult;
564 double offset=0, jitter=0; 564 double offset=0, jitter=0;
565 char *result_line, *perfdata_line; 565 char *result_line, *perfdata_line;
566 566
@@ -597,15 +597,19 @@ int main(int argc, char *argv[]){
597 result = STATE_UNKNOWN; 597 result = STATE_UNKNOWN;
598 result = max_state_alt(result, get_status(fabs(offset), offset_thresholds)); 598 result = max_state_alt(result, get_status(fabs(offset), offset_thresholds));
599 } 599 }
600 600 oresult = result;
601
601 if(do_truechimers) 602 if(do_truechimers)
602 result = max_state_alt(result, get_status(num_truechimers, truechimer_thresholds)); 603 tresult = get_status(num_truechimers, truechimer_thresholds);
604 result = max_state_alt(result, tresult);
603 605
604 if(do_stratum) 606 if(do_stratum)
605 result = max_state_alt(result, get_status(stratum, stratum_thresholds)); 607 sresult = get_status(stratum, stratum_thresholds);
608 result = max_state_alt(result, sresult);
606 609
607 if(do_jitter) 610 if(do_jitter)
608 result = max_state_alt(result, get_status(jitter, jitter_thresholds)); 611 jresult = get_status(jitter, jitter_thresholds);
612 result = max_state_alt(result, jresult);
609 613
610 switch (result) { 614 switch (result) {
611 case STATE_CRITICAL : 615 case STATE_CRITICAL :
@@ -629,20 +633,43 @@ int main(int argc, char *argv[]){
629 if(offset_result == STATE_UNKNOWN){ 633 if(offset_result == STATE_UNKNOWN){
630 xasprintf(&result_line, "%s %s", result_line, _("Offset unknown")); 634 xasprintf(&result_line, "%s %s", result_line, _("Offset unknown"));
631 xasprintf(&perfdata_line, ""); 635 xasprintf(&perfdata_line, "");
636 } else if (oresult == STATE_WARNING) {
637 xasprintf(&result_line, "%s %s %.10g secs (WARNING)", result_line, _("Offset"), offset);
638 } else if (oresult == STATE_CRITICAL) {
639 xasprintf(&result_line, "%s %s %.10g secs (CRITICAL)", result_line, _("Offset"), offset);
632 } else { 640 } else {
633 xasprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset); 641 xasprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset);
634 xasprintf(&perfdata_line, "%s", perfd_offset(offset)); 642 }
635 } 643 xasprintf(&perfdata_line, "%s", perfd_offset(offset));
644
636 if (do_jitter) { 645 if (do_jitter) {
637 xasprintf(&result_line, "%s, jitter=%f", result_line, jitter); 646 if (jresult == STATE_WARNING) {
647 xasprintf(&result_line, "%s, jitter=%f (WARNING)", result_line, jitter);
648 } else if (jresult == STATE_CRITICAL) {
649 xasprintf(&result_line, "%s, jitter=%f (CRITICAL)", result_line, jitter);
650 } else {
651 xasprintf(&result_line, "%s, jitter=%f", result_line, jitter);
652 }
638 xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_jitter(jitter)); 653 xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_jitter(jitter));
639 } 654 }
640 if (do_stratum) { 655 if (do_stratum) {
641 xasprintf(&result_line, "%s, stratum=%i", result_line, stratum); 656 if (sresult == STATE_WARNING) {
657 xasprintf(&result_line, "%s, stratum=%i (WARNING)", result_line, stratum);
658 } else if (sresult == STATE_CRITICAL) {
659 xasprintf(&result_line, "%s, stratum=%i (CRITICAL)", result_line, stratum);
660 } else {
661 xasprintf(&result_line, "%s, stratum=%i", result_line, stratum);
662 }
642 xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_stratum(stratum)); 663 xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_stratum(stratum));
643 } 664 }
644 if (do_truechimers) { 665 if (do_truechimers) {
645 xasprintf(&result_line, "%s, truechimers=%i", result_line, num_truechimers); 666 if (tresult == STATE_WARNING) {
667 xasprintf(&result_line, "%s, truechimers=%i (WARNING)", result_line, num_truechimers);
668 } else if (tresult == STATE_CRITICAL) {
669 xasprintf(&result_line, "%s, truechimers=%i (CRITICAL)", result_line, num_truechimers);
670 } else {
671 xasprintf(&result_line, "%s, truechimers=%i", result_line, num_truechimers);
672 }
646 xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_truechimers(num_truechimers)); 673 xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_truechimers(num_truechimers));
647 } 674 }
648 printf("%s|%s\n", result_line, perfdata_line); 675 printf("%s|%s\n", result_line, perfdata_line);
@@ -651,8 +678,6 @@ int main(int argc, char *argv[]){
651 return result; 678 return result;
652} 679}
653 680
654
655
656void print_help(void){ 681void print_help(void){
657 print_revision(progname, NP_VERSION); 682 print_revision(progname, NP_VERSION);
658 683
diff --git a/plugins/check_ntp_time.c b/plugins/check_ntp_time.c
index 72dffbd8..e344f8b7 100644
--- a/plugins/check_ntp_time.c
+++ b/plugins/check_ntp_time.c
@@ -48,6 +48,7 @@ static int verbose=0;
48static int quiet=0; 48static int quiet=0;
49static char *owarn="60"; 49static char *owarn="60";
50static char *ocrit="120"; 50static char *ocrit="120";
51static int time_offset=0;
51 52
52int process_arguments (int, char **); 53int process_arguments (int, char **);
53thresholds *offset_thresholds = NULL; 54thresholds *offset_thresholds = NULL;
@@ -400,7 +401,7 @@ double offset_request(const char *host, int *status){
400 gettimeofday(&recv_time, NULL); 401 gettimeofday(&recv_time, NULL);
401 DBG(print_ntp_message(&req[i])); 402 DBG(print_ntp_message(&req[i]));
402 respnum=servers[i].num_responses++; 403 respnum=servers[i].num_responses++;
403 servers[i].offset[respnum]=calc_offset(&req[i], &recv_time); 404 servers[i].offset[respnum]=calc_offset(&req[i], &recv_time)+time_offset;
404 if(verbose) { 405 if(verbose) {
405 printf("offset %.10g\n", servers[i].offset[respnum]); 406 printf("offset %.10g\n", servers[i].offset[respnum]);
406 } 407 }
@@ -455,6 +456,7 @@ int process_arguments(int argc, char **argv){
455 {"use-ipv4", no_argument, 0, '4'}, 456 {"use-ipv4", no_argument, 0, '4'},
456 {"use-ipv6", no_argument, 0, '6'}, 457 {"use-ipv6", no_argument, 0, '6'},
457 {"quiet", no_argument, 0, 'q'}, 458 {"quiet", no_argument, 0, 'q'},
459 {"time-offset", optional_argument, 0, 'o'},
458 {"warning", required_argument, 0, 'w'}, 460 {"warning", required_argument, 0, 'w'},
459 {"critical", required_argument, 0, 'c'}, 461 {"critical", required_argument, 0, 'c'},
460 {"timeout", required_argument, 0, 't'}, 462 {"timeout", required_argument, 0, 't'},
@@ -468,7 +470,7 @@ int process_arguments(int argc, char **argv){
468 usage ("\n"); 470 usage ("\n");
469 471
470 while (1) { 472 while (1) {
471 c = getopt_long (argc, argv, "Vhv46qw:c:t:H:p:", longopts, &option); 473 c = getopt_long (argc, argv, "Vhv46qw:c:t:H:p:o:", longopts, &option);
472 if (c == -1 || c == EOF || c == 1) 474 if (c == -1 || c == EOF || c == 1)
473 break; 475 break;
474 476
@@ -504,6 +506,9 @@ int process_arguments(int argc, char **argv){
504 case 't': 506 case 't':
505 socket_timeout=atoi(optarg); 507 socket_timeout=atoi(optarg);
506 break; 508 break;
509 case 'o':
510 time_offset=atoi(optarg);
511 break;
507 case '4': 512 case '4':
508 address_family = AF_INET; 513 address_family = AF_INET;
509 break; 514 break;
@@ -616,6 +621,8 @@ void print_help(void){
616 printf (" %s\n", _("Offset to result in warning status (seconds)")); 621 printf (" %s\n", _("Offset to result in warning status (seconds)"));
617 printf (" %s\n", "-c, --critical=THRESHOLD"); 622 printf (" %s\n", "-c, --critical=THRESHOLD");
618 printf (" %s\n", _("Offset to result in critical status (seconds)")); 623 printf (" %s\n", _("Offset to result in critical status (seconds)"));
624 printf (" %s\n", "-o, --time_offset=INTEGER");
625 printf (" %s\n", _("Expected offset of the ntp server relative to local server (seconds)"));
619 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 626 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
620 printf (UT_VERBOSE); 627 printf (UT_VERBOSE);
621 628
@@ -628,6 +635,8 @@ void print_help(void){
628 printf("%s\n", _("Notes:")); 635 printf("%s\n", _("Notes:"));
629 printf(" %s\n", _("If you'd rather want to monitor an NTP server, please use")); 636 printf(" %s\n", _("If you'd rather want to monitor an NTP server, please use"));
630 printf(" %s\n", _("check_ntp_peer.")); 637 printf(" %s\n", _("check_ntp_peer."));
638 printf(" %s\n", _("--time-offset is usefull for compensating for servers with known"));
639 printf(" %s\n", _("and expected clock skew."));
631 printf("\n"); 640 printf("\n");
632 printf(UT_THRESHOLDS_NOTES); 641 printf(UT_THRESHOLDS_NOTES);
633 642
@@ -642,6 +651,6 @@ void
642print_usage(void) 651print_usage(void)
643{ 652{
644 printf ("%s\n", _("Usage:")); 653 printf ("%s\n", _("Usage:"));
645 printf(" %s -H <host> [-4|-6] [-w <warn>] [-c <crit>] [-v verbose]\n", progname); 654 printf(" %s -H <host> [-4|-6] [-w <warn>] [-c <crit>] [-v verbose] [-o <time offset>]\n", progname);
646} 655}
647 656
diff --git a/plugins/check_radius.c b/plugins/check_radius.c
index 3481f0cc..b2943475 100644
--- a/plugins/check_radius.c
+++ b/plugins/check_radius.c
@@ -36,9 +36,10 @@ 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#ifdef HAVE_LIBRADIUSCLIENT_NG 39#if defined(HAVE_LIBFREERADIUS_CLIENT)
40#include <freeradius-client.h>
41#elif defined(HAVE_LIBRADIUSCLIENT_NG)
40#include <radiusclient-ng.h> 42#include <radiusclient-ng.h>
41rc_handle *rch = NULL;
42#else 43#else
43#include <radiusclient.h> 44#include <radiusclient.h>
44#endif 45#endif
@@ -47,11 +48,14 @@ int process_arguments (int, char **);
47void print_help (void); 48void print_help (void);
48void print_usage (void); 49void print_usage (void);
49 50
50/* libradiusclient(-ng) wrapper functions */ 51#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG)
51#ifdef HAVE_LIBRADIUSCLIENT_NG
52#define my_rc_conf_str(a) rc_conf_str(rch,a) 52#define my_rc_conf_str(a) rc_conf_str(rch,a)
53#define my_rc_send_server(a,b) rc_send_server(rch,a,b) 53#define my_rc_send_server(a,b) rc_send_server(rch,a,b)
54#ifdef HAVE_LIBFREERADIUS_CLIENT
55#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,(a)->secret,e,f)
56#else
54#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,e,f) 57#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,e,f)
58#endif
55#define my_rc_own_ipaddress() rc_own_ipaddress(rch) 59#define my_rc_own_ipaddress() rc_own_ipaddress(rch)
56#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(rch,a,b,c,-1,d) 60#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(rch,a,b,c,-1,d)
57#define my_rc_read_dictionary(a) rc_read_dictionary(rch, a) 61#define my_rc_read_dictionary(a) rc_read_dictionary(rch, a)
@@ -72,6 +76,10 @@ void print_usage (void);
72 76
73int my_rc_read_config(char *); 77int my_rc_read_config(char *);
74 78
79#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG)
80rc_handle *rch = NULL;
81#endif
82
75char *server = NULL; 83char *server = NULL;
76char *username = NULL; 84char *username = NULL;
77char *password = NULL; 85char *password = NULL;
@@ -142,11 +150,10 @@ Please note that all tags must be lowercase to use the DocBook XML DTD.
142int 150int
143main (int argc, char **argv) 151main (int argc, char **argv)
144{ 152{
145 UINT4 service;
146 char msg[BUFFER_LEN]; 153 char msg[BUFFER_LEN];
147 SEND_DATA data; 154 SEND_DATA data;
148 int result = STATE_UNKNOWN; 155 int result = STATE_UNKNOWN;
149 UINT4 client_id; 156 uint32_t client_id, service;
150 char *str; 157 char *str;
151 158
152 setlocale (LC_ALL, ""); 159 setlocale (LC_ALL, "");
@@ -162,7 +169,7 @@ main (int argc, char **argv)
162 str = strdup ("dictionary"); 169 str = strdup ("dictionary");
163 if ((config_file && my_rc_read_config (config_file)) || 170 if ((config_file && my_rc_read_config (config_file)) ||
164 my_rc_read_dictionary (my_rc_conf_str (str))) 171 my_rc_read_dictionary (my_rc_conf_str (str)))
165 die (STATE_UNKNOWN, _("Config file error")); 172 die (STATE_UNKNOWN, _("Config file error\n"));
166 173
167 service = PW_AUTHENTICATE_ONLY; 174 service = PW_AUTHENTICATE_ONLY;
168 175
@@ -171,24 +178,24 @@ main (int argc, char **argv)
171 my_rc_avpair_add (&data.send_pairs, PW_USER_NAME, username, 0) && 178 my_rc_avpair_add (&data.send_pairs, PW_USER_NAME, username, 0) &&
172 my_rc_avpair_add (&data.send_pairs, PW_USER_PASSWORD, password, 0) 179 my_rc_avpair_add (&data.send_pairs, PW_USER_PASSWORD, password, 0)
173 )) 180 ))
174 die (STATE_UNKNOWN, _("Out of Memory?")); 181 die (STATE_UNKNOWN, _("Out of Memory?\n"));
175 182
176 if (nasid != NULL) { 183 if (nasid != NULL) {
177 if (!(my_rc_avpair_add (&data.send_pairs, PW_NAS_IDENTIFIER, nasid, 0))) 184 if (!(my_rc_avpair_add (&data.send_pairs, PW_NAS_IDENTIFIER, nasid, 0)))
178 die (STATE_UNKNOWN, _("Invalid NAS-Identifier")); 185 die (STATE_UNKNOWN, _("Invalid NAS-Identifier\n"));
179 } 186 }
180 187
181 if (nasipaddress != NULL) { 188 if (nasipaddress != NULL) {
182 if (rc_good_ipaddr (nasipaddress)) 189 if (rc_good_ipaddr (nasipaddress))
183 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address")); 190 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
184 if ((client_id = rc_get_ipaddr(nasipaddress)) == 0) 191 if ((client_id = rc_get_ipaddr(nasipaddress)) == 0)
185 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address")); 192 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
186 } else { 193 } else {
187 if ((client_id = my_rc_own_ipaddress ()) == 0) 194 if ((client_id = my_rc_own_ipaddress ()) == 0)
188 die (STATE_UNKNOWN, _("Can't find local IP for NAS-IP-Address")); 195 die (STATE_UNKNOWN, _("Can't find local IP for NAS-IP-Address\n"));
189 } 196 }
190 if (my_rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) == NULL) 197 if (my_rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) == NULL)
191 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address")); 198 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
192 199
193 my_rc_buildreq (&data, PW_ACCESS_REQUEST, server, port, (int)timeout_interval, 200 my_rc_buildreq (&data, PW_ACCESS_REQUEST, server, port, (int)timeout_interval,
194 retries); 201 retries);
@@ -199,19 +206,19 @@ main (int argc, char **argv)
199 rc_avpair_free (data.receive_pairs); 206 rc_avpair_free (data.receive_pairs);
200 207
201 if (result == TIMEOUT_RC) 208 if (result == TIMEOUT_RC)
202 die (STATE_CRITICAL, _("Timeout")); 209 die (STATE_CRITICAL, _("Timeout\n"));
203 if (result == ERROR_RC) 210 if (result == ERROR_RC)
204 die (STATE_CRITICAL, _("Auth Error")); 211 die (STATE_CRITICAL, _("Auth Error\n"));
205 if (result == REJECT_RC) 212 if (result == REJECT_RC)
206 die (STATE_WARNING, _("Auth Failed")); 213 die (STATE_WARNING, _("Auth Failed\n"));
207 if (result == BADRESP_RC) 214 if (result == BADRESP_RC)
208 die (STATE_WARNING, _("Bad Response")); 215 die (STATE_WARNING, _("Bad Response\n"));
209 if (expect && !strstr (msg, expect)) 216 if (expect && !strstr (msg, expect))
210 die (STATE_WARNING, "%s", msg); 217 die (STATE_WARNING, "%s\n", msg);
211 if (result == OK_RC) 218 if (result == OK_RC)
212 die (STATE_OK, _("Auth OK")); 219 die (STATE_OK, _("Auth OK\n"));
213 (void)snprintf(msg, sizeof(msg), _("Unexpected result code %d"), result); 220 (void)snprintf(msg, sizeof(msg), _("Unexpected result code %d"), result);
214 die (STATE_UNKNOWN, "%s", msg); 221 die (STATE_UNKNOWN, "%s\n", msg);
215} 222}
216 223
217 224
@@ -392,7 +399,7 @@ print_usage (void)
392 399
393int my_rc_read_config(char * a) 400int my_rc_read_config(char * a)
394{ 401{
395#ifdef HAVE_LIBRADIUSCLIENT_NG 402#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG)
396 rch = rc_read_config(a); 403 rch = rc_read_config(a);
397 return (rch == NULL) ? 1 : 0; 404 return (rch == NULL) ? 1 : 0;
398#else 405#else
diff --git a/plugins/check_real.c b/plugins/check_real.c
index 47776c5b..36f64134 100644
--- a/plugins/check_real.c
+++ b/plugins/check_real.c
@@ -178,6 +178,7 @@ main (int argc, char **argv)
178 178
179 /* watch for the REAL connection string */ 179 /* watch for the REAL connection string */
180 result = recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0); 180 result = recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0);
181 buffer[result] = "\0"; /* null terminate recieved buffer */
181 182
182 /* return a CRITICAL status if we couldn't read any data */ 183 /* return a CRITICAL status if we couldn't read any data */
183 if (result == -1) { 184 if (result == -1) {
diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c
index f4522e2b..b6187d61 100644
--- a/plugins/check_ssh.c
+++ b/plugins/check_ssh.c
@@ -46,6 +46,7 @@ const char *email = "devel@monitoring-plugins.org";
46int port = -1; 46int port = -1;
47char *server_name = NULL; 47char *server_name = NULL;
48char *remote_version = NULL; 48char *remote_version = NULL;
49char *remote_protocol = NULL;
49int verbose = FALSE; 50int verbose = FALSE;
50 51
51int process_arguments (int, char **); 52int process_arguments (int, char **);
@@ -53,7 +54,7 @@ int validate_arguments (void);
53void print_help (void); 54void print_help (void);
54void print_usage (void); 55void print_usage (void);
55 56
56int ssh_connect (char *haddr, int hport, char *remote_version); 57int ssh_connect (char *haddr, int hport, char *remote_version, char *remote_protocol);
57 58
58 59
59 60
@@ -78,7 +79,7 @@ main (int argc, char **argv)
78 alarm (socket_timeout); 79 alarm (socket_timeout);
79 80
80 /* ssh_connect exits if error is found */ 81 /* ssh_connect exits if error is found */
81 result = ssh_connect (server_name, port, remote_version); 82 result = ssh_connect (server_name, port, remote_version, remote_protocol);
82 83
83 alarm (0); 84 alarm (0);
84 85
@@ -105,6 +106,7 @@ process_arguments (int argc, char **argv)
105 {"timeout", required_argument, 0, 't'}, 106 {"timeout", required_argument, 0, 't'},
106 {"verbose", no_argument, 0, 'v'}, 107 {"verbose", no_argument, 0, 'v'},
107 {"remote-version", required_argument, 0, 'r'}, 108 {"remote-version", required_argument, 0, 'r'},
109 {"remote-protcol", required_argument, 0, 'P'},
108 {0, 0, 0, 0} 110 {0, 0, 0, 0}
109 }; 111 };
110 112
@@ -116,7 +118,7 @@ process_arguments (int argc, char **argv)
116 strcpy (argv[c], "-t"); 118 strcpy (argv[c], "-t");
117 119
118 while (1) { 120 while (1) {
119 c = getopt_long (argc, argv, "+Vhv46t:r:H:p:", longopts, &option); 121 c = getopt_long (argc, argv, "+Vhv46t:r:H:p:P:", longopts, &option);
120 122
121 if (c == -1 || c == EOF) 123 if (c == -1 || c == EOF)
122 break; 124 break;
@@ -152,6 +154,9 @@ process_arguments (int argc, char **argv)
152 case 'r': /* remote version */ 154 case 'r': /* remote version */
153 remote_version = optarg; 155 remote_version = optarg;
154 break; 156 break;
157 case 'P': /* remote version */
158 remote_protocol = optarg;
159 break;
155 case 'H': /* host */ 160 case 'H': /* host */
156 if (is_host (optarg) == FALSE) 161 if (is_host (optarg) == FALSE)
157 usage2 (_("Invalid hostname/address"), optarg); 162 usage2 (_("Invalid hostname/address"), optarg);
@@ -206,7 +211,7 @@ validate_arguments (void)
206 211
207 212
208int 213int
209ssh_connect (char *haddr, int hport, char *remote_version) 214ssh_connect (char *haddr, int hport, char *remote_version, char *remote_protocol)
210{ 215{
211 int sd; 216 int sd;
212 int result; 217 int result;
@@ -254,6 +259,14 @@ ssh_connect (char *haddr, int hport, char *remote_version)
254 exit (STATE_WARNING); 259 exit (STATE_WARNING);
255 } 260 }
256 261
262 if (remote_protocol && strcmp(remote_protocol, ssh_proto)) {
263 printf
264 (_("SSH WARNING - %s (protocol %s) protocol version mismatch, expected '%s'\n"),
265 ssh_server, ssh_proto, remote_protocol);
266 close(sd);
267 exit (STATE_WARNING);
268 }
269
257 elapsed_time = (double)deltime(tv) / 1.0e6; 270 elapsed_time = (double)deltime(tv) / 1.0e6;
258 271
259 printf 272 printf
@@ -296,6 +309,9 @@ print_help (void)
296 printf (" %s\n", "-r, --remote-version=STRING"); 309 printf (" %s\n", "-r, --remote-version=STRING");
297 printf (" %s\n", _("Warn if string doesn't match expected server version (ex: OpenSSH_3.9p1)")); 310 printf (" %s\n", _("Warn if string doesn't match expected server version (ex: OpenSSH_3.9p1)"));
298 311
312 printf (" %s\n", "-P, --remote-protocol=STRING");
313 printf (" %s\n", _("Warn if protocol doesn't match expected protocol version (ex: 2.0)"));
314
299 printf (UT_VERBOSE); 315 printf (UT_VERBOSE);
300 316
301 printf (UT_SUPPORT); 317 printf (UT_SUPPORT);
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index 0a6e2b27..f75c523c 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -32,13 +32,12 @@ char *progname;
32const char *copyright = "1999-2008"; 32const char *copyright = "1999-2008";
33const char *email = "devel@monitoring-plugins.org"; 33const char *email = "devel@monitoring-plugins.org";
34 34
35#include <ctype.h>
36
37#include "common.h" 35#include "common.h"
38#include "netutils.h" 36#include "netutils.h"
39#include "utils.h" 37#include "utils.h"
40#include "utils_tcp.h" 38#include "utils_tcp.h"
41 39
40#include <ctype.h>
42#include <sys/select.h> 41#include <sys/select.h>
43 42
44#ifdef HAVE_SSL 43#ifdef HAVE_SSL
@@ -354,8 +353,13 @@ main (int argc, char **argv)
354 printf("Unexpected response from host/socket on "); 353 printf("Unexpected response from host/socket on ");
355 else 354 else
356 printf("%.3f second response time on ", elapsed_time); 355 printf("%.3f second response time on ", elapsed_time);
357 if(server_address[0] != '/') 356 if(server_address[0] != '/') {
358 printf("port %d", server_port); 357 if (host_specified)
358 printf("%s port %d",
359 server_address, server_port);
360 else
361 printf("port %d", server_port);
362 }
359 else 363 else
360 printf("socket %s", server_address); 364 printf("socket %s", server_address);
361 } 365 }
diff --git a/plugins/check_ups.c b/plugins/check_ups.c
index 7cced495..099881d0 100644
--- a/plugins/check_ups.c
+++ b/plugins/check_ups.c
@@ -66,7 +66,7 @@ enum {
66#define UPSSTATUS_BOOST 512 66#define UPSSTATUS_BOOST 512
67#define UPSSTATUS_CHRG 1024 67#define UPSSTATUS_CHRG 1024
68#define UPSSTATUS_DISCHRG 2048 68#define UPSSTATUS_DISCHRG 2048
69#define UPSSTATUS_UNKOWN 4096 69#define UPSSTATUS_UNKNOWN 4096
70 70
71enum { NOSUCHVAR = ERROR-1 }; 71enum { NOSUCHVAR = ERROR-1 };
72 72
@@ -181,7 +181,7 @@ main (int argc, char **argv)
181 if (status & UPSSTATUS_DISCHRG) { 181 if (status & UPSSTATUS_DISCHRG) {
182 xasprintf (&ups_status, "%s%s", ups_status, _(", Discharging")); 182 xasprintf (&ups_status, "%s%s", ups_status, _(", Discharging"));
183 } 183 }
184 if (status & UPSSTATUS_UNKOWN) { 184 if (status & UPSSTATUS_UNKNOWN) {
185 xasprintf (&ups_status, "%s%s", ups_status, _(", Unknown")); 185 xasprintf (&ups_status, "%s%s", ups_status, _(", Unknown"));
186 } 186 }
187 } 187 }
@@ -379,7 +379,7 @@ determine_status (void)
379 else if (!strcmp (ptr, "DISCHRG")) 379 else if (!strcmp (ptr, "DISCHRG"))
380 status |= UPSSTATUS_DISCHRG; 380 status |= UPSSTATUS_DISCHRG;
381 else 381 else
382 status |= UPSSTATUS_UNKOWN; 382 status |= UPSSTATUS_UNKNOWN;
383 } 383 }
384 384
385 return OK; 385 return OK;
diff --git a/plugins/negate.c b/plugins/negate.c
index 4bd09deb..beaed1ea 100644
--- a/plugins/negate.c
+++ b/plugins/negate.c
@@ -35,16 +35,16 @@ const char *email = "devel@monitoring-plugins.org";
35 35
36#define DEFAULT_TIMEOUT 11 36#define DEFAULT_TIMEOUT 11
37 37
38#include <ctype.h>
39
40#include "common.h" 38#include "common.h"
41#include "utils.h" 39#include "utils.h"
42#include "utils_cmd.h" 40#include "utils_cmd.h"
43 41
42#include <ctype.h>
43
44/* char *command_line; */ 44/* char *command_line; */
45 45
46static const char **process_arguments (int, char **); 46static const char **process_arguments (int, char **);
47int validate_arguments (char **); 47void validate_arguments (char **);
48void print_help (void); 48void print_help (void);
49void print_usage (void); 49void print_usage (void);
50int subst_text = FALSE; 50int subst_text = FALSE;
@@ -98,8 +98,7 @@ main (int argc, char **argv)
98 die (max_state_alt (result, STATE_UNKNOWN), _("No data returned from command\n")); 98 die (max_state_alt (result, STATE_UNKNOWN), _("No data returned from command\n"));
99 99
100 for (i = 0; i < chld_out.lines; i++) { 100 for (i = 0; i < chld_out.lines; i++) {
101 if (subst_text && result != state[result] && 101 if (subst_text && result >= 0 && result <= 4 && result != state[result]) {
102 result >= 0 && result <= 4) {
103 /* Loop over each match found */ 102 /* Loop over each match found */
104 while ((sub = strstr (chld_out.line[i], state_text (result)))) { 103 while ((sub = strstr (chld_out.line[i], state_text (result)))) {
105 /* Terminate the first part and skip over the string we'll substitute */ 104 /* Terminate the first part and skip over the string we'll substitute */
@@ -206,7 +205,7 @@ process_arguments (int argc, char **argv)
206} 205}
207 206
208 207
209int 208void
210validate_arguments (char **command_line) 209validate_arguments (char **command_line)
211{ 210{
212 if (command_line[0] == NULL) 211 if (command_line[0] == NULL)
diff --git a/plugins/netutils.c b/plugins/netutils.c
index 7ae97223..705aaf09 100644
--- a/plugins/netutils.c
+++ b/plugins/netutils.c
@@ -171,11 +171,12 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
171 char port_str[6], host[MAX_HOST_ADDRESS_LENGTH]; 171 char port_str[6], host[MAX_HOST_ADDRESS_LENGTH];
172 size_t len; 172 size_t len;
173 int socktype, result; 173 int socktype, result;
174 short is_socket = (host_name[0] == '/');
174 175
175 socktype = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM; 176 socktype = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM;
176 177
177 /* as long as it doesn't start with a '/', it's assumed a host or ip */ 178 /* as long as it doesn't start with a '/', it's assumed a host or ip */
178 if(host_name[0] != '/'){ 179 if (!is_socket){
179 memset (&hints, 0, sizeof (hints)); 180 memset (&hints, 0, sizeof (hints));
180 hints.ai_family = address_family; 181 hints.ai_family = address_family;
181 hints.ai_protocol = proto; 182 hints.ai_protocol = proto;
@@ -255,7 +256,11 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
255 case STATE_OK: 256 case STATE_OK:
256 case STATE_WARNING: /* user wants WARN or OK on refusal, or... */ 257 case STATE_WARNING: /* user wants WARN or OK on refusal, or... */
257 case STATE_CRITICAL: /* user did not set econn_refuse_state, or wanted critical */ 258 case STATE_CRITICAL: /* user did not set econn_refuse_state, or wanted critical */
258 printf ("%s\n", strerror(errno)); 259 if (is_socket)
260 printf("connect to file socket %s: %s\n", host_name, strerror(errno));
261 else
262 printf("connect to address %s and port %d: %s\n",
263 host_name, port, strerror(errno));
259 return STATE_CRITICAL; 264 return STATE_CRITICAL;
260 break; 265 break;
261 default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */ 266 default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */
@@ -264,7 +269,11 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
264 } 269 }
265 } 270 }
266 else { 271 else {
267 printf ("%s\n", strerror(errno)); 272 if (is_socket)
273 printf("connect to file socket %s: %s\n", host_name, strerror(errno));
274 else
275 printf("connect to address %s and port %d: %s\n",
276 host_name, port, strerror(errno));
268 return STATE_CRITICAL; 277 return STATE_CRITICAL;
269 } 278 }
270} 279}
diff --git a/plugins/netutils.h b/plugins/netutils.h
index c5aa18fc..c6fce901 100644
--- a/plugins/netutils.h
+++ b/plugins/netutils.h
@@ -40,8 +40,8 @@
40#ifdef HAVE_SYS_UN_H 40#ifdef HAVE_SYS_UN_H
41# include <sys/un.h> 41# include <sys/un.h>
42# ifndef UNIX_PATH_MAX 42# ifndef UNIX_PATH_MAX
43 /* linux uses this, on sun it's hard-coded at 108 without a define */ 43 /* linux uses this, on sun it's hard-coded at 108 without a define, on BSD at 104 */
44# define UNIX_PATH_MAX 108 44# define UNIX_PATH_MAX 104
45# endif /* UNIX_PATH_MAX */ 45# endif /* UNIX_PATH_MAX */
46#endif /* HAVE_SYS_UN_H */ 46#endif /* HAVE_SYS_UN_H */
47 47
diff --git a/plugins/runcmd.c b/plugins/runcmd.c
index 4352e603..1a7c904f 100644
--- a/plugins/runcmd.c
+++ b/plugins/runcmd.c
@@ -261,7 +261,7 @@ runcmd_timeout_alarm_handler (int signo)
261 size_t i; 261 size_t i;
262 262
263 if (signo == SIGALRM) 263 if (signo == SIGALRM)
264 puts(_("CRITICAL - Plugin timed out while executing system call\n")); 264 puts(_("CRITICAL - Plugin timed out while executing system call"));
265 265
266 if(np_pids) for(i = 0; i < maxfd; i++) { 266 if(np_pids) for(i = 0; i < maxfd; i++) {
267 if(np_pids[i] != 0) kill(np_pids[i], SIGKILL); 267 if(np_pids[i] != 0) kill(np_pids[i], SIGKILL);
diff --git a/plugins/sslutils.c b/plugins/sslutils.c
index 2732125d..d0ae4741 100644
--- a/plugins/sslutils.c
+++ b/plugins/sslutils.c
@@ -86,10 +86,12 @@ int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int
86 if (cert && privkey) { 86 if (cert && privkey) {
87 SSL_CTX_use_certificate_file(c, cert, SSL_FILETYPE_PEM); 87 SSL_CTX_use_certificate_file(c, cert, SSL_FILETYPE_PEM);
88 SSL_CTX_use_PrivateKey_file(c, privkey, SSL_FILETYPE_PEM); 88 SSL_CTX_use_PrivateKey_file(c, privkey, SSL_FILETYPE_PEM);
89#ifdef USE_OPENSSL
89 if (!SSL_CTX_check_private_key(c)) { 90 if (!SSL_CTX_check_private_key(c)) {
90 printf ("%s\n", _("CRITICAL - Private key does not seem to match certificate!\n")); 91 printf ("%s\n", _("CRITICAL - Private key does not seem to match certificate!\n"));
91 return STATE_CRITICAL; 92 return STATE_CRITICAL;
92 } 93 }
94#endif
93 } 95 }
94#ifdef SSL_OP_NO_TICKET 96#ifdef SSL_OP_NO_TICKET
95 SSL_CTX_set_options(c, SSL_OP_NO_TICKET); 97 SSL_CTX_set_options(c, SSL_OP_NO_TICKET);
@@ -151,7 +153,8 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
151 struct tm stamp; 153 struct tm stamp;
152 float time_left; 154 float time_left;
153 int days_left; 155 int days_left;
154 char timestamp[17] = ""; 156 char timestamp[50] = "";
157 time_t tm_t;
155 158
156 certificate=SSL_get_peer_certificate(s); 159 certificate=SSL_get_peer_certificate(s);
157 if (!certificate) { 160 if (!certificate) {
@@ -209,10 +212,8 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
209 212
210 time_left = difftime(timegm(&stamp), time(NULL)); 213 time_left = difftime(timegm(&stamp), time(NULL));
211 days_left = time_left / 86400; 214 days_left = time_left / 86400;
212 snprintf 215 tm_t = mktime (&stamp);
213 (timestamp, 17, "%02d/%02d/%04d %02d:%02d", 216 strftime(timestamp, 50, "%c", localtime(&tm_t));
214 stamp.tm_mon + 1,
215 stamp.tm_mday, stamp.tm_year + 1900, stamp.tm_hour, stamp.tm_min);
216 217
217 if (days_left > 0 && days_left <= days_till_exp_warn) { 218 if (days_left > 0 && days_left <= days_till_exp_warn) {
218 printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, days_left, timestamp); 219 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
new file mode 100644
index 00000000..4ebfb90e
--- /dev/null
+++ b/plugins/t/NPTest.cache.travis
@@ -0,0 +1,56 @@
1{
2 'MYSQL_LOGIN_DETAILS' => '-u root -d test',
3 'NP_ALLOW_SUDO' => 'yes',
4 'NP_DNS_SERVER' => '8.8.8.8',
5 'NP_GOOD_NTP_SERVICE' => '',
6 'NP_HOSTNAME_INVALID' => 'nosuchhost',
7 'NP_HOSTNAME_VALID' => 'monitoringplugins.org',
8 'NP_HOSTNAME_VALID_IP' => '130.133.8.40',
9 'NP_HOSTNAME_VALID_REVERSE' => 'orwell.monitoring-plugins.org.',
10 'NP_HOST_DHCP_RESPONSIVE' => '',
11 'NP_HOST_NONRESPONSIVE' => '10.0.0.1',
12 'NP_HOST_RESPONSIVE' => 'localhost',
13 'NP_HOST_SMB' => '',
14 'NP_HOST_SNMP' => '',
15 'NP_HOST_TCP_FTP' => '',
16 'NP_HOST_TCP_HPJD' => '',
17 'NP_HOST_HPJD_PORT_INVALID' => '161',
18 'NP_HOST_HPJD_PORT_VALID' => '',
19 'NP_HOST_TCP_HTTP' => 'localhost',
20 'NP_HOST_TCP_HTTP2' => 'labs.consol.de',
21 'NP_HOST_TCP_IMAP' => 'imap.web.de',
22 'NP_HOST_TCP_POP' => 'pop.web.de',
23 'NP_HOST_TCP_SMTP' => 'localhost',
24 'NP_HOST_TCP_SMTP_NOTLS' => '',
25 'NP_HOST_TCP_SMTP_TLS' => '',
26 'NP_INTERNET_ACCESS' => 'yes',
27 'NP_MOUNTPOINT2_VALID' => '',
28 'NP_MOUNTPOINT_VALID' => '/',
29 'NP_MYSQL_SERVER' => 'localhost',
30 'NP_HOST_UDP_TIME' => 'localhost',
31 'NP_MYSQL_SOCKET' => '/var/run/mysqld/mysqld.sock',
32 'NP_MYSQL_WITH_SLAVE' => '',
33 'NP_MYSQL_WITH_SLAVE_LOGIN' => '',
34 'NP_NO_NTP_SERVICE' => 'localhost',
35 'NP_SMB_SHARE' => '',
36 'NP_SMB_SHARE_DENY' => '',
37 'NP_SMB_SHARE_SPC' => '',
38 'NP_SMB_VALID_USER' => '',
39 'NP_SMB_VALID_USER_PASS' => '',
40 'NP_SNMP_COMMUNITY' => '',
41 'NP_SSH_CONFIGFILE' => '~/.ssh/config',
42 'NP_SSH_HOST' => 'localhost',
43 'NP_SSH_IDENTITY' => '~/.ssh/id_dsa',
44 'NP_HOST_TCP_JABBER' => 'jabber.org',
45 'host_nonresponsive' => '10.0.0.1',
46 'host_responsive' => 'localhost',
47 'host_snmp' => '',
48 'host_tcp_ftp' => '',
49 'host_tcp_http' => 'localhost',
50 'host_tcp_imap' => 'imap.nierlein.de',
51 'host_tcp_smtp' => 'localhost',
52 'hostname_invalid' => 'nosuchhost',
53 'snmp_community' => '',
54 'user_snmp' => '',
55 'host_udp_time' => 'none',
56}
diff --git a/plugins/t/check_dns.t b/plugins/t/check_dns.t
index 2c903db9..b8858807 100644
--- a/plugins/t/check_dns.t
+++ b/plugins/t/check_dns.t
@@ -10,7 +10,7 @@ use NPTest;
10 10
11plan skip_all => "check_dns not compiled" unless (-x "check_dns"); 11plan skip_all => "check_dns not compiled" unless (-x "check_dns");
12 12
13plan tests => 13; 13plan tests => 14;
14 14
15my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/'; 15my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/';
16 16
@@ -54,6 +54,7 @@ cmp_ok( $res->return_code, '==', 2, "Critical threshold passed");
54 54
55$res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5 -w 0 -c 5"); 55$res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5 -w 0 -c 5");
56cmp_ok( $res->return_code, '==', 1, "Warning threshold passed"); 56cmp_ok( $res->return_code, '==', 1, "Warning threshold passed");
57like( $res->output, '/\|time=[\d\.]+s;0.0*;5\.0*;0\.0*/', "Output performance data OK" );
57 58
58$res = NPTest->testCmd("./check_dns -H $hostname_invalid -t 1"); 59$res = NPTest->testCmd("./check_dns -H $hostname_invalid -t 1");
59cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid"); 60cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid");
diff --git a/plugins/t/check_fping.t b/plugins/t/check_fping.t
index 45a9be8a..08692e46 100644
--- a/plugins/t/check_fping.t
+++ b/plugins/t/check_fping.t
@@ -27,16 +27,18 @@ my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_IN
27 27
28my $t; 28my $t;
29 29
30if ( -x "./check_fping" ) 30my $fping = qx(which fping 2> /dev/null);
31{ 31chomp($fping);
32if( ! -x "./check_fping") {
33 $t += skipMissingCmd( "./check_fping", $tests );
34}
35elsif ( $> != 0 && (!$fping || ! -u $fping)) {
36 $t += skipMsg( "./check_fping", $tests );
37} else {
32 $t += checkCmd( "./check_fping $host_responsive", 0, $successOutput ); 38 $t += checkCmd( "./check_fping $host_responsive", 0, $successOutput );
33 $t += checkCmd( "./check_fping $host_nonresponsive", [ 1, 2 ] ); 39 $t += checkCmd( "./check_fping $host_nonresponsive", [ 1, 2 ] );
34 $t += checkCmd( "./check_fping $hostname_invalid", [ 1, 2 ] ); 40 $t += checkCmd( "./check_fping $hostname_invalid", [ 1, 2 ] );
35} 41}
36else
37{
38 $t += skipMissingCmd( "./check_fping", $tests );
39}
40 42
41exit(0) if defined($Test::Harness::VERSION); 43exit(0) if defined($Test::Harness::VERSION);
42exit($tests - $t); 44exit($tests - $t);
diff --git a/plugins/t/check_hpjd.t b/plugins/t/check_hpjd.t
index 10ded54a..4d64852a 100644
--- a/plugins/t/check_hpjd.t
+++ b/plugins/t/check_hpjd.t
@@ -10,7 +10,6 @@ use NPTest;
10 10
11plan skip_all => "check_hpjd not compiled" unless (-x "check_hpjd"); 11plan skip_all => "check_hpjd not compiled" unless (-x "check_hpjd");
12 12
13plan tests => 5;
14 13
15my $successOutput = '/^Printer ok - /'; 14my $successOutput = '/^Printer ok - /';
16my $failureOutput = '/Timeout: No [Rr]esponse from /'; 15my $failureOutput = '/Timeout: No [Rr]esponse from /';
@@ -20,31 +19,53 @@ my $host_tcp_hpjd = getTestParameter(
20 "A host (usually a printer) providing the HP-JetDirect Services" 19 "A host (usually a printer) providing the HP-JetDirect Services"
21 ); 20 );
22 21
22my $host_hpjd_port_invalid = getTestParameter(
23 "NP_HOST_HPJD_PORT_INVALID",
24 "A port that HP-JetDirect Services is not listening on",
25 "162"
26 );
27
28my $host_hpjd_port_valid = getTestParameter(
29 "NP_HOST_HPJD_PORT_VALID",
30 "The port that HP-JetDirect Services is currently listening on",
31 "161"
32 );
33
23my $host_nonresponsive = getTestParameter( 34my $host_nonresponsive = getTestParameter(
24 "NP_HOST_NONRESPONSIVE", 35 "NP_HOST_NONRESPONSIVE",
25 "The hostname of system not responsive to network requests", 36 "The hostname of system not responsive to network requests",
26 "10.0.0.1", 37 "10.0.0.1"
27 ); 38 );
28 39
29my $hostname_invalid = getTestParameter( 40my $hostname_invalid = getTestParameter(
30 "NP_HOSTNAME_INVALID", 41 "NP_HOSTNAME_INVALID",
31 "An invalid (not known to DNS) hostname", 42 "An invalid (not known to DNS) hostname",
32 "nosuchhost", 43 "nosuchhost"
33 ); 44 );
34 45
46my $tests = $host_tcp_hpjd ? 9 : 5;
47plan tests => $tests;
35my $res; 48my $res;
36 49
37SKIP: { 50SKIP: {
38 skip "No HP JetDirect defined", 2 unless $host_tcp_hpjd; 51 skip "No HP JetDirect defined", 2 unless $host_tcp_hpjd;
39 $res = NPTest->testCmd("./check_hpjd $host_tcp_hpjd"); 52 $res = NPTest->testCmd("./check_hpjd -H $host_tcp_hpjd");
40 cmp_ok( $res->return_code, '==', 0, "Jetdirect responding" ); 53 cmp_ok( $res->return_code, 'eq', 0, "Jetdirect responding" );
41 like ( $res->output, $successOutput, "Output correct" ); 54 like ( $res->output, $successOutput, "Output correct" );
55
56 $res = NPTest->testCmd("./check_hpjd -H $host_tcp_hpjd -p $host_hpjd_port_valid");
57 cmp_ok( $res->return_code, 'eq', 0, "Jetdirect responding on port $host_hpjd_port_valid" );
58 like ( $res->output, $successOutput, "Output correct" );
59
60 $res = NPTest->testCmd("./check_hpjd -H $host_tcp_hpjd -p $host_hpjd_port_invalid");
61 cmp_ok( $res->return_code, 'eq', 2, "Jetdirect not responding on port $host_hpjd_port_invalid" );
62 like ( $res->output, $failureOutput, "Output correct" );
42} 63}
43 64
44$res = NPTest->testCmd("./check_hpjd $host_nonresponsive"); 65$res = NPTest->testCmd("./check_hpjd -H $host_nonresponsive");
45cmp_ok( $res->return_code, 'eq', 2, "Host not responding"); 66cmp_ok( $res->return_code, 'eq', 2, "Host not responding");
46like ( $res->output, $failureOutput, "Output OK" ); 67like ( $res->output, $failureOutput, "Output OK" );
47 68
48$res = NPTest->testCmd("./check_hpjd $hostname_invalid"); 69$res = NPTest->testCmd("./check_hpjd -H $hostname_invalid");
49cmp_ok( $res->return_code, 'eq', 3, "Hostname invalid"); 70cmp_ok( $res->return_code, 'eq', 3, "Hostname invalid");
50 71
diff --git a/plugins/t/check_jabber.t b/plugins/t/check_jabber.t
index 1aaf8125..7a708d5b 100644
--- a/plugins/t/check_jabber.t
+++ b/plugins/t/check_jabber.t
@@ -29,7 +29,7 @@ my $hostname_invalid = getTestParameter(
29 ); 29 );
30 30
31 31
32my $jabberOK = '/JABBER OK\s-\s\d+\.\d+\ssecond response time on port 5222/'; 32my $jabberOK = '/JABBER OK\s-\s\d+\.\d+\ssecond response time on '.$host_tcp_jabber.' port 5222/';
33 33
34my $jabberUnresponsive = '/CRITICAL\s-\sSocket timeout after\s\d+\sseconds/'; 34my $jabberUnresponsive = '/CRITICAL\s-\sSocket timeout after\s\d+\sseconds/';
35 35
@@ -40,7 +40,7 @@ my $r;
40SKIP: { 40SKIP: {
41 skip "No jabber server defined", 6 unless $host_tcp_jabber; 41 skip "No jabber server defined", 6 unless $host_tcp_jabber;
42 42
43 $r = NPTest->testCmd( "./check_jabber $host_tcp_jabber" ); 43 $r = NPTest->testCmd( "./check_jabber -H $host_tcp_jabber" );
44 is( $r->return_code, 0, "Connected okay"); 44 is( $r->return_code, 0, "Connected okay");
45 like( $r->output, $jabberOK, "Output as expected" ); 45 like( $r->output, $jabberOK, "Output as expected" );
46 46
@@ -48,7 +48,7 @@ SKIP: {
48 is( $r->return_code, 0, "Connected okay, within limits" ); 48 is( $r->return_code, 0, "Connected okay, within limits" );
49 like( $r->output, $jabberOK, "Output as expected" ); 49 like( $r->output, $jabberOK, "Output as expected" );
50 50
51 $r = NPTest->testCmd( "./check_jabber $host_tcp_jabber -wt 9 -ct 9 -to 10" ); 51 $r = NPTest->testCmd( "./check_jabber -H $host_tcp_jabber -wt 9 -ct 9 -to 10" );
52 is( $r->return_code, 0, "Old syntax okay" ); 52 is( $r->return_code, 0, "Old syntax okay" );
53 like( $r->output, $jabberOK, "Output as expected" ); 53 like( $r->output, $jabberOK, "Output as expected" );
54 54
diff --git a/plugins/t/check_ntp.t b/plugins/t/check_ntp.t
index 3eee6e17..b8fc8fdf 100644
--- a/plugins/t/check_ntp.t
+++ b/plugins/t/check_ntp.t
@@ -23,27 +23,27 @@ my $no_ntp_service = getTestParameter( "NP_NO_NTP_SERVICE",
23 "A host NOT providing the NTP service", 23 "A host NOT providing the NTP service",
24 "localhost" ); 24 "localhost" );
25 25
26my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE", 26my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE",
27 "The hostname of system not responsive to network requests", 27 "The hostname of system not responsive to network requests",
28 "10.0.0.1" ); 28 "10.0.0.1" );
29 29
30my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID", 30my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID",
31 "An invalid (not known to DNS) hostname", 31 "An invalid (not known to DNS) hostname",
32 "nosuchhost"); 32 "nosuchhost");
33 33
34my $ntp_okmatch1 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/'; 34my $ntp_okmatch1 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/';
35my $ntp_warnmatch1 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/'; 35my $ntp_warnmatch1 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/';
36my $ntp_critmatch1 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/'; 36my $ntp_critmatch1 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/';
37my $ntp_okmatch2 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2},\struechimers=[0-9]+/'; 37my $ntp_okmatch2 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2},\struechimers=[0-9]+/';
38my $ntp_warnmatch2 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2},\struechimers=[0-9]+/'; 38my $ntp_warnmatch2 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2}\s\(WARNING\),\struechimers=[0-9]+/';
39my $ntp_critmatch2 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2},\struechimers=[0-9]+/'; 39my $ntp_critmatch2 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+\s\(CRITICAL\),\sstratum=[0-9]{1,2},\struechimers=[0-9]+/';
40my $ntp_noresponse = '/^(CRITICAL - Socket timeout after 3 seconds)|(NTP CRITICAL: No response from NTP server)$/'; 40my $ntp_noresponse = '/^(CRITICAL - Socket timeout after 3 seconds)|(NTP CRITICAL: No response from NTP server)$/';
41my $ntp_nosuchhost = '/^check_ntp.*: Invalid hostname/address - ' . $hostname_invalid . '/'; 41my $ntp_nosuchhost = '/^check_ntp.*: Invalid hostname/address - ' . $hostname_invalid . '/';
42 42
43 43
44foreach my $plugin (@PLUGINS1) { 44foreach my $plugin (@PLUGINS1) {
45 SKIP: { 45 SKIP: {
46 skip "No NTP server defined", 1 unless $ntp_service; 46 skip "No NTP server defined", 6 unless $ntp_service;
47 $res = NPTest->testCmd( 47 $res = NPTest->testCmd(
48 "./$plugin -H $ntp_service -w 1000 -c 2000" 48 "./$plugin -H $ntp_service -w 1000 -c 2000"
49 ); 49 );
@@ -88,7 +88,7 @@ foreach my $plugin (@PLUGINS1) {
88 88
89foreach my $plugin (@PLUGINS2) { 89foreach my $plugin (@PLUGINS2) {
90 SKIP: { 90 SKIP: {
91 skip "No NTP server defined", 1 unless $ntp_service; 91 skip "No NTP server defined", 6 unless $ntp_service;
92 $res = NPTest->testCmd( 92 $res = NPTest->testCmd(
93 "./$plugin -H $ntp_service -w 1000 -c 2000 -W 20 -C 21 -j 100000 -k 200000 -m 1: -n 0:" 93 "./$plugin -H $ntp_service -w 1000 -c 2000 -W 20 -C 21 -j 100000 -k 200000 -m 1: -n 0:"
94 ); 94 );
diff --git a/plugins/t/check_procs.t b/plugins/t/check_procs.t
index ca4acdd7..abe7284e 100644
--- a/plugins/t/check_procs.t
+++ b/plugins/t/check_procs.t
@@ -26,7 +26,7 @@ $result = NPTest->testCmd( "./check_procs -w 100000 -c 100000 -s Z" );
26is( $result->return_code, 0, "Checking less than 100000 zombie processes" ); 26is( $result->return_code, 0, "Checking less than 100000 zombie processes" );
27like( $result->output, '/^PROCS OK: [0-9]+ process(es)? with /', "Output correct" ); 27like( $result->output, '/^PROCS OK: [0-9]+ process(es)? with /', "Output correct" );
28 28
29if(fork() == 0) { exec("sleep 7"); } # fork a test process 29if(fork() == 0) { exec("sleep 7"); } else { sleep(1) } # fork a test process in child and give child time to fork in parent
30$result = NPTest->testCmd( "./check_procs -a 'sleep 7'" ); 30$result = NPTest->testCmd( "./check_procs -a 'sleep 7'" );
31is( $result->return_code, 0, "Parent process is ignored" ); 31is( $result->return_code, 0, "Parent process is ignored" );
32like( $result->output, '/^PROCS OK: 1 process?/', "Output correct" ); 32like( $result->output, '/^PROCS OK: 1 process?/', "Output correct" );
diff --git a/plugins/t/check_snmp.t b/plugins/t/check_snmp.t
index c35d7821..2d6c44a7 100644
--- a/plugins/t/check_snmp.t
+++ b/plugins/t/check_snmp.t
@@ -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", 38 if ( ! $host_snmp ); 48 skip "no snmp host defined", 48 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" );
diff --git a/plugins/t/check_udp.t b/plugins/t/check_udp.t
index 619cadfb..1f6fee70 100644
--- a/plugins/t/check_udp.t
+++ b/plugins/t/check_udp.t
@@ -62,7 +62,7 @@ SKIP: {
62 cmp_ok( $res->return_code, '==', '2', "Hung waiting for response"); 62 cmp_ok( $res->return_code, '==', '2', "Hung waiting for response");
63 like ( $res->output, '/Socket timeout after 5 seconds/', "Timeout message"); 63 like ( $res->output, '/Socket timeout after 5 seconds/', "Timeout message");
64 like ( $duration, '/^[56]$/', "Timeout after 5 (possibly 6) seconds"); 64 like ( $duration, '/^[56]$/', "Timeout after 5 (possibly 6) seconds");
65 my $read_nc = <NC>; 65 my $read_nc = <NC> || '';
66 close NC; 66 close NC;
67 cmp_ok( $read_nc, 'eq', "foofoo", "Data received correctly" ); 67 cmp_ok( $read_nc, 'eq', "foofoo", "Data received correctly" );
68} 68}
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t
index 2c89beb0..d93a0ecf 100755
--- a/plugins/tests/check_http.t
+++ b/plugins/tests/check_http.t
@@ -20,8 +20,9 @@ use FindBin qw($Bin);
20my $common_tests = 70; 20my $common_tests = 70;
21my $ssl_only_tests = 8; 21my $ssl_only_tests = 8;
22# Check that all dependent modules are available 22# Check that all dependent modules are available
23eval "use HTTP::Daemon 6.01;";
24plan skip_all => 'HTTP::Daemon >= 6.01 required' if $@;
23eval { 25eval {
24 require HTTP::Daemon;
25 require HTTP::Status; 26 require HTTP::Status;
26 require HTTP::Response; 27 require HTTP::Response;
27}; 28};
@@ -185,21 +186,21 @@ SKIP: {
185 186
186 $result = NPTest->testCmd( "$command -p $port_https -S -C 14" ); 187 $result = NPTest->testCmd( "$command -p $port_https -S -C 14" );
187 is( $result->return_code, 0, "$command -p $port_https -S -C 14" ); 188 is( $result->return_code, 0, "$command -p $port_https -S -C 14" );
188 is( $result->output, 'OK - Certificate \'Ton Voon\' will expire on 03/03/2019 21:41.', "output ok" ); 189 is( $result->output, 'OK - Certificate \'Ton Voon\' will expire on Sun Mar 3 21:41:00 2019.', "output ok" );
189 190
190 $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" ); 191 $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" );
191 is( $result->return_code, 1, "$command -p $port_https -S -C 14000" ); 192 is( $result->return_code, 1, "$command -p $port_https -S -C 14000" );
192 like( $result->output, '/WARNING - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(03/03/2019 21:41\)./', "output ok" ); 193 like( $result->output, '/WARNING - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:00 2019\)./', "output ok" );
193 194
194 # Expired cert tests 195 # Expired cert tests
195 $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" ); 196 $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" );
196 is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" ); 197 is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" );
197 like( $result->output, '/CRITICAL - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(03/03/2019 21:41\)./', "output ok" ); 198 like( $result->output, '/CRITICAL - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:00 2019\)./', "output ok" );
198 199
199 $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" ); 200 $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" );
200 is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" ); 201 is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" );
201 is( $result->output, 202 is( $result->output,
202 'CRITICAL - Certificate \'Ton Voon\' expired on 03/05/2009 00:13.', 203 'CRITICAL - Certificate \'Ton Voon\' expired on Thu Mar 5 00:13:00 2009.',
203 "output ok" ); 204 "output ok" );
204 205
205} 206}
@@ -392,27 +393,21 @@ sub run_common_tests {
392 skip "This doesn't seems to work all the time", 1 unless ($ENV{HTTP_EXTERNAL}); 393 skip "This doesn't seems to work all the time", 1 unless ($ENV{HTTP_EXTERNAL});
393 $cmd = "$command -f follow -u /redir_external -t 5"; 394 $cmd = "$command -f follow -u /redir_external -t 5";
394 eval { 395 eval {
395 local $SIG{ALRM} = sub { die "alarm\n" }; 396 $result = NPTest->testCmd( $cmd, 2 );
396 alarm(2); 397 };
397 $result = NPTest->testCmd( $cmd ); 398 like( $@, "/timeout in command: $cmd/", $cmd );
398 alarm(0); };
399 is( $@, "alarm\n", $cmd );
400 } 399 }
401 400
402 $cmd = "$command -u /timeout -t 5"; 401 $cmd = "$command -u /timeout -t 5";
403 eval { 402 eval {
404 local $SIG{ALRM} = sub { die "alarm\n" }; 403 $result = NPTest->testCmd( $cmd, 2 );
405 alarm(2); 404 };
406 $result = NPTest->testCmd( $cmd ); 405 like( $@, "/timeout in command: $cmd/", $cmd );
407 alarm(0); };
408 is( $@, "alarm\n", $cmd );
409 406
410 $cmd = "$command -f follow -u /redir_timeout -t 2"; 407 $cmd = "$command -f follow -u /redir_timeout -t 2";
411 eval { 408 eval {
412 local $SIG{ALRM} = sub { die "alarm\n" }; 409 $result = NPTest->testCmd( $cmd, 5 );
413 alarm(5); 410 };
414 $result = NPTest->testCmd( $cmd ); 411 is( $@, "", $cmd );
415 alarm(0); };
416 isnt( $@, "alarm\n", $cmd );
417 412
418} 413}
diff --git a/plugins/tests/check_procs.t b/plugins/tests/check_procs.t
index 1ad2c2f1..54d43d9b 100755
--- a/plugins/tests/check_procs.t
+++ b/plugins/tests/check_procs.t
@@ -48,21 +48,26 @@ SKIP: {
48 like( $result->output, '/^PROCS OK: 1 process with command name \'launchd\', UID = 501 (.*)$/', "Output correct" ); 48 like( $result->output, '/^PROCS OK: 1 process with command name \'launchd\', UID = 501 (.*)$/', "Output correct" );
49} 49}
50 50
51$result = NPTest->testCmd( "$command -u -2 -w 2:2" ); 51SKIP: {
52is( $result->return_code, 1, "Checking processes with userid=-2" ); 52 skip 'user with uid -2 required', 8 unless getpwuid(-2);
53like( $result->output, '/^PROCS WARNING: 3 processes with UID = -2 \(nobody\)$/', "Output correct" ); 53 skip 'uid -2 must have name "nobody"', 8 unless getpwuid(-2) eq 'nobody';
54
55 $result = NPTest->testCmd( "$command -u -2 -w 2:2" );
56 is( $result->return_code, 1, "Checking processes with userid=-2" );
57 like( $result->output, '/^PROCS WARNING: 3 processes with UID = -2 \(nobody\)$/', "Output correct" );
54 58
55$result = NPTest->testCmd( "$command -u -2 -w 3:3" ); 59 $result = NPTest->testCmd( "$command -u -2 -w 3:3" );
56is( $result->return_code, 0, "Checking processes with userid=-2 past threshold" ); 60 is( $result->return_code, 0, "Checking processes with userid=-2 past threshold" );
57like( $result->output, '/^PROCS OK: 3 processes with UID = -2 \(nobody\)$/', "Output correct" ); 61 like( $result->output, '/^PROCS OK: 3 processes with UID = -2 \(nobody\)$/', "Output correct" );
58 62
59$result = NPTest->testCmd( "$command -u -2 -a usb" ); 63 $result = NPTest->testCmd( "$command -u -2 -a usb" );
60is( $result->return_code, 0, "Checking processes with userid=-2 and usb in arguments" ); 64 is( $result->return_code, 0, "Checking processes with userid=-2 and usb in arguments" );
61like( $result->output, '/^PROCS OK: 1 process with UID = -2 \(nobody\), args \'usb\'/', "Output correct" ); 65 like( $result->output, '/^PROCS OK: 1 process with UID = -2 \(nobody\), args \'usb\'/', "Output correct" );
62 66
63$result = NPTest->testCmd( "$command -u -2 -a UsB" ); 67 $result = NPTest->testCmd( "$command -u -2 -a UsB" );
64is( $result->return_code, 0, "Checking case sensitivity of args" ); 68 is( $result->return_code, 0, "Checking case sensitivity of args" );
65like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" ); 69 like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" );
70};
66 71
67$result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" ); 72$result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" );
68is( $result->return_code, 0, "Checking regexp search of arguments" ); 73is( $result->return_code, 0, "Checking regexp search of arguments" );
diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t
index d865e190..aace9bcc 100755
--- a/plugins/tests/check_snmp.t
+++ b/plugins/tests/check_snmp.t
@@ -79,7 +79,7 @@ Copyright (c) 1986-2004 by cisco Systems, Inc.
79$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.0 -o sysContact.0 -o .1.3.6.1.4.1.8072.3.2.67.1"); 79$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.0 -o sysContact.0 -o .1.3.6.1.4.1.8072.3.2.67.1");
80cmp_ok( $res->return_code, '==', 0, "Exit OK when querying multi-line OIDs" ); 80cmp_ok( $res->return_code, '==', 0, "Exit OK when querying multi-line OIDs" );
81like($res->output, '/^SNMP OK - /', "String contains SNMP OK"); 81like($res->output, '/^SNMP OK - /', "String contains SNMP OK");
82like($res->output, '/'.quotemeta('SNMP OK - Cisco Internetwork Operating System Software "Alice" Kisco Outernetwork Oserating Gystem Totware | 82like($res->output, '/'.quotemeta('SNMP OK - Cisco Internetwork Operating System Software ').'"?Alice"?'.quotemeta(' Kisco Outernetwork Oserating Gystem Totware |
83.1.3.6.1.4.1.8072.3.2.67.0: 83.1.3.6.1.4.1.8072.3.2.67.0:
84"Cisco Internetwork Operating System Software 84"Cisco Internetwork Operating System Software
85IOS (tm) Catalyst 4000 \"L3\" Switch Software (cat4000-I9K91S-M), Version 85IOS (tm) Catalyst 4000 \"L3\" Switch Software (cat4000-I9K91S-M), Version