From 54381a3857ea412460bb27dd79b0f83150ba9566 Mon Sep 17 00:00:00 2001 From: NP <26493612+paasi6666@users.noreply.github.com> Date: Tue, 25 Nov 2025 14:47:29 +0100 Subject: [PATCH] Update snmp Added "min" and "max" to Perfdata Alert Thresholds. Made sure to not break any existing checks. --- check-plugins/snmp/snmp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/check-plugins/snmp/snmp b/check-plugins/snmp/snmp index cc175c9b..13cdd8ca 100755 --- a/check-plugins/snmp/snmp +++ b/check-plugins/snmp/snmp @@ -551,10 +551,14 @@ def main(): # create perfdata for numeric values value_type = lib.base.guess_type(value) - w, c = None, None + w, c, mi, ma = None, None, 0, None try: # performance thresholds should return a tuple - w, c = eval(perf_thresholds, {}) # pylint: disable=W0123 + result = eval(perf_thresholds, {}) # pylint: disable=W0123 + if not isinstance(result, (tuple, list)): + result = (result,) + result = (list(result) + [None, None, None, None])[:4] + w, c, mi, ma = result except: pass if not ignore_perfdata and isinstance(value_type, (int, float)): @@ -575,8 +579,8 @@ def main(): uom=perfdata_unit.upper(), warn=w, crit=c, - _min=0, - _max=None, + _min=mi, + _max=ma, ) elif perfdata_unit.lower() in ['c', 's', 'ms', 'us',]: perfdata += lib.base.get_perfdata( @@ -585,8 +589,8 @@ def main(): uom=perfdata_unit.lower(), warn=w, crit=c, - _min=0, - _max=None, + _min=mi, + _max=ma, ) else: # unknown perfdata suffixes, so do not use them @@ -596,8 +600,8 @@ def main(): uom=None, warn=w, crit=c, - _min=0, - _max=None, + _min=mi, + _max=ma, ) # create output