diff options
author | Simon Kainz <simon@familiekainz.at> | 2013-08-05 23:00:21 +0200 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-08-18 19:35:18 +0200 |
commit | dc1d1c46d6f9ca1a15609c126cf212bf3bb5ee4e (patch) | |
tree | 54b02ad415020a305c8df31ab533c9c380884242 /plugins/check_snmp.c | |
parent | 22519bced6235c1c6cdb81d59783dd8fe1208461 (diff) | |
download | monitoring-plugins-dc1d1c46d6f9ca1a15609c126cf212bf3bb5ee4e.tar.gz |
added --offset option to allow adjustment of sensor data
Diffstat (limited to 'plugins/check_snmp.c')
-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"; #define L_CALCULATE_RATE CHAR_MAX+1 #define L_RATE_MULTIPLIER CHAR_MAX+2 #define L_INVERT_SEARCH CHAR_MAX+3 +#define L_OFFSET CHAR_MAX+4 /* Gobble to string - stop incrementing c when c[0] match one of the * characters in s */ @@ -138,6 +139,7 @@ char *output_delim; char *miblist = NULL; int needmibs = FALSE; int calculate_rate = 0; +double offset = 0.0; int rate_multiplier = 1; state_data *previous_state; double previous_value[MAX_OIDS]; @@ -430,7 +432,7 @@ main (int argc, char **argv) ptr = strpbrk (show, "0123456789"); if (ptr == NULL) die (STATE_UNKNOWN,_("No valid data returned (%s)\n"), show); - response_value[i] = strtod (ptr, NULL); + response_value[i] = strtod (ptr, NULL)+offset; if(calculate_rate) { if (previous_state!=NULL) { @@ -619,6 +621,7 @@ process_arguments (int argc, char **argv) {"next", no_argument, 0, 'n'}, {"rate", no_argument, 0, L_CALCULATE_RATE}, {"rate-multiplier", required_argument, 0, L_RATE_MULTIPLIER}, + {"offset", required_argument, 0, L_OFFSET}, {"invert-search", no_argument, 0, L_INVERT_SEARCH}, {"perf-oids", no_argument, 0, 'O'}, {0, 0, 0, 0} @@ -833,6 +836,9 @@ process_arguments (int argc, char **argv) if(!is_integer(optarg)||((rate_multiplier=atoi(optarg))<=0)) usage2(_("Rate multiplier must be a positive integer"),optarg); break; + case L_OFFSET: + offset=strtod(optarg,NULL); + break; case L_INVERT_SEARCH: invert_search=1; break; @@ -1081,6 +1087,8 @@ print_help (void) printf (" %s\n", _("Enable rate calculation. See 'Rate Calculation' below")); printf (" %s\n", "--rate-multiplier"); printf (" %s\n", _("Converts rate per second. For example, set to 60 to convert to per minute")); + printf (" %s\n", "--offset=OFFSET"); + printf (" %s\n", _("Allows to add/substract a value to numeric sensor data.")); /* Tests Against Strings */ printf (" %s\n", "-s, --string=STRING"); |