diff options
author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2023-09-20 06:16:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-20 06:16:11 (GMT) |
commit | a5ba424f85153b1ddaaf5e5269c82f0f049828d0 (patch) | |
tree | b9c158930159f2ab1ea2eb45e9e19ccdd0fbb76b /plugins-root | |
parent | a99db0243baa5d208c5d500a9bde86b4619cec92 (diff) | |
parent | 220455a11e8f1dd3a86ac4725cf0c799c8e3b21b (diff) | |
download | monitoring-plugins-a5ba424f85153b1ddaaf5e5269c82f0f049828d0.tar.gz |
Merge branch 'master' into masterrefs/pull/1637/head
Diffstat (limited to 'plugins-root')
-rw-r--r-- | plugins-root/check_dhcp.c | 16 | ||||
-rw-r--r-- | plugins-root/check_icmp.c | 7 | ||||
-rw-r--r-- | plugins-root/pst3.c | 2 | ||||
-rw-r--r-- | plugins-root/t/check_icmp.t | 2 |
4 files changed, 14 insertions, 13 deletions
diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c index ad67323..2d22619 100644 --- a/plugins-root/check_dhcp.c +++ b/plugins-root/check_dhcp.c | |||
@@ -229,7 +229,7 @@ struct in_addr requested_address; | |||
229 | 229 | ||
230 | int process_arguments(int, char **); | 230 | int process_arguments(int, char **); |
231 | int call_getopt(int, char **); | 231 | int call_getopt(int, char **); |
232 | int validate_arguments(int, int); | 232 | int validate_arguments(int); |
233 | void print_usage(void); | 233 | void print_usage(void); |
234 | void print_help(void); | 234 | void print_help(void); |
235 | 235 | ||
@@ -470,10 +470,6 @@ int send_dhcp_discover(int sock){ | |||
470 | packet_xid=random(); | 470 | packet_xid=random(); |
471 | discover_packet.xid=htonl(packet_xid); | 471 | discover_packet.xid=htonl(packet_xid); |
472 | 472 | ||
473 | /**** WHAT THE HECK IS UP WITH THIS?!? IF I DON'T MAKE THIS CALL, ONLY ONE SERVER RESPONSE IS PROCESSED!!!! ****/ | ||
474 | /* downright bizzarre... */ | ||
475 | ntohl(discover_packet.xid); | ||
476 | |||
477 | /*discover_packet.secs=htons(65535);*/ | 473 | /*discover_packet.secs=htons(65535);*/ |
478 | discover_packet.secs=0xFF; | 474 | discover_packet.secs=0xFF; |
479 | 475 | ||
@@ -1059,8 +1055,8 @@ int process_arguments(int argc, char **argv){ | |||
1059 | return ERROR; | 1055 | return ERROR; |
1060 | 1056 | ||
1061 | arg_index = call_getopt(argc,argv); | 1057 | arg_index = call_getopt(argc,argv); |
1062 | return validate_arguments(argc,arg_index); | 1058 | return validate_arguments(argc); |
1063 | } | 1059 | } |
1064 | 1060 | ||
1065 | 1061 | ||
1066 | 1062 | ||
@@ -1158,13 +1154,13 @@ int call_getopt(int argc, char **argv){ | |||
1158 | } | 1154 | } |
1159 | 1155 | ||
1160 | 1156 | ||
1161 | int validate_arguments(int argc, int arg_index){ | 1157 | int validate_arguments(int argc){ |
1162 | 1158 | ||
1163 | if(argc-optind > 0) | 1159 | if(argc - optind > 0) |
1164 | usage(_("Got unexpected non-option argument")); | 1160 | usage(_("Got unexpected non-option argument")); |
1165 | 1161 | ||
1166 | return OK; | 1162 | return OK; |
1167 | } | 1163 | } |
1168 | 1164 | ||
1169 | 1165 | ||
1170 | #if defined(__sun__) || defined(__solaris__) || defined(__hpux__) | 1166 | #if defined(__sun__) || defined(__solaris__) || defined(__hpux__) |
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index c3be2ef..1d47e9f 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c | |||
@@ -274,7 +274,7 @@ get_icmp_error_msg(unsigned char icmp_type, unsigned char icmp_code) | |||
274 | break; | 274 | break; |
275 | 275 | ||
276 | case ICMP_TIMXCEED: | 276 | case ICMP_TIMXCEED: |
277 | /* really 'out of reach', or non-existant host behind a router serving | 277 | /* really 'out of reach', or non-existent host behind a router serving |
278 | * two different subnets */ | 278 | * two different subnets */ |
279 | switch(icmp_code) { | 279 | switch(icmp_code) { |
280 | case ICMP_TIMXCEED_INTRANS: msg = "Time to live exceeded in transit"; break; | 280 | case ICMP_TIMXCEED_INTRANS: msg = "Time to live exceeded in transit"; break; |
@@ -1432,15 +1432,20 @@ get_ip_address(const char *ifname) | |||
1432 | { | 1432 | { |
1433 | // TODO: Rewrite this so the function return an error and we exit somewhere else | 1433 | // TODO: Rewrite this so the function return an error and we exit somewhere else |
1434 | struct sockaddr_in ip; | 1434 | struct sockaddr_in ip; |
1435 | ip.sin_addr.s_addr = 0; // Fake initialization to make compiler happy | ||
1435 | #if defined(SIOCGIFADDR) | 1436 | #if defined(SIOCGIFADDR) |
1436 | struct ifreq ifr; | 1437 | struct ifreq ifr; |
1437 | 1438 | ||
1438 | strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1); | 1439 | strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1); |
1440 | |||
1439 | ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0'; | 1441 | ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0'; |
1442 | |||
1440 | if(ioctl(icmp_sock, SIOCGIFADDR, &ifr) == -1) | 1443 | if(ioctl(icmp_sock, SIOCGIFADDR, &ifr) == -1) |
1441 | crash("Cannot determine IP address of interface %s", ifname); | 1444 | crash("Cannot determine IP address of interface %s", ifname); |
1445 | |||
1442 | memcpy(&ip, &ifr.ifr_addr, sizeof(ip)); | 1446 | memcpy(&ip, &ifr.ifr_addr, sizeof(ip)); |
1443 | #else | 1447 | #else |
1448 | (void) ifname; | ||
1444 | errno = 0; | 1449 | errno = 0; |
1445 | crash("Cannot get interface IP address on this platform."); | 1450 | crash("Cannot get interface IP address on this platform."); |
1446 | #endif | 1451 | #endif |
diff --git a/plugins-root/pst3.c b/plugins-root/pst3.c index c3589f0..1f69f3a 100644 --- a/plugins-root/pst3.c +++ b/plugins-root/pst3.c | |||
@@ -257,6 +257,6 @@ void usage() { | |||
257 | printf("\tRSS - Real memory usage (kilobytes)\n"); | 257 | printf("\tRSS - Real memory usage (kilobytes)\n"); |
258 | printf("\t%%CPU - CPU usage\n"); | 258 | printf("\t%%CPU - CPU usage\n"); |
259 | printf("\tCOMMAND - Command being run\n"); | 259 | printf("\tCOMMAND - Command being run\n"); |
260 | printf("\tARGS - Full command line with arguements\n"); | 260 | printf("\tARGS - Full command line with arguments\n"); |
261 | return; | 261 | return; |
262 | } | 262 | } |
diff --git a/plugins-root/t/check_icmp.t b/plugins-root/t/check_icmp.t index f6aa681..96addd3 100644 --- a/plugins-root/t/check_icmp.t +++ b/plugins-root/t/check_icmp.t | |||
@@ -92,5 +92,5 @@ like( $res->output, $successOutput, "Output OK" ); | |||
92 | $res = NPTest->testCmd( | 92 | $res = NPTest->testCmd( |
93 | "$sudo ./check_icmp -H $host_responsive -b 65507" | 93 | "$sudo ./check_icmp -H $host_responsive -b 65507" |
94 | ); | 94 | ); |
95 | is( $res->return_code, 0, "Try max paket size" ); | 95 | is( $res->return_code, 0, "Try max packet size" ); |
96 | like( $res->output, $successOutput, "Output OK - Didn't overflow" ); | 96 | like( $res->output, $successOutput, "Output OK - Didn't overflow" ); |