diff options
Diffstat (limited to 'plugins/check_snmp.c')
-rw-r--r-- | plugins/check_snmp.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 4cd38051..51ad6f4e 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
@@ -141,6 +141,7 @@ int calculate_rate = 0; | |||
141 | int rate_multiplier = 1; | 141 | int rate_multiplier = 1; |
142 | state_data *previous_state; | 142 | state_data *previous_state; |
143 | double previous_value[MAX_OIDS]; | 143 | double previous_value[MAX_OIDS]; |
144 | int perf_labels = 1; | ||
144 | 145 | ||
145 | 146 | ||
146 | int | 147 | int |
@@ -169,6 +170,7 @@ main (int argc, char **argv) | |||
169 | char *state_string=NULL; | 170 | char *state_string=NULL; |
170 | size_t response_length, current_length, string_length; | 171 | size_t response_length, current_length, string_length; |
171 | char *temp_string=NULL; | 172 | char *temp_string=NULL; |
173 | char *quote_string=NULL; | ||
172 | time_t current_time; | 174 | time_t current_time; |
173 | double temp_double; | 175 | double temp_double; |
174 | time_t duration; | 176 | time_t duration; |
@@ -485,11 +487,22 @@ main (int argc, char **argv) | |||
485 | ptr = NULL; | 487 | ptr = NULL; |
486 | strtod(show, &ptr); | 488 | strtod(show, &ptr); |
487 | if (ptr > show) { | 489 | if (ptr > show) { |
488 | if (nlabels >= (size_t)1 && (size_t)i < nlabels && labels[i] != NULL) | 490 | if (perf_labels && nlabels >= (size_t)1 && (size_t)i < nlabels && labels[i] != NULL) |
489 | temp_string=labels[i]; | 491 | temp_string=labels[i]; |
490 | else | 492 | else |
491 | temp_string=oidname; | 493 | temp_string=oidname; |
492 | strncat(perfstr, temp_string, sizeof(perfstr)-strlen(perfstr)-1); | 494 | if (strpbrk (temp_string, " ='\"") == NULL) { |
495 | strncat(perfstr, temp_string, sizeof(perfstr)-strlen(perfstr)-1); | ||
496 | } else { | ||
497 | if (strpbrk (temp_string, "\"") == NULL) { | ||
498 | quote_string="\""; | ||
499 | } else { | ||
500 | quote_string="'"; | ||
501 | } | ||
502 | strncat(perfstr, quote_string, sizeof(perfstr)-strlen(perfstr)-1); | ||
503 | strncat(perfstr, temp_string, sizeof(perfstr)-strlen(perfstr)-1); | ||
504 | strncat(perfstr, quote_string, sizeof(perfstr)-strlen(perfstr)-1); | ||
505 | } | ||
493 | strncat(perfstr, "=", sizeof(perfstr)-strlen(perfstr)-1); | 506 | strncat(perfstr, "=", sizeof(perfstr)-strlen(perfstr)-1); |
494 | len = sizeof(perfstr)-strlen(perfstr)-1; | 507 | len = sizeof(perfstr)-strlen(perfstr)-1; |
495 | strncat(perfstr, show, len>ptr-show ? ptr-show : len); | 508 | strncat(perfstr, show, len>ptr-show ? ptr-show : len); |
@@ -583,6 +596,7 @@ process_arguments (int argc, char **argv) | |||
583 | {"rate", no_argument, 0, L_CALCULATE_RATE}, | 596 | {"rate", no_argument, 0, L_CALCULATE_RATE}, |
584 | {"rate-multiplier", required_argument, 0, L_RATE_MULTIPLIER}, | 597 | {"rate-multiplier", required_argument, 0, L_RATE_MULTIPLIER}, |
585 | {"invert-search", no_argument, 0, L_INVERT_SEARCH}, | 598 | {"invert-search", no_argument, 0, L_INVERT_SEARCH}, |
599 | {"perf-oids", no_argument, 0, 'O'}, | ||
586 | {0, 0, 0, 0} | 600 | {0, 0, 0, 0} |
587 | }; | 601 | }; |
588 | 602 | ||
@@ -600,7 +614,7 @@ process_arguments (int argc, char **argv) | |||
600 | } | 614 | } |
601 | 615 | ||
602 | while (1) { | 616 | while (1) { |
603 | c = getopt_long (argc, argv, "nhvVt:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:L:U:a:x:A:X:", | 617 | c = getopt_long (argc, argv, "nhvVOt:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:L:U:a:x:A:X:", |
604 | longopts, &option); | 618 | longopts, &option); |
605 | 619 | ||
606 | if (c == -1 || c == EOF) | 620 | if (c == -1 || c == EOF) |
@@ -798,6 +812,9 @@ process_arguments (int argc, char **argv) | |||
798 | case L_INVERT_SEARCH: | 812 | case L_INVERT_SEARCH: |
799 | invert_search=1; | 813 | invert_search=1; |
800 | break; | 814 | break; |
815 | case 'O': | ||
816 | perf_labels=0; | ||
817 | break; | ||
801 | } | 818 | } |
802 | } | 819 | } |
803 | 820 | ||
@@ -1063,6 +1080,9 @@ print_help (void) | |||
1063 | printf (" %s\n", "-e, --retries=INTEGER"); | 1080 | printf (" %s\n", "-e, --retries=INTEGER"); |
1064 | printf (" %s\n", _("Number of retries to be used in the requests")); | 1081 | printf (" %s\n", _("Number of retries to be used in the requests")); |
1065 | 1082 | ||
1083 | printf (" %s\n", "-O, --perf-oids"); | ||
1084 | printf (" %s\n", _("Label performance data with OIDs instead of --label's")); | ||
1085 | |||
1066 | printf (UT_VERBOSE); | 1086 | printf (UT_VERBOSE); |
1067 | 1087 | ||
1068 | printf ("\n"); | 1088 | printf ("\n"); |