diff options
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2007-04-15 06:44:46 +0000 |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2007-04-15 06:44:46 +0000 |
commit | 6a564052eab2921b7027a259c5578319dbebde7c (patch) | |
tree | 317e102b6ab5380e8d51154f88caf0242ec166c3 | |
parent | 8899bc81940c07ade019022bca5c8f64cac64c66 (diff) | |
download | monitoring-plugins-6a564052eab2921b7027a259c5578319dbebde7c.tar.gz |
Fix bug #1344584: Counter64 values not handled correctly
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1687 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r-- | BUGS | 1 | ||||
-rw-r--r-- | plugins/check_snmp.c | 48 |
2 files changed, 26 insertions, 23 deletions
@@ -30,7 +30,6 @@ For the 1.4.8 release: | |||
30 | 1381604 - Perlsec breaks any perl plugin with perl 5.8.x | 30 | 1381604 - Perlsec breaks any perl plugin with perl 5.8.x |
31 | 1373801 - check_ping timeout on Mandrake 10.1 | 31 | 1373801 - check_ping timeout on Mandrake 10.1 |
32 | 1370031 - check_disk_smb requires DNS agree with NetBIOS names | 32 | 1370031 - check_disk_smb requires DNS agree with NetBIOS names |
33 | 1344584 - check_snmp counter64 values not handled correctly | ||
34 | 1291987 - urlize useragent does not work | 33 | 1291987 - urlize useragent does not work |
35 | 1225470 - check_swap perf data incorrect | 34 | 1225470 - check_swap perf data incorrect |
36 | 1218438 - check_radius linking to wrong header | 35 | 1218438 - check_radius linking to wrong header |
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index c43f1efb..741ad3ea 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * Nagios check_snmp plugin | 3 | * Nagios check_snmp plugin |
4 | * | 4 | * |
5 | * License: GPL | 5 | * License: GPL |
6 | * Copyright (c) 1999-2006 nagios-plugins team | 6 | * Copyright (c) 1999-2007 nagios-plugins team |
7 | * | 7 | * |
8 | * Last Modified: $Date$ | 8 | * Last Modified: $Date$ |
9 | * | 9 | * |
@@ -11,7 +11,7 @@ | |||
11 | * | 11 | * |
12 | * This file contains the check_snmp plugin | 12 | * This file contains the check_snmp plugin |
13 | * | 13 | * |
14 | * Check status of remote machines and obtain sustem information via SNMP | 14 | * Check status of remote machines and obtain system information via SNMP |
15 | * | 15 | * |
16 | * | 16 | * |
17 | * License Information: | 17 | * License Information: |
@@ -36,7 +36,7 @@ | |||
36 | 36 | ||
37 | const char *progname = "check_snmp"; | 37 | const char *progname = "check_snmp"; |
38 | const char *revision = "$Revision$"; | 38 | const char *revision = "$Revision$"; |
39 | const char *copyright = "1999-2006"; | 39 | const char *copyright = "1999-2007"; |
40 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; | 40 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; |
41 | 41 | ||
42 | #include "common.h" | 42 | #include "common.h" |
@@ -84,8 +84,8 @@ int process_arguments (int, char **); | |||
84 | int validate_arguments (void); | 84 | int validate_arguments (void); |
85 | char *clarify_message (char *); | 85 | char *clarify_message (char *); |
86 | int check_num (int); | 86 | int check_num (int); |
87 | int lu_getll (unsigned long *, char *); | 87 | int llu_getll (unsigned long long *, char *); |
88 | int lu_getul (unsigned long *, char *); | 88 | int llu_getul (unsigned long long *, char *); |
89 | char *thisarg (char *str); | 89 | char *thisarg (char *str); |
90 | char *nextarg (char *str); | 90 | char *nextarg (char *str); |
91 | void print_usage (void); | 91 | void print_usage (void); |
@@ -124,15 +124,15 @@ size_t nunits = 0; | |||
124 | size_t unitv_size = 8; | 124 | size_t unitv_size = 8; |
125 | int verbose = FALSE; | 125 | int verbose = FALSE; |
126 | int usesnmpgetnext = FALSE; | 126 | int usesnmpgetnext = FALSE; |
127 | unsigned long lower_warn_lim[MAX_OIDS]; | 127 | unsigned long long lower_warn_lim[MAX_OIDS]; |
128 | unsigned long upper_warn_lim[MAX_OIDS]; | 128 | unsigned long long upper_warn_lim[MAX_OIDS]; |
129 | unsigned long lower_crit_lim[MAX_OIDS]; | 129 | unsigned long long lower_crit_lim[MAX_OIDS]; |
130 | unsigned long upper_crit_lim[MAX_OIDS]; | 130 | unsigned long long upper_crit_lim[MAX_OIDS]; |
131 | unsigned long response_value[MAX_OIDS]; | 131 | unsigned long long response_value[MAX_OIDS]; |
132 | int check_warning_value = FALSE; | 132 | int check_warning_value = FALSE; |
133 | int check_critical_value = FALSE; | 133 | int check_critical_value = FALSE; |
134 | int retries = 0; | 134 | int retries = 0; |
135 | unsigned long eval_method[MAX_OIDS]; | 135 | unsigned long long eval_method[MAX_OIDS]; |
136 | char *delimiter; | 136 | char *delimiter; |
137 | char *output_delim; | 137 | char *output_delim; |
138 | char *miblist = NULL; | 138 | char *miblist = NULL; |
@@ -268,6 +268,10 @@ main (int argc, char **argv) | |||
268 | show = strstr (response, "Counter32: ") + 11; | 268 | show = strstr (response, "Counter32: ") + 11; |
269 | strcpy(type, "c"); | 269 | strcpy(type, "c"); |
270 | } | 270 | } |
271 | else if (strstr (response, "Counter64: ")) { | ||
272 | show = strstr (response, "Counter64: ") + 11; | ||
273 | strcpy(type, "c"); | ||
274 | } | ||
271 | else if (strstr (response, "INTEGER: ")) | 275 | else if (strstr (response, "INTEGER: ")) |
272 | show = strstr (response, "INTEGER: ") + 9; | 276 | show = strstr (response, "INTEGER: ") + 9; |
273 | else if (strstr (response, "STRING: ")) | 277 | else if (strstr (response, "STRING: ")) |
@@ -296,7 +300,7 @@ main (int argc, char **argv) | |||
296 | die (STATE_UNKNOWN,_("No valid data returned")); | 300 | die (STATE_UNKNOWN,_("No valid data returned")); |
297 | response_value[i] = strtoul (p2, NULL, 10); | 301 | response_value[i] = strtoul (p2, NULL, 10); |
298 | iresult = check_num (i); | 302 | iresult = check_num (i); |
299 | asprintf (&show, "%lu", response_value[i]); | 303 | asprintf (&show, "%llu", response_value[i]); |
300 | } | 304 | } |
301 | 305 | ||
302 | /* Process this block for string matching */ | 306 | /* Process this block for string matching */ |
@@ -501,9 +505,9 @@ process_arguments (int argc, char **argv) | |||
501 | if (strspn (optarg, "0123456789:,") < strlen (optarg)) | 505 | if (strspn (optarg, "0123456789:,") < strlen (optarg)) |
502 | usage2 (_("Invalid critical threshold: %s\n"), optarg); | 506 | usage2 (_("Invalid critical threshold: %s\n"), optarg); |
503 | for (ptr = optarg; ptr && jj < MAX_OIDS; jj++) { | 507 | for (ptr = optarg; ptr && jj < MAX_OIDS; jj++) { |
504 | if (lu_getll (&lower_crit_lim[jj], ptr) == 1) | 508 | if (llu_getll (&lower_crit_lim[jj], ptr) == 1) |
505 | eval_method[jj] |= CRIT_LT; | 509 | eval_method[jj] |= CRIT_LT; |
506 | if (lu_getul (&upper_crit_lim[jj], ptr) == 1) | 510 | if (llu_getul (&upper_crit_lim[jj], ptr) == 1) |
507 | eval_method[jj] |= CRIT_GT; | 511 | eval_method[jj] |= CRIT_GT; |
508 | (ptr = index (ptr, ',')) ? ptr++ : ptr; | 512 | (ptr = index (ptr, ',')) ? ptr++ : ptr; |
509 | } | 513 | } |
@@ -512,9 +516,9 @@ process_arguments (int argc, char **argv) | |||
512 | if (strspn (optarg, "0123456789:,") < strlen (optarg)) | 516 | if (strspn (optarg, "0123456789:,") < strlen (optarg)) |
513 | usage2 (_("Invalid warning threshold: %s\n"), optarg); | 517 | usage2 (_("Invalid warning threshold: %s\n"), optarg); |
514 | for (ptr = optarg; ptr && ii < MAX_OIDS; ii++) { | 518 | for (ptr = optarg; ptr && ii < MAX_OIDS; ii++) { |
515 | if (lu_getll (&lower_warn_lim[ii], ptr) == 1) | 519 | if (llu_getll (&lower_warn_lim[ii], ptr) == 1) |
516 | eval_method[ii] |= WARN_LT; | 520 | eval_method[ii] |= WARN_LT; |
517 | if (lu_getul (&upper_warn_lim[ii], ptr) == 1) | 521 | if (llu_getul (&upper_warn_lim[ii], ptr) == 1) |
518 | eval_method[ii] |= WARN_GT; | 522 | eval_method[ii] |= WARN_GT; |
519 | (ptr = index (ptr, ',')) ? ptr++ : ptr; | 523 | (ptr = index (ptr, ',')) ? ptr++ : ptr; |
520 | } | 524 | } |
@@ -819,14 +823,14 @@ check_num (int i) | |||
819 | 823 | ||
820 | 824 | ||
821 | int | 825 | int |
822 | lu_getll (unsigned long *ll, char *str) | 826 | llu_getll (unsigned long long *ll, char *str) |
823 | { | 827 | { |
824 | char tmp[100]; | 828 | char tmp[100]; |
825 | if (strchr (str, ':') == NULL) | 829 | if (strchr (str, ':') == NULL) |
826 | return 0; | 830 | return 0; |
827 | if (strchr (str, ',') != NULL && (strchr (str, ',') < strchr (str, ':'))) | 831 | if (strchr (str, ',') != NULL && (strchr (str, ',') < strchr (str, ':'))) |
828 | return 0; | 832 | return 0; |
829 | if (sscanf (str, "%lu%[:]", ll, tmp) == 2) | 833 | if (sscanf (str, "%llu%[:]", ll, tmp) == 2) |
830 | return 1; | 834 | return 1; |
831 | return 0; | 835 | return 0; |
832 | } | 836 | } |
@@ -834,14 +838,14 @@ lu_getll (unsigned long *ll, char *str) | |||
834 | 838 | ||
835 | 839 | ||
836 | int | 840 | int |
837 | lu_getul (unsigned long *ul, char *str) | 841 | llu_getul (unsigned long long *ul, char *str) |
838 | { | 842 | { |
839 | char tmp[100]; | 843 | char tmp[100]; |
840 | if (sscanf (str, "%lu%[^,]", ul, tmp) == 1) | 844 | if (sscanf (str, "%llu%[^,]", ul, tmp) == 1) |
841 | return 1; | 845 | return 1; |
842 | if (sscanf (str, ":%lu%[^,]", ul, tmp) == 1) | 846 | if (sscanf (str, ":%llu%[^,]", ul, tmp) == 1) |
843 | return 1; | 847 | return 1; |
844 | if (sscanf (str, "%*u:%lu%[^,]", ul, tmp) == 1) | 848 | if (sscanf (str, "%*u:%llu%[^,]", ul, tmp) == 1) |
845 | return 1; | 849 | return 1; |
846 | return 0; | 850 | return 0; |
847 | } | 851 | } |