Module: check_mk
Branch: master
Commit: d9084a3e6ec849e7882d0e87db8a1647a7d06ed0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d9084a3e6ec849…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed May 9 16:12:36 2018 +0200
Minor cleanup
Change-Id: Ied15966d61e2608ffa4b77c8b333ff74f73d73b9
---
checks/cisco_temperature | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/checks/cisco_temperature b/checks/cisco_temperature
index 7a9b3ee..a8a0b90 100644
--- a/checks/cisco_temperature
+++ b/checks/cisco_temperature
@@ -246,34 +246,29 @@ check_info['cisco_temperature'] = {
def inventory_cisco_temperature_dom(parsed):
- parsed_dom = parsed.get('14', {})
- for item, attrs in parsed_dom.iteritems():
+ for item, attrs in parsed.get('14', {}).iteritems():
if attrs.get('raw_dev_state') == '1':
yield item, {}
def check_cisco_temperature_dom(item, params, parsed):
# TODO perf, precision, severity, etc.
- parsed_dom = parsed.get('14', {})
- if item in parsed_dom:
- data = parsed_dom[item]
+ if item in parsed.get('14', {}):
+ data = parsed['14'][item]
reading = data['reading']
state, state_readable = data['dev_state']
yield state, 'Status: %s' % state_readable
infotext = "%s dBm" % reading
- perfdata = ['power_level', reading]
state = 0
- if data.get('dev_levels'):
- warn, crit = data['dev_levels']
- perfdata += [warn, crit]
- if reading >= crit:
- state = 2
- elif reading >= warn:
- state = 1
- if state:
- infotext += " (warn/crit at %s/%s dBm)" % (warn, crit)
- yield state, infotext, [perfdata]
+ warn, crit = data.get('dev_levels', (None, None))
+ if crit is not None and reading >= crit:
+ state = 2
+ elif warn is not None and reading >= warn:
+ state = 1
+ if state:
+ infotext += " (warn/crit at %s/%s dBm)" % (warn, crit)
+ yield state, infotext, [('power_level', reading, warn, crit)]
check_info['cisco_temperature.dom'] = {