diff options
author | Lorenz <12514511+RincewindsHat@users.noreply.github.com> | 2022-01-03 13:48:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-03 13:48:39 +0100 |
commit | 2714df42fd27ec377228a102acff3744d6bff86d (patch) | |
tree | 3098fa3d9be4826e5da9d1df39ecf6b42bf3570b /plugins-root | |
parent | 11af74de386ba7c02d5d0e53f2500b5029a4537d (diff) | |
parent | 78a999edd4dd3305ef8fa3e06c43f6a893fb6fea (diff) | |
download | monitoring-plugins-2714df42fd27ec377228a102acff3744d6bff86d.tar.gz |
Merge branch 'master' into master
Diffstat (limited to 'plugins-root')
-rw-r--r-- | plugins-root/Makefile.am | 3 | ||||
-rw-r--r-- | plugins-root/check_icmp.c | 8 | ||||
-rw-r--r-- | plugins-root/t/check_dhcp.t | 9 |
3 files changed, 14 insertions, 6 deletions
diff --git a/plugins-root/Makefile.am b/plugins-root/Makefile.am index a1ebb6d2..7cd2675a 100644 --- a/plugins-root/Makefile.am +++ b/plugins-root/Makefile.am @@ -37,6 +37,9 @@ TESTS = @PLUGIN_TEST@ test: perl -I $(top_builddir) -I $(top_srcdir) ../test.pl +test-debug: + NPTEST_DEBUG=1 HARNESS_VERBOSE=1 perl -I $(top_builddir) -I $(top_srcdir) ../test.pl + setuid_root_mode = ug=rx,u+s # /* Author Coreutils team - see ACKNOWLEDGEMENTS */ diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index e45fdf60..01ae174a 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c @@ -502,7 +502,7 @@ main(int argc, char **argv) icmp_data_size = size; icmp_pkt_size = size + ICMP_MINLEN; } else - usage_va("ICMP data length must be between: %d and %d", + usage_va("ICMP data length must be between: %lu and %lu", sizeof(struct icmp) + sizeof(struct icmp_ping_data), MAX_PING_DATA - 1); break; @@ -921,7 +921,7 @@ wait_for_reply(int sock, u_int t) /* if we're in hostcheck mode, exit with limited printouts */ if(mode == MODE_HOSTCHECK) { printf("OK - %s responds to ICMP. Packet %u, rta %0.3fms|" - "pkt=%u;;0;%u rta=%0.3f;%0.3f;%0.3f;;\n", + "pkt=%u;;;0;%u rta=%0.3f;%0.3f;%0.3f;;\n", host->name, icmp_recv, (float)tdiff / 1000, icmp_recv, packets, (float)tdiff / 1000, (float)warn.rta / 1000, (float)crit.rta / 1000); @@ -1134,7 +1134,7 @@ finish(int sig) while(host) { if(!host->icmp_recv) { /* rta 0 is ofcourse not entirely correct, but will still show up - * conspicuosly as missing entries in perfparse and cacti */ + * conspicuously as missing entries in perfparse and cacti */ pl = 100; rta = 0; status = STATE_CRITICAL; @@ -1293,7 +1293,7 @@ add_target_ip(char *arg, struct sockaddr_storage *in) if(!host) { char straddr[INET6_ADDRSTRLEN]; parse_address((struct sockaddr_storage*)&in, straddr, sizeof(straddr)); - crash("add_target_ip(%s, %s): malloc(%d) failed", + crash("add_target_ip(%s, %s): malloc(%lu) failed", arg, straddr, sizeof(struct rta_host)); } memset(host, 0, sizeof(struct rta_host)); diff --git a/plugins-root/t/check_dhcp.t b/plugins-root/t/check_dhcp.t index 222f4544..ce627736 100644 --- a/plugins-root/t/check_dhcp.t +++ b/plugins-root/t/check_dhcp.t @@ -19,7 +19,7 @@ if ($allow_sudo eq "yes" or $> == 0) { my $sudo = $> == 0 ? '' : 'sudo'; my $successOutput = '/OK: Received \d+ DHCPOFFER\(s\), \d+ of 1 requested servers responded, max lease time = \d+ sec\./'; -my $failureOutput = '/CRITICAL: No DHCPOFFERs were received/'; +my $failureOutput = '/CRITICAL: (No DHCPOFFERs were received|Received \d+ DHCPOFFER\(s\), 0 of 1 requested servers responded, max lease time = \d+ sec\.)/'; my $invalidOutput = '/Invalid hostname/'; my $host_responsive = getTestParameter( "NP_HOST_DHCP_RESPONSIVE", @@ -36,7 +36,12 @@ my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID", # try to determince interface my $interface = ''; -if(`ifconfig -a 2>/dev/null` =~ m/^(e\w*\d+)/mx and $1 ne 'eth0') { + +# find interface used for default route +if (-x '/usr/sbin/ip' and `/usr/sbin/ip route get 1.1.1.1 2>/dev/null` =~ m/\sdev\s(\S+)/) { + $interface = "-i $1"; +} +elsif (`ifconfig -a 2>/dev/null` =~ m/^(e\w*\d+)/mx and $1 ne 'eth0') { $interface = ' -i '.$1; } |