diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_snmp.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 3e8a9cf1..cd503896 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
@@ -63,6 +63,7 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net"; | |||
63 | #define L_CALCULATE_RATE CHAR_MAX+1 | 63 | #define L_CALCULATE_RATE CHAR_MAX+1 |
64 | #define L_RATE_MULTIPLIER CHAR_MAX+2 | 64 | #define L_RATE_MULTIPLIER CHAR_MAX+2 |
65 | #define L_INVERT_SEARCH CHAR_MAX+3 | 65 | #define L_INVERT_SEARCH CHAR_MAX+3 |
66 | #define L_OFFSET CHAR_MAX+4 | ||
66 | 67 | ||
67 | /* Gobble to string - stop incrementing c when c[0] match one of the | 68 | /* Gobble to string - stop incrementing c when c[0] match one of the |
68 | * characters in s */ | 69 | * characters in s */ |
@@ -138,6 +139,7 @@ char *output_delim; | |||
138 | char *miblist = NULL; | 139 | char *miblist = NULL; |
139 | int needmibs = FALSE; | 140 | int needmibs = FALSE; |
140 | int calculate_rate = 0; | 141 | int calculate_rate = 0; |
142 | double offset = 0.0; | ||
141 | int rate_multiplier = 1; | 143 | int rate_multiplier = 1; |
142 | state_data *previous_state; | 144 | state_data *previous_state; |
143 | double previous_value[MAX_OIDS]; | 145 | double previous_value[MAX_OIDS]; |
@@ -430,7 +432,7 @@ main (int argc, char **argv) | |||
430 | ptr = strpbrk (show, "0123456789"); | 432 | ptr = strpbrk (show, "0123456789"); |
431 | if (ptr == NULL) | 433 | if (ptr == NULL) |
432 | die (STATE_UNKNOWN,_("No valid data returned (%s)\n"), show); | 434 | die (STATE_UNKNOWN,_("No valid data returned (%s)\n"), show); |
433 | response_value[i] = strtod (ptr, NULL); | 435 | response_value[i] = strtod (ptr, NULL)+offset; |
434 | 436 | ||
435 | if(calculate_rate) { | 437 | if(calculate_rate) { |
436 | if (previous_state!=NULL) { | 438 | if (previous_state!=NULL) { |
@@ -619,6 +621,7 @@ process_arguments (int argc, char **argv) | |||
619 | {"next", no_argument, 0, 'n'}, | 621 | {"next", no_argument, 0, 'n'}, |
620 | {"rate", no_argument, 0, L_CALCULATE_RATE}, | 622 | {"rate", no_argument, 0, L_CALCULATE_RATE}, |
621 | {"rate-multiplier", required_argument, 0, L_RATE_MULTIPLIER}, | 623 | {"rate-multiplier", required_argument, 0, L_RATE_MULTIPLIER}, |
624 | {"offset", required_argument, 0, L_OFFSET}, | ||
622 | {"invert-search", no_argument, 0, L_INVERT_SEARCH}, | 625 | {"invert-search", no_argument, 0, L_INVERT_SEARCH}, |
623 | {"perf-oids", no_argument, 0, 'O'}, | 626 | {"perf-oids", no_argument, 0, 'O'}, |
624 | {0, 0, 0, 0} | 627 | {0, 0, 0, 0} |
@@ -833,6 +836,9 @@ process_arguments (int argc, char **argv) | |||
833 | if(!is_integer(optarg)||((rate_multiplier=atoi(optarg))<=0)) | 836 | if(!is_integer(optarg)||((rate_multiplier=atoi(optarg))<=0)) |
834 | usage2(_("Rate multiplier must be a positive integer"),optarg); | 837 | usage2(_("Rate multiplier must be a positive integer"),optarg); |
835 | break; | 838 | break; |
839 | case L_OFFSET: | ||
840 | offset=strtod(optarg,NULL); | ||
841 | break; | ||
836 | case L_INVERT_SEARCH: | 842 | case L_INVERT_SEARCH: |
837 | invert_search=1; | 843 | invert_search=1; |
838 | break; | 844 | break; |
@@ -1081,6 +1087,8 @@ print_help (void) | |||
1081 | printf (" %s\n", _("Enable rate calculation. See 'Rate Calculation' below")); | 1087 | printf (" %s\n", _("Enable rate calculation. See 'Rate Calculation' below")); |
1082 | printf (" %s\n", "--rate-multiplier"); | 1088 | printf (" %s\n", "--rate-multiplier"); |
1083 | printf (" %s\n", _("Converts rate per second. For example, set to 60 to convert to per minute")); | 1089 | printf (" %s\n", _("Converts rate per second. For example, set to 60 to convert to per minute")); |
1090 | printf (" %s\n", "--offset=OFFSET"); | ||
1091 | printf (" %s\n", _("Allows to add/substract a value to numeric sensor data.")); | ||
1084 | 1092 | ||
1085 | /* Tests Against Strings */ | 1093 | /* Tests Against Strings */ |
1086 | printf (" %s\n", "-s, --string=STRING"); | 1094 | printf (" %s\n", "-s, --string=STRING"); |