summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS8
-rw-r--r--THANKS.in6
-rw-r--r--configure.ac7
-rw-r--r--lib/utils_base.c15
-rwxr-xr-xplugins-scripts/check_ifstatus.pl59
-rw-r--r--plugins-scripts/t/check_disk_smb.t2
-rw-r--r--plugins/check_by_ssh.c3
-rw-r--r--plugins/check_dig.c9
-rw-r--r--plugins/check_disk.c16
-rw-r--r--plugins/check_dns.c22
-rw-r--r--plugins/check_hpjd.c30
-rw-r--r--plugins/check_mysql.c22
-rw-r--r--plugins/check_ntp_peer.c58
-rw-r--r--plugins/check_ntp_time.c15
-rw-r--r--plugins/netutils.c15
-rw-r--r--plugins/sslutils.c9
-rw-r--r--plugins/t/NPTest.cache.travis2
-rw-r--r--plugins/t/check_dns.t14
-rw-r--r--plugins/t/check_hpjd.t35
-rw-r--r--plugins/t/check_ntp.t4
-rw-r--r--plugins/t/negate.t5
-rwxr-xr-xplugins/tests/check_http.t8
-rwxr-xr-xplugins/tests/check_snmp.t11
-rwxr-xr-xtest.pl.in2
-rwxr-xr-xtools/generate-change-log2
25 files changed, 289 insertions, 90 deletions
diff --git a/NEWS b/NEWS
index 8109f80..73af0c0 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,12 @@
1This file documents the major additions and syntax changes between releases. 1This file documents the major additions and syntax changes between releases.
2 2
32.0.1 ... 32.1
4 ENHANCEMENTS
5 New check_hpjd -p option for port specification (abrist)
6 New ./configure --with-qmail-qstat-command option to specify the path to
7 qmail-qstat(8)
8 New check_ifstatus -n option to ignore interfaces by name
9
4 FIXES 10 FIXES
5 Fix check_jabber to work with Openfire servers 11 Fix check_jabber to work with Openfire servers
6 12
diff --git a/THANKS.in b/THANKS.in
index 7e3295b..75ecd56 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -323,5 +323,11 @@ Eric J. Mislivec
323Jean-Claude Computing 323Jean-Claude Computing
324Andy Brist 324Andy Brist
325Mikael Falkvidd 325Mikael Falkvidd
326Patric Wust
327Julius Kriukas
328Patrick McAndrew
329Alexander Wittig
330Jason Benguerel
331Matthew Kent
326Frederic Krueger 332Frederic Krueger
327Simon Meggle 333Simon Meggle
diff --git a/configure.ac b/configure.ac
index f6ead58..1fa7472 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1478,9 +1478,12 @@ else
1478fi 1478fi
1479 1479
1480AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat) 1480AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
1481if test -x "$PATH_TO_QMAIL_QSTAT" 1481AC_ARG_WITH(qmail_qstat_command,
1482 ACX_HELP_STRING([--with-qmail-qstat-command=PATH],
1483 [sets path to qmail-qstat]), PATH_TO_QMAIL_QSTAT=$withval)
1484if test -n "$PATH_TO_QMAIL_QSTAT"
1482then 1485then
1483 AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat]) 1486 AC_DEFINE_UNQUOTED(PATH_TO_QMAIL_QSTAT,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1484else 1487else
1485 AC_MSG_WARN([Could not find qmail-qstat or eqivalent]) 1488 AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
1486fi 1489fi
diff --git a/lib/utils_base.c b/lib/utils_base.c
index addf26b..4fb6375 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -446,6 +446,7 @@ void np_enable_state(char *keyname, int expected_data_version) {
446 char *temp_filename = NULL; 446 char *temp_filename = NULL;
447 char *temp_keyname = NULL; 447 char *temp_keyname = NULL;
448 char *p=NULL; 448 char *p=NULL;
449 int ret;
449 450
450 if(this_monitoring_plugin==NULL) 451 if(this_monitoring_plugin==NULL)
451 die(STATE_UNKNOWN, _("This requires np_init to be called")); 452 die(STATE_UNKNOWN, _("This requires np_init to be called"));
@@ -476,9 +477,13 @@ void np_enable_state(char *keyname, int expected_data_version) {
476 this_state->state_data=NULL; 477 this_state->state_data=NULL;
477 478
478 /* Calculate filename */ 479 /* Calculate filename */
479 asprintf(&temp_filename, "%s/%lu/%s/%s", 480 ret = xasprintf(&temp_filename, "%s/%lu/%s/%s",
480 _np_state_calculate_location_prefix(), (unsigned long)geteuid(), 481 _np_state_calculate_location_prefix(), (unsigned long)geteuid(),
481 this_monitoring_plugin->plugin_name, this_state->name); 482 this_monitoring_plugin->plugin_name, this_state->name);
483 if (ret < 0)
484 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"),
485 strerror(errno));
486
482 this_state->_filename=temp_filename; 487 this_state->_filename=temp_filename;
483 488
484 this_monitoring_plugin->state = this_state; 489 this_monitoring_plugin->state = this_state;
@@ -614,8 +619,8 @@ void np_state_write_string(time_t data_time, char *data_string) {
614 619
615 /* If file doesn't currently exist, create directories */ 620 /* If file doesn't currently exist, create directories */
616 if(access(this_monitoring_plugin->state->_filename,F_OK)!=0) { 621 if(access(this_monitoring_plugin->state->_filename,F_OK)!=0) {
617 asprintf(&directories, "%s", this_monitoring_plugin->state->_filename); 622 result = xasprintf(&directories, "%s", this_monitoring_plugin->state->_filename);
618 if(directories==NULL) 623 if(result < 0)
619 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"), 624 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"),
620 strerror(errno)); 625 strerror(errno));
621 626
@@ -633,8 +638,8 @@ void np_state_write_string(time_t data_time, char *data_string) {
633 np_free(directories); 638 np_free(directories);
634 } 639 }
635 640
636 asprintf(&temp_file,"%s.XXXXXX",this_monitoring_plugin->state->_filename); 641 result = xasprintf(&temp_file,"%s.XXXXXX",this_monitoring_plugin->state->_filename);
637 if(temp_file==NULL) 642 if(result < 0)
638 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"), 643 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"),
639 strerror(errno)); 644 strerror(errno));
640 645
diff --git a/plugins-scripts/check_ifstatus.pl b/plugins-scripts/check_ifstatus.pl
index fb17d98..9aa2515 100755
--- a/plugins-scripts/check_ifstatus.pl
+++ b/plugins-scripts/check_ifstatus.pl
@@ -9,6 +9,7 @@
9# Added -u option (4/2003) 9# Added -u option (4/2003)
10# Added -M option (10/2003) 10# Added -M option (10/2003)
11# Added SNMPv3 support (10/2003) 11# Added SNMPv3 support (10/2003)
12# Added -n option (07/2014)
12# 13#
13# This program is free software; you can redistribute it and/or 14# This program is free software; you can redistribute it and/or
14# modify it under the terms of the GNU General Public License 15# modify it under the terms of the GNU General Public License
@@ -95,8 +96,10 @@ my $ifXTable;
95my $opt_h ; 96my $opt_h ;
96my $opt_V ; 97my $opt_V ;
97my $opt_u; 98my $opt_u;
99my $opt_n;
98my $opt_x ; 100my $opt_x ;
99my %excluded ; 101my %excluded ;
102my %unused_names ;
100my @unused_ports ; 103my @unused_ports ;
101my %session_opts; 104my %session_opts;
102 105
@@ -171,27 +174,30 @@ alarm(0);
171foreach $key (keys %ifStatus) { 174foreach $key (keys %ifStatus) {
172 175
173 # skip unused interfaces 176 # skip unused interfaces
174 if (!defined($ifStatus{$key}{'notInUse'})) { 177 my $ifName = $ifStatus{$key}{$snmpIfDescr};
178
179 if (!defined($ifStatus{$key}{'notInUse'}) || !grep(/^${ifName}/, @unused_ports )) {
175 # check only if interface is administratively up 180 # check only if interface is administratively up
176 if ($ifStatus{$key}{$snmpIfAdminStatus} == 1 ) { 181 if ($ifStatus{$key}{$snmpIfAdminStatus} == 1 ) {
177 182 #check only if interface is not excluded
178 # check only if interface type is not listed in %excluded 183 if (!defined $unused_names{$ifStatus{$key}{$snmpIfDescr}} ) {
179 if (!defined $excluded{$ifStatus{$key}{$snmpIfType}} ) { 184 # check only if interface type is not listed in %excluded
180 if ($ifStatus{$key}{$snmpIfOperStatus} == 1 ) { $ifup++ ;} 185 if (!defined $excluded{$ifStatus{$key}{$snmpIfType}} ) {
181 if ($ifStatus{$key}{$snmpIfOperStatus} == 2 ) { 186 if ($ifStatus{$key}{$snmpIfOperStatus} == 1 ) { $ifup++ ; }
182 $ifdown++ ; 187 if ($ifStatus{$key}{$snmpIfOperStatus} == 2 ) {
183 if (defined $ifXTable) { 188 $ifdown++ ;
184 $ifmessage .= sprintf("%s: down -> %s<BR>", 189 if (defined $ifXTable) {
185 $ifStatus{$key}{$snmpIfName}, 190 $ifmessage .= sprintf("%s: down -> %s<BR>\n", $ifStatus{$key}{$snmpIfName}, $ifStatus{$key}{$snmpIfAlias});
186 $ifStatus{$key}{$snmpIfAlias}); 191 }else{
187 }else{ 192 $ifmessage .= sprintf("%s: down <BR>\n",$ifStatus{$key}{$snmpIfDescr});
188 $ifmessage .= sprintf("%s: down <BR>", 193 }
189 $ifStatus{$key}{$snmpIfDescr}); 194 }
190 } 195 if ($ifStatus{$key}{$snmpIfOperStatus} == 5 ) { $ifdormant++ ;}
196 } else {
197 $ifexclude++;
191 } 198 }
192 if ($ifStatus{$key}{$snmpIfOperStatus} == 5 ) { $ifdormant++ ;} 199 } else {
193 }else{ 200 $ifunused++;
194 $ifexclude++;
195 } 201 }
196 202
197 } 203 }
@@ -221,7 +227,7 @@ foreach $key (keys %ifStatus) {
221 $ifexclude, 227 $ifexclude,
222 $ifunused); 228 $ifunused);
223 } 229 }
224my $perfdata = sprintf("up=%d,down=%d,dormant=%d,excluded=%d,unused=%d",$ifup,$ifdown,$ifdormant,$ifexclude,$ifunused); 230my $perfdata = sprintf("up=%d down=%d dormant=%d excluded=%d unused=%d",$ifup,$ifdown,$ifdormant,$ifexclude,$ifunused);
225print ("$state: $answer |$perfdata\n"); 231print ("$state: $answer |$perfdata\n");
226exit $ERRORS{$state}; 232exit $ERRORS{$state};
227 233
@@ -259,6 +265,8 @@ sub print_help() {
259 printf " the descriptive name. Do not use if you don't know what this is. \n"; 265 printf " the descriptive name. Do not use if you don't know what this is. \n";
260 printf " -x (--exclude) A comma separated list of ifType values that should be excluded \n"; 266 printf " -x (--exclude) A comma separated list of ifType values that should be excluded \n";
261 printf " from the report (default for an empty list is PPP(23).\n"; 267 printf " from the report (default for an empty list is PPP(23).\n";
268 printf " -n (--unused_ports_by_name) A comma separated list of ifDescr values that should be excluded \n";
269 printf " from the report (default is an empty exclusion list).\n";
262 printf " -u (--unused_ports) A comma separated list of ifIndex values that should be excluded \n"; 270 printf " -u (--unused_ports) A comma separated list of ifIndex values that should be excluded \n";
263 printf " from the report (default is an empty exclusion list).\n"; 271 printf " from the report (default is an empty exclusion list).\n";
264 printf " See the IANAifType-MIB for a list of interface types.\n"; 272 printf " See the IANAifType-MIB for a list of interface types.\n";
@@ -299,6 +307,7 @@ sub process_arguments() {
299 "I" => \$ifXTable, "ifmib" => \$ifXTable, 307 "I" => \$ifXTable, "ifmib" => \$ifXTable,
300 "x:s" => \$opt_x, "exclude:s" => \$opt_x, 308 "x:s" => \$opt_x, "exclude:s" => \$opt_x,
301 "u=s" => \$opt_u, "unused_ports=s" => \$opt_u, 309 "u=s" => \$opt_u, "unused_ports=s" => \$opt_u,
310 "n=s" => \$opt_n, "unused_ports_by_name=s" => \$opt_n,
302 "M=i" => \$maxmsgsize, "maxmsgsize=i" => \$maxmsgsize, 311 "M=i" => \$maxmsgsize, "maxmsgsize=i" => \$maxmsgsize,
303 "t=i" => \$timeout, "timeout=i" => \$timeout, 312 "t=i" => \$timeout, "timeout=i" => \$timeout,
304 ); 313 );
@@ -406,6 +415,16 @@ sub process_arguments() {
406 } 415 }
407 } 416 }
408 417
418 # Excluded interface descriptors
419 if (defined $opt_n) {
420 my @unused = split(/,/,$opt_n);
421 if ( @unused ) {
422 foreach $key (@unused) {
423 $unused_names{$key} = 1;
424 }
425 }
426 }
427
409 # Excluded interface ports (ifIndex) - management reasons 428 # Excluded interface ports (ifIndex) - management reasons
410 if ($opt_u) { 429 if ($opt_u) {
411 @unused_ports = split(/,/,$opt_u); 430 @unused_ports = split(/,/,$opt_u);
diff --git a/plugins-scripts/t/check_disk_smb.t b/plugins-scripts/t/check_disk_smb.t
index 831f388..c2e8bbb 100644
--- a/plugins-scripts/t/check_disk_smb.t
+++ b/plugins-scripts/t/check_disk_smb.t
@@ -90,7 +90,7 @@ SKIP: {
90 SKIP: { 90 SKIP: {
91 skip "no non responsive host defined", 1 if ( ! $host_nonresponsive ); 91 skip "no non responsive host defined", 1 if ( ! $host_nonresponsive );
92 $res = NPTest->testCmd( "./$plugin -H $host_nonresponsive -s np_foobar "); 92 $res = NPTest->testCmd( "./$plugin -H $host_nonresponsive -s np_foobar ");
93 cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN with non responsive host" ); 93 cmp_ok( $res->return_code, '>=', 2, "Exit CRITICAL/UNKNOWN with non responsive host" );
94 } 94 }
95 95
96} 96}
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index 58f333d..a877f88 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -169,7 +169,8 @@ process_arguments (int argc, char **argv)
169 {"verbose", no_argument, 0, 'v'}, 169 {"verbose", no_argument, 0, 'v'},
170 {"fork", no_argument, 0, 'f'}, 170 {"fork", no_argument, 0, 'f'},
171 {"timeout", required_argument, 0, 't'}, 171 {"timeout", required_argument, 0, 't'},
172 {"host", required_argument, 0, 'H'}, 172 {"host", required_argument, 0, 'H'}, /* backward compatibility */
173 {"hostname", required_argument, 0, 'H'},
173 {"port", required_argument,0,'p'}, 174 {"port", required_argument,0,'p'},
174 {"output", required_argument, 0, 'O'}, 175 {"output", required_argument, 0, 'O'},
175 {"name", required_argument, 0, 'n'}, 176 {"name", required_argument, 0, 'n'},
diff --git a/plugins/check_dig.c b/plugins/check_dig.c
index d9481f2..d899b11 100644
--- a/plugins/check_dig.c
+++ b/plugins/check_dig.c
@@ -94,8 +94,8 @@ 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 -p %d %s -t %s %s %s +tries=%d +time=%d", 97 xasprintf (&command_line, "%s %s %s -p %d @%s %s %s +tries=%d +time=%d",
98 PATH_TO_DIG, dns_server, server_port, query_address, record_type, dig_args, query_transport, 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);
101 gettimeofday (&tv, NULL); 101 gettimeofday (&tv, NULL);
@@ -296,7 +296,10 @@ process_arguments (int argc, char **argv)
296 dns_server = argv[c]; 296 dns_server = argv[c];
297 } 297 }
298 else { 298 else {
299 dns_server = strdup ("127.0.0.1"); 299 if (strcmp(query_transport,"-6") == 0)
300 dns_server = strdup("::1");
301 else
302 dns_server = strdup ("127.0.0.1");
300 } 303 }
301 } 304 }
302 305
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 925dfa8..0d73a4f 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -171,6 +171,7 @@ main (int argc, char **argv)
171 char *details; 171 char *details;
172 char *perf; 172 char *perf;
173 char *preamble; 173 char *preamble;
174 char *flag_header;
174 double inode_space_pct; 175 double inode_space_pct;
175 double warning_high_tide; 176 double warning_high_tide;
176 double critical_high_tide; 177 double critical_high_tide;
@@ -353,18 +354,23 @@ main (int argc, char **argv)
353 if (disk_result==STATE_OK && erronly && !verbose) 354 if (disk_result==STATE_OK && erronly && !verbose)
354 continue; 355 continue;
355 356
356 xasprintf (&output, "%s %s %.0f %s (%.0f%%", 357 if(disk_result && verbose >= 1) {
357 output, 358 xasprintf(&flag_header, " %s [", state_text (disk_result));
359 } else {
360 xasprintf(&flag_header, "");
361 }
362 xasprintf (&output, "%s%s %s %.0f %s (%.0f%%",
363 output, flag_header,
358 (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir, 364 (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
359 path->dfree_units, 365 path->dfree_units,
360 units, 366 units,
361 path->dfree_pct); 367 path->dfree_pct);
362 if (path->dused_inodes_percent < 0) { 368 if (path->dused_inodes_percent < 0) {
363 xasprintf(&output, "%s inode=-);", output); 369 xasprintf(&output, "%s inode=-)%s;", output, (disk_result ? "]" : ""));
364 } else { 370 } else {
365 xasprintf(&output, "%s inode=%.0f%%);", output, path->dfree_inodes_percent ); 371 xasprintf(&output, "%s inode=%.0f%%)%s;", output, path->dfree_inodes_percent, ((disk_result && verbose >= 1) ? "]" : ""));
366 } 372 }
367 373 free(flag_header);
368 /* TODO: Need to do a similar debug line 374 /* TODO: Need to do a similar debug line
369 xasprintf (&details, _("%s\n\ 375 xasprintf (&details, _("%s\n\
370%.0f of %.0f %s (%.0f%% inode=%.0f%%) free on %s (type %s mounted on %s) warn:%lu crit:%lu warn%%:%.0f%% crit%%:%.0f%%"), 376%.0f of %.0f %s (%.0f%% inode=%.0f%%) free on %s (type %s mounted on %s) warn:%lu crit:%lu warn%%:%.0f%% crit%%:%.0f%%"),
diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index 31a953d..2212122 100644
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
@@ -136,6 +136,28 @@ main (int argc, char **argv)
136 } 136 }
137 } 137 }
138 138
139 /* bug ID: 2946553 - Older versions of bind will use all available dns
140 servers, we have to match the one specified */
141 if (strstr (chld_out.line[i], "Server:") && strlen(dns_server) > 0) {
142 temp_buffer = strchr (chld_out.line[i], ':');
143 temp_buffer++;
144
145 /* Strip leading tabs */
146 for (; *temp_buffer != '\0' && *temp_buffer == '\t'; temp_buffer++)
147 /* NOOP */;
148
149 strip(temp_buffer);
150 if (temp_buffer==NULL || strlen(temp_buffer)==0) {
151 die (STATE_CRITICAL,
152 _("DNS CRITICAL - '%s' returned empty server string\n"),
153 NSLOOKUP_COMMAND);
154 }
155
156 if (strcmp(temp_buffer, dns_server) != 0) {
157 die (STATE_CRITICAL, _("DNS CRITICAL - No response from DNS %s\n"), dns_server);
158 }
159 }
160
139 /* the server is responding, we just got the host name... */ 161 /* the server is responding, we just got the host name... */
140 if (strstr (chld_out.line[i], "Name:")) 162 if (strstr (chld_out.line[i], "Name:"))
141 parse_address = TRUE; 163 parse_address = TRUE;
diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c
index 1e7605b..5fe0698 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_mysql.c b/plugins/check_mysql.c
index 4f09e5f..216626b 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_ntp_peer.c b/plugins/check_ntp_peer.c
index 8dc1978..44424af 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,22 @@ 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 oresult = result;
601
602 if(do_truechimers) {
603 tresult = get_status(num_truechimers, truechimer_thresholds);
604 result = max_state_alt(result, tresult);
605 }
600 606
601 if(do_truechimers) 607 if(do_stratum) {
602 result = max_state_alt(result, get_status(num_truechimers, truechimer_thresholds)); 608 sresult = get_status(stratum, stratum_thresholds);
603 609 result = max_state_alt(result, sresult);
604 if(do_stratum) 610 }
605 result = max_state_alt(result, get_status(stratum, stratum_thresholds));
606 611
607 if(do_jitter) 612 if(do_jitter) {
608 result = max_state_alt(result, get_status(jitter, jitter_thresholds)); 613 jresult = get_status(jitter, jitter_thresholds);
614 result = max_state_alt(result, jresult);
615 }
609 616
610 switch (result) { 617 switch (result) {
611 case STATE_CRITICAL : 618 case STATE_CRITICAL :
@@ -629,20 +636,43 @@ int main(int argc, char *argv[]){
629 if(offset_result == STATE_UNKNOWN){ 636 if(offset_result == STATE_UNKNOWN){
630 xasprintf(&result_line, "%s %s", result_line, _("Offset unknown")); 637 xasprintf(&result_line, "%s %s", result_line, _("Offset unknown"));
631 xasprintf(&perfdata_line, ""); 638 xasprintf(&perfdata_line, "");
639 } else if (oresult == STATE_WARNING) {
640 xasprintf(&result_line, "%s %s %.10g secs (WARNING)", result_line, _("Offset"), offset);
641 } else if (oresult == STATE_CRITICAL) {
642 xasprintf(&result_line, "%s %s %.10g secs (CRITICAL)", result_line, _("Offset"), offset);
632 } else { 643 } else {
633 xasprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset); 644 xasprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset);
634 xasprintf(&perfdata_line, "%s", perfd_offset(offset)); 645 }
635 } 646 xasprintf(&perfdata_line, "%s", perfd_offset(offset));
647
636 if (do_jitter) { 648 if (do_jitter) {
637 xasprintf(&result_line, "%s, jitter=%f", result_line, jitter); 649 if (jresult == STATE_WARNING) {
650 xasprintf(&result_line, "%s, jitter=%f (WARNING)", result_line, jitter);
651 } else if (jresult == STATE_CRITICAL) {
652 xasprintf(&result_line, "%s, jitter=%f (CRITICAL)", result_line, jitter);
653 } else {
654 xasprintf(&result_line, "%s, jitter=%f", result_line, jitter);
655 }
638 xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_jitter(jitter)); 656 xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_jitter(jitter));
639 } 657 }
640 if (do_stratum) { 658 if (do_stratum) {
641 xasprintf(&result_line, "%s, stratum=%i", result_line, stratum); 659 if (sresult == STATE_WARNING) {
660 xasprintf(&result_line, "%s, stratum=%i (WARNING)", result_line, stratum);
661 } else if (sresult == STATE_CRITICAL) {
662 xasprintf(&result_line, "%s, stratum=%i (CRITICAL)", result_line, stratum);
663 } else {
664 xasprintf(&result_line, "%s, stratum=%i", result_line, stratum);
665 }
642 xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_stratum(stratum)); 666 xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_stratum(stratum));
643 } 667 }
644 if (do_truechimers) { 668 if (do_truechimers) {
645 xasprintf(&result_line, "%s, truechimers=%i", result_line, num_truechimers); 669 if (tresult == STATE_WARNING) {
670 xasprintf(&result_line, "%s, truechimers=%i (WARNING)", result_line, num_truechimers);
671 } else if (tresult == STATE_CRITICAL) {
672 xasprintf(&result_line, "%s, truechimers=%i (CRITICAL)", result_line, num_truechimers);
673 } else {
674 xasprintf(&result_line, "%s, truechimers=%i", result_line, num_truechimers);
675 }
646 xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_truechimers(num_truechimers)); 676 xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_truechimers(num_truechimers));
647 } 677 }
648 printf("%s|%s\n", result_line, perfdata_line); 678 printf("%s|%s\n", result_line, perfdata_line);
@@ -651,8 +681,6 @@ int main(int argc, char *argv[]){
651 return result; 681 return result;
652} 682}
653 683
654
655
656void print_help(void){ 684void print_help(void){
657 print_revision(progname, NP_VERSION); 685 print_revision(progname, NP_VERSION);
658 686
diff --git a/plugins/check_ntp_time.c b/plugins/check_ntp_time.c
index 72dffbd..e344f8b 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/netutils.c b/plugins/netutils.c
index 0044046..83f8942 100644
--- a/plugins/netutils.c
+++ b/plugins/netutils.c
@@ -167,11 +167,12 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
167 char port_str[6], host[MAX_HOST_ADDRESS_LENGTH]; 167 char port_str[6], host[MAX_HOST_ADDRESS_LENGTH];
168 size_t len; 168 size_t len;
169 int socktype, result; 169 int socktype, result;
170 short is_socket = (host_name[0] == '/');
170 171
171 socktype = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM; 172 socktype = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM;
172 173
173 /* as long as it doesn't start with a '/', it's assumed a host or ip */ 174 /* as long as it doesn't start with a '/', it's assumed a host or ip */
174 if(host_name[0] != '/'){ 175 if (!is_socket){
175 memset (&hints, 0, sizeof (hints)); 176 memset (&hints, 0, sizeof (hints));
176 hints.ai_family = address_family; 177 hints.ai_family = address_family;
177 hints.ai_protocol = proto; 178 hints.ai_protocol = proto;
@@ -253,7 +254,11 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
253 return econn_refuse_state; 254 return econn_refuse_state;
254 break; 255 break;
255 case STATE_CRITICAL: /* user did not set econn_refuse_state */ 256 case STATE_CRITICAL: /* user did not set econn_refuse_state */
256 printf ("%s\n", strerror(errno)); 257 if (is_socket)
258 printf("connect to file socket %s: %s\n", host_name, strerror(errno));
259 else
260 printf("connect to address %s and port %d: %s\n",
261 host_name, port, strerror(errno));
257 return econn_refuse_state; 262 return econn_refuse_state;
258 break; 263 break;
259 default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */ 264 default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */
@@ -262,7 +267,11 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
262 } 267 }
263 } 268 }
264 else { 269 else {
265 printf ("%s\n", strerror(errno)); 270 if (is_socket)
271 printf("connect to file socket %s: %s\n", host_name, strerror(errno));
272 else
273 printf("connect to address %s and port %d: %s\n",
274 host_name, port, strerror(errno));
266 return STATE_CRITICAL; 275 return STATE_CRITICAL;
267 } 276 }
268} 277}
diff --git a/plugins/sslutils.c b/plugins/sslutils.c
index 687bffb..d0ae474 100644
--- a/plugins/sslutils.c
+++ b/plugins/sslutils.c
@@ -153,7 +153,8 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
153 struct tm stamp; 153 struct tm stamp;
154 float time_left; 154 float time_left;
155 int days_left; 155 int days_left;
156 char timestamp[17] = ""; 156 char timestamp[50] = "";
157 time_t tm_t;
157 158
158 certificate=SSL_get_peer_certificate(s); 159 certificate=SSL_get_peer_certificate(s);
159 if (!certificate) { 160 if (!certificate) {
@@ -211,10 +212,8 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
211 212
212 time_left = difftime(timegm(&stamp), time(NULL)); 213 time_left = difftime(timegm(&stamp), time(NULL));
213 days_left = time_left / 86400; 214 days_left = time_left / 86400;
214 snprintf 215 tm_t = mktime (&stamp);
215 (timestamp, 17, "%02d/%02d/%04d %02d:%02d", 216 strftime(timestamp, 50, "%c", localtime(&tm_t));
216 stamp.tm_mon + 1,
217 stamp.tm_mday, stamp.tm_year + 1900, stamp.tm_hour, stamp.tm_min);
218 217
219 if (days_left > 0 && days_left <= days_till_exp_warn) { 218 if (days_left > 0 && days_left <= days_till_exp_warn) {
220 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
index c1007de..4ebfb90 100644
--- a/plugins/t/NPTest.cache.travis
+++ b/plugins/t/NPTest.cache.travis
@@ -14,6 +14,8 @@
14 'NP_HOST_SNMP' => '', 14 'NP_HOST_SNMP' => '',
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',
18 'NP_HOST_HPJD_PORT_VALID' => '',
17 'NP_HOST_TCP_HTTP' => 'localhost', 19 'NP_HOST_TCP_HTTP' => 'localhost',
18 'NP_HOST_TCP_HTTP2' => 'labs.consol.de', 20 'NP_HOST_TCP_HTTP2' => 'labs.consol.de',
19 'NP_HOST_TCP_IMAP' => 'imap.web.de', 21 'NP_HOST_TCP_IMAP' => 'imap.web.de',
diff --git a/plugins/t/check_dns.t b/plugins/t/check_dns.t
index 4ff553f..035e768 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 => 14; 13plan tests => 16;
14 14
15my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/'; 15my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/';
16 16
@@ -43,6 +43,12 @@ my $dns_server = getTestParameter(
43 "A non default (remote) DNS server", 43 "A non default (remote) DNS server",
44 ); 44 );
45 45
46my $host_nonresponsive = getTestParameter(
47 "NP_HOST_NONRESPONSIVE",
48 "The hostname of system not responsive to network requests",
49 "10.0.0.1",
50 );
51
46my $res; 52my $res;
47 53
48$res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5"); 54$res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5");
@@ -54,7 +60,7 @@ cmp_ok( $res->return_code, '==', 2, "Critical threshold passed");
54 60
55$res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5 -w 0 -c 5"); 61$res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5 -w 0 -c 5");
56cmp_ok( $res->return_code, '==', 1, "Warning threshold passed"); 62cmp_ok( $res->return_code, '==', 1, "Warning threshold passed");
57like( $res->output, "/\|time=[\d\.]+s;0.0*;5\.0*;0\.0*/", "Output performance data OK" ); 63like( $res->output, '/\|time=[\d\.]+s;0.0*;5\.0*;0\.0*/', "Output performance data OK" );
58 64
59$res = NPTest->testCmd("./check_dns -H $hostname_invalid -t 1"); 65$res = NPTest->testCmd("./check_dns -H $hostname_invalid -t 1");
60cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid"); 66cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid");
@@ -66,6 +72,10 @@ like ( $res->output, $successOutput, "Output OK" );
66$res = NPTest->testCmd("./check_dns -H $hostname_invalid -s $dns_server -t 1"); 72$res = NPTest->testCmd("./check_dns -H $hostname_invalid -s $dns_server -t 1");
67cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid on $dns_server"); 73cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid on $dns_server");
68 74
75$res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_ip -s $host_nonresponsive -t 2");
76cmp_ok( $res->return_code, '==', 2, "Got no answer from unresponsive server");
77like ( $res->output, "/CRITICAL - /", "Output OK");
78
69$res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_ip -t 5"); 79$res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_ip -t 5");
70cmp_ok( $res->return_code, '==', 0, "Got expected address"); 80cmp_ok( $res->return_code, '==', 0, "Got expected address");
71 81
diff --git a/plugins/t/check_hpjd.t b/plugins/t/check_hpjd.t
index 10ded54..4d64852 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_ntp.t b/plugins/t/check_ntp.t
index 74d890f..b8fc8fd 100644
--- a/plugins/t/check_ntp.t
+++ b/plugins/t/check_ntp.t
@@ -35,8 +35,8 @@ my $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
diff --git a/plugins/t/negate.t b/plugins/t/negate.t
index f18acc3..d96a109 100644
--- a/plugins/t/negate.t
+++ b/plugins/t/negate.t
@@ -6,6 +6,7 @@
6 6
7use strict; 7use strict;
8use Test::More; 8use Test::More;
9use Cwd;
9use NPTest; 10use NPTest;
10 11
11# 15 tests in the first part, 9 in timeout tests and 2 * 32 in the last loops 12# 15 tests in the first part, 9 in timeout tests and 2 * 32 in the last loops
@@ -13,7 +14,7 @@ plan tests => 88;
13 14
14my $res; 15my $res;
15 16
16my $PWD = $ENV{PWD}; 17my $PWD = getcwd();
17 18
18$res = NPTest->testCmd( "./negate" ); 19$res = NPTest->testCmd( "./negate" );
19is( $res->return_code, 3, "Not enough parameters"); 20is( $res->return_code, 3, "Not enough parameters");
@@ -50,7 +51,7 @@ is( $res->output, "OK: a dummy okay", "The quoted string is passed through to su
50$res = NPTest->testCmd( "./negate '$PWD/check_dummy 0' 'a dummy okay'" ); 51$res = NPTest->testCmd( "./negate '$PWD/check_dummy 0' 'a dummy okay'" );
51is( $res->output, "No data returned from command", "Bad command, as expected (trying to execute './check_dummy 0')"); 52is( $res->output, "No data returned from command", "Bad command, as expected (trying to execute './check_dummy 0')");
52 53
53$res = NPTest->testCmd( './negate $PWD/check_dummy 0 \'$$ a dummy okay\'' ); 54$res = NPTest->testCmd( './negate '.$PWD.'/check_dummy 0 \'$$ a dummy okay\'' );
54is( $res->output, 'OK: $$ a dummy okay', 'Proves that $$ is not being expanded again' ); 55is( $res->output, 'OK: $$ a dummy okay', 'Proves that $$ is not being expanded again' );
55 56
56my %state = ( 57my %state = (
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t
index 225b449..d93a0ec 100755
--- a/plugins/tests/check_http.t
+++ b/plugins/tests/check_http.t
@@ -186,21 +186,21 @@ SKIP: {
186 186
187 $result = NPTest->testCmd( "$command -p $port_https -S -C 14" ); 187 $result = NPTest->testCmd( "$command -p $port_https -S -C 14" );
188 is( $result->return_code, 0, "$command -p $port_https -S -C 14" ); 188 is( $result->return_code, 0, "$command -p $port_https -S -C 14" );
189 is( $result->output, 'OK - Certificate \'Ton Voon\' will expire on 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" );
190 190
191 $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" ); 191 $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" );
192 is( $result->return_code, 1, "$command -p $port_https -S -C 14000" ); 192 is( $result->return_code, 1, "$command -p $port_https -S -C 14000" );
193 like( $result->output, '/WARNING - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(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" );
194 194
195 # Expired cert tests 195 # Expired cert tests
196 $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" ); 196 $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" );
197 is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" ); 197 is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" );
198 like( $result->output, '/CRITICAL - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(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" );
199 199
200 $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" ); 200 $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" );
201 is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" ); 201 is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" );
202 is( $result->output, 202 is( $result->output,
203 'CRITICAL - Certificate \'Ton Voon\' expired on 03/05/2009 00:13.', 203 'CRITICAL - Certificate \'Ton Voon\' expired on Thu Mar 5 00:13:00 2009.',
204 "output ok" ); 204 "output ok" );
205 205
206} 206}
diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t
index aace9bc..2fd033d 100755
--- a/plugins/tests/check_snmp.t
+++ b/plugins/tests/check_snmp.t
@@ -20,7 +20,16 @@ if ($@) {
20 plan skip_all => "Missing required module for test: $@"; 20 plan skip_all => "Missing required module for test: $@";
21} else { 21} else {
22 if (-x "./check_snmp") { 22 if (-x "./check_snmp") {
23 plan tests => $tests; 23 # check if snmpd has perl support
24 my $test = `snmpd -c tests/conf/snmpd.conf -C -r -H 2>&1`;
25 if(!defined $test) {
26 plan skip_all => "snmpd required";
27 }
28 elsif($test =~ m/Warning: Unknown token: perl/) {
29 plan skip_all => "snmpd has no perl support";
30 } else {
31 plan tests => $tests;
32 }
24 } else { 33 } else {
25 plan skip_all => "No check_snmp compiled"; 34 plan skip_all => "No check_snmp compiled";
26 } 35 }
diff --git a/test.pl.in b/test.pl.in
index 01a97ec..2f2c44f 100755
--- a/test.pl.in
+++ b/test.pl.in
@@ -9,6 +9,8 @@ use Getopt::Long;
9 9
10use NPTest qw(DetermineTestHarnessDirectory TestsFrom); 10use NPTest qw(DetermineTestHarnessDirectory TestsFrom);
11 11
12$ENV{LC_ALL} = 'C';
13
12my @tstdir; 14my @tstdir;
13 15
14if ( ! GetOptions( "testdir:s" => \@tstdir ) ) 16if ( ! GetOptions( "testdir:s" => \@tstdir ) )
diff --git a/tools/generate-change-log b/tools/generate-change-log
index 3a6b38e..ad19ce9 100755
--- a/tools/generate-change-log
+++ b/tools/generate-change-log
@@ -19,6 +19,7 @@ use Text::Wrap;
19 19
20# The lines will have a length of no more than $columns - 1. 20# The lines will have a length of no more than $columns - 1.
21$Text::Wrap::columns = 81; 21$Text::Wrap::columns = 81;
22$Text::Wrap::huge = 'overflow';
22 23
23if (system('git rev-parse --git-dir >/dev/null 2>&1') != 0) { 24if (system('git rev-parse --git-dir >/dev/null 2>&1') != 0) {
24 print "Not a Git repository, so I won't update the ChangeLog.\n"; 25 print "Not a Git repository, so I won't update the ChangeLog.\n";
@@ -51,6 +52,7 @@ while ($git_log =~ /$regex/gm) {
51 $prev_date = $commit{date}; 52 $prev_date = $commit{date};
52 $prev_name = $commit{name}; 53 $prev_name = $commit{name};
53 $prev_email = $commit{email}; 54 $prev_email = $commit{email};
55 $commit{message} =~ s/\s*Signed\-off\-by.*$//sgmx;
54 56
55 my @files = split(/\n/, $commit{files}); 57 my @files = split(/\n/, $commit{files});
56 my @message = map { s/^ {4}//; $_ } split(/\n/, $commit{message}); 58 my @message = map { s/^ {4}//; $_ } split(/\n/, $commit{message});