Module: check_mk
Branch: master
Commit: abd9b14a2a693b8215be47dc9b5167f0568bc04c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=abd9b14a2a693b…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue Jul 12 09:44:02 2016 +0200
3692 FIX f5_bigip_conns: fixed empty data handling
---
.werks/3692 | 10 ++++++
ChangeLog | 1 +
checks/f5_bigip_conns | 80 +++++++++++++++-------------------------------
modules/check_mk_base.py | 19 +++++++----
4 files changed, 49 insertions(+), 61 deletions(-)
diff --git a/.werks/3692 b/.werks/3692
new file mode 100644
index 0000000..a740d7b
--- /dev/null
+++ b/.werks/3692
@@ -0,0 +1,10 @@
+Title: f5_bigip_conns: fixed empty data handling
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i1
+Date: 1468309337
+
+
diff --git a/ChangeLog b/ChangeLog
index ad0a5c1..ce5c12b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -302,6 +302,7 @@
* 3555 FIX: esx_vsphere_sensors: fixed incorrect default parameter during service
discovery...
* 3665 FIX: hitachi_hnas_*: Fixed service discovery on some devices (e.g. HM800)
* 3666 FIX: ups_*: Fixed discovery for Vision UPS devices
+ * 3692 FIX: f5_bigip_conns: fixed empty data handling
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/checks/f5_bigip_conns b/checks/f5_bigip_conns
index 3b617d4..e37f2f7 100644
--- a/checks/f5_bigip_conns
+++ b/checks/f5_bigip_conns
@@ -25,81 +25,53 @@
# Boston, MA 02110-1301 USA.
-# {iso(1) identified-organization(3) dod(6) internet(1) private(4) enterprise(1) 3375
bigipTrafficMgmt(2) bigipSystem(1) sysGlobals(1) sysGlobalStats(2) sysGlobalStat(1)
sysStatClientCurConns(8)}
+# .1.3.6.1.4.1.3375.2.1.1.2.1.8.0 594 -->
F5-BIGIP-SYSTEM-MIB::sysStatClientCurConns.0
+# .1.3.6.1.4.1.3375.2.1.1.2.9.2.0 --> F5-BIGIP-SYSTEM-MIB::sysClientsslStatCurConns.0
-# {iso(1) identified-organization(3) dod(6) internet(1) private(4) enterprise(1) 3375
bigipTrafficMgmt(2) bigipSystem(1) sysGlobals(1) sysGlobalStats(2)
sysGlobalClientSslStat(9) sysClientsslStatCurConns(2)}
factory_settings["f5_bigip_conns_default_levels"] = {
"conns" : (25000, 30000),
"ssl_conns" : (25000, 30000),
}
+
def inventory_f5_bigip_conns(info):
if info:
return [ ( None, {} ) ]
+
def check_f5_bigip_conns(item, params, info):
- type_list = { 'conns': ('Connections', 0),
- 'ssl_conns': ('SSL Connections', 1),
- }
- perfdata = []
- infotext = ""
- state = 0
+ for val, what, title in [
+ (info[0][0], "conns", "Connections"),
+ (info[0][1], "ssl_conns", "SSL connections")]:
+
+ state = 0
+ infotext = "%s:" % title
+ perfdata = []
+
+ # SSL may not be configured, eg. on test servers
+ if val == "":
+ infotext += " not configured"
- separator = ""
- for typ, values in type_list.iteritems():
- param = params.get(typ)
- desc = values[0]
- index = values[1]
- conns = int(info[0][index])
- infotext += separator
- separator = " - "
- if type(param) == tuple:
- warn, crit = param
- perfdata.append( (typ, conns, warn, crit) )
- if conns >=crit:
- sstate = 2
- sym = "(!!)"
- elif conns >= warn:
- sstate = 1
- sym = "(!)"
- else:
- sstate = 0
- sym = ""
- infotext += "%d %s%s (%d/%d)" % (conns, desc, sym, warn, crit)
else:
- warn, crit = None, None
- perf = ( (typ, conns, warn, crit) )
- sstate, text, extraperf = check_levels(conns, typ, param)
- if sstate == 2:
- sym == "(!!)"
- elif sstate == 1:
- sym = "(!)"
- else:
- sym = ""
- perfdata.append(perf)
- if len(extraperf) > 0:
- perfdata.append(extraperf[0])
- infotext += "%d %s%s" % (conns, desc, sym)
- if text:
- infotext += ", " + text
- if state < sstate:
- state = sstate
+ state, extrainfo, perfdata = check_levels(int(val), what, params.get(what))
+ infotext += " %s%s" % (what, extrainfo)
+
+ yield state, infotext, perfdata
- return (state, infotext, perfdata)
check_info["f5_bigip_conns"] = {
'check_function' : check_f5_bigip_conns,
'inventory_function' : inventory_f5_bigip_conns,
'service_description' : 'Open Connections',
+ 'snmp_info' : ( '.1.3.6.1.4.1.3375.2.1.1.2', [
+ '1.8', #
F5-BIGIP-SYSTEM-MIB::sysStatServerCurConns
+ '9.2', #
F5-BIGIP-SYSTEM-MIB::sysClientsslStatCurConns
+ ]),
+ 'snmp_scan_function' : lambda oid: '.1.3.6.1.4.1.3375.2' in \
+ oid(".1.3.6.1.2.1.1.2.0") and
"big-ip" in \
+
oid(".1.3.6.1.4.1.3375.2.1.4.1.0").lower(),
'has_perfdata' : True,
'group' : 'f5_connections',
'default_levels_variable' : 'f5_bigip_conns_default_levels',
- 'snmp_info' : ( '.1.3.6.1.4.1.3375.2.1.1.2', [
- '1.8', # sysStatServerCurConns
- '9.2', # sysClientsslStatCurConns
- ] ),
- 'snmp_scan_function' : lambda oid: '.1.3.6.1.4.1.3375.2' in \
- oid(".1.3.6.1.2.1.1.2.0") and "big-ip" in \
- oid(".1.3.6.1.4.1.3375.2.1.4.1.0").lower(),
}
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index a7ba470..a36570b 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -2133,6 +2133,9 @@ def check_levels(value, dsname, params, unit="",
factor=1.0, scale=1.0, statemar
else:
return v * factor * scale
+ def levelsinfo_ty(ty, warn, crit, unit):
+ return ("warn/crit %s %.2f/%.2f %s" % (ty, warn, crit, unit)).strip()
+
# None or (None, None) -> do not check any levels
if params == None or params == (None, None):
return 0, "", []
@@ -2142,9 +2145,11 @@ def check_levels(value, dsname, params, unit="",
factor=1.0, scale=1.0, statemar
if len(params) == 2: # upper warn and crit
warn_upper, crit_upper = scale_value(params[0]), scale_value(params[1])
warn_lower, crit_lower = None, None
- else: # uppwer and lower warn and crit
+
+ else: # upper and lower warn and crit
warn_upper, crit_upper = scale_value(params[0]), scale_value(params[1])
warn_lower, crit_lower = scale_value(params[2]), scale_value(params[3])
+
ref_value = None
# Dictionary -> predictive levels
@@ -2174,18 +2179,18 @@ def check_levels(value, dsname, params, unit="",
factor=1.0, scale=1.0, statemar
# Critical cases
if crit_upper != None and value >= crit_upper:
state = 2
- infotexts.append("critical level at %.2f%s" % (crit_upper / scale,
unit))
- elif crit_lower != None and value <= crit_lower:
+ infotexts.append(levelsinfo_ty("at", warn_upper / scale, crit_upper /
scale, unit))
+ elif crit_lower != None and value < crit_lower:
state = 2
- infotexts.append("too low: critical level at %.2f%s" % (crit_lower /
scale, unit))
+ infotexts.append(levelsinfo_ty("below", warn_lower / scale, crit_lower
/ scale, unit))
# Warning cases
elif warn_upper != None and value >= warn_upper:
state = 1
- infotexts.append("warning level at %.2f%s" % (warn_upper / scale,
unit))
- elif warn_lower != None and value <= warn_lower:
+ infotexts.append(levelsinfo_ty("at", warn_upper / scale, crit_upper /
scale, unit))
+ elif warn_lower != None and value < warn_lower:
state = 1
- infotexts.append("too low: warning level at %.2f%s" % (warn_lower /
scale, unit))
+ infotexts.append(levelsinfo_ty("below", warn_lower / scale, crit_lower
/ scale, unit))
# OK
else: