[nagiosplug] added --offset option to allow adjustment of ...
Nagios Plugin Development
nagios-plugins at users.sourceforge.net
Sun Aug 18 19:50:17 CEST 2013
Module: nagiosplug
Branch: master
Commit: dc1d1c46d6f9ca1a15609c126cf212bf3bb5ee4e
Author: Simon Kainz <simon at familiekainz.at>
Committer: Holger Weiss <holger at zedat.fu-berlin.de>
Date: Mon Aug 5 23:00:21 2013 +0200
URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=dc1d1c4
added --offset option to allow adjustment of sensor data
---
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 3e8a9cf..cd50389 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -63,6 +63,7 @@ const char *email = "nagiosplug-devel at 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");
More information about the Commits
mailing list