diff --git a/check_snmp_metric/check_snmp_metric-0.4.4.mkp b/check_snmp_metric/check_snmp_metric-0.4.4.mkp deleted file mode 100644 index d5291676..00000000 Binary files a/check_snmp_metric/check_snmp_metric-0.4.4.mkp and /dev/null differ diff --git a/check_snmp_metric/check_snmp_metric-0.5.0.mkp b/check_snmp_metric/check_snmp_metric-0.5.0.mkp new file mode 100644 index 00000000..6d1892b9 Binary files /dev/null and b/check_snmp_metric/check_snmp_metric-0.5.0.mkp differ diff --git a/check_snmp_metric/checks/check_snmp_metric b/check_snmp_metric/checks/check_snmp_metric index 133768d2..88f188b6 100644 --- a/check_snmp_metric/checks/check_snmp_metric +++ b/check_snmp_metric/checks/check_snmp_metric @@ -63,6 +63,9 @@ def check_snmp_metric_arguments(params): if "factor" in params: args += ' --factor %f' % params["factor"] + if "offset" in params: + args += ' --offset %f' % params["offset"] + if "unit" in params: args += ' --unit %s' % quote_shell_string(params["unit"]) diff --git a/check_snmp_metric/lib/nagios/plugins/check_snmp_metric b/check_snmp_metric/lib/nagios/plugins/check_snmp_metric index 05492574..d68f0570 100755 --- a/check_snmp_metric/lib/nagios/plugins/check_snmp_metric +++ b/check_snmp_metric/lib/nagios/plugins/check_snmp_metric @@ -23,6 +23,7 @@ from pprint import pprint snmpgetcmd=['snmpget', '-O', 'nq'] factor=1.0 +offset=0.0 unit="" warn=0 warnset=False @@ -43,6 +44,8 @@ while args: a = args.pop(0) if a == "--factor": factor=float(args.pop(0)) + elif a == "--offset": + offset=float(args.pop(0)) elif a == "--unit": unit=args.pop(0) elif a == "--metric": @@ -72,7 +75,7 @@ res = exec_snmpget(snmpgetcmd) if res.returncode == 0: oid, v = res.stdout.strip().split() - val = float(v) / factor + val = (float(v) / factor) + offset state = 0 info = '%s is %0.2f %s' % (oid, val, unit) if critset and val > crit: diff --git a/check_snmp_metric/web/plugins/wato/active_checks_snmp_metric.py b/check_snmp_metric/web/plugins/wato/active_checks_snmp_metric.py index c7f2c405..e6b816bb 100644 --- a/check_snmp_metric/web/plugins/wato/active_checks_snmp_metric.py +++ b/check_snmp_metric/web/plugins/wato/active_checks_snmp_metric.py @@ -103,6 +103,12 @@ def _valuespec_active_checks_snmp_metric(): help = _("A Factor of 10 means that the value reported is ten times the real value, e.g. the OID contains 245, but the real temperature is 24,5°C"), default_value = 1.0, )), + ( "offset", + Float( + title = _("Value offset"), + help = _("An offset that gets added (with a positive value) to the value or subtracted (with a negative value) from the value after applying the value factor."), + default_value = 0.0, + )), ( "metric", TextAscii( title = _("Metric name"), @@ -114,7 +120,7 @@ def _valuespec_active_checks_snmp_metric(): help = _("Unit of the value. Used for display."), )), ], - optional_keys = [ 'hostname', 'port', 'timeout', 'creds', 'levels_upper', 'levels_lower', 'factor', 'metric', 'unit', ], + optional_keys = [ 'hostname', 'port', 'timeout', 'creds', 'levels_upper', 'levels_lower', 'factor', 'offset', 'metric', 'unit', ], ) rulespec_registry.register(