Module: check_mk
Branch: master
Commit: f2c59fc368b78b869baf214942341c78a86ff141
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f2c59fc368b78b…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Jul 8 09:16:23 2015 +0200
heartbeat_crm: fix exception in case of no output by old agent
---
checks/heartbeat_crm | 20 ++++++++++++--------
checks/ipmi | 24 ++++++++++--------------
2 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/checks/heartbeat_crm b/checks/heartbeat_crm
index da1be84..9fbc7ff 100644
--- a/checks/heartbeat_crm
+++ b/checks/heartbeat_crm
@@ -72,7 +72,10 @@ factory_settings["heartbeat_crm_default_levels"] = {
}
def heartbeat_crm_parse_general(info):
- dc, num_nodes, num_resources = None, None, None
+ last_updated = None
+ dc = None
+ num_nodes = None
+ num_resources = None
for line in info:
if ' '.join(line[0:2]) == 'Last updated:':
last_updated = ' '.join(line[2:])
@@ -98,13 +101,14 @@ def inventory_heartbeat_crm(info):
# - Check the age of "last updated"
settings = host_extra_conf_merged(g_hostname, inventory_heartbeat_crm_rules)
last_updated, dc, num_nodes, num_resources = heartbeat_crm_parse_general(info)
- params = {
- 'num_nodes' : num_nodes,
- 'num_resources' : num_resources,
- }
- if settings.get('naildown_dc', False):
- params['dc'] = dc
- return [(None, params)]
+ if last_updated:
+ params = {
+ 'num_nodes' : num_nodes,
+ 'num_resources' : num_resources,
+ }
+ if settings.get('naildown_dc', False):
+ params['dc'] = dc
+ return [(None, params)]
def check_heartbeat_crm(item, params, info):
if len(info) > 0:
diff --git a/checks/ipmi b/checks/ipmi
index 82a6012..0bcc4a5 100644
--- a/checks/ipmi
+++ b/checks/ipmi
@@ -121,20 +121,16 @@ def check_ipmi(item, params, info):
return check_ipmi_detailed(item, info)
def check_ipmi_detailed(item, info):
- try:
- for name, val, unit, status, unrec_low, crit_low, \
- warn_low, warn_high, crit_high, unrec_high in info:
- if name == item:
- perfdata = [ (name, val + unit) ] # TODO: add warn and crit levels
- if status == 'ok':
- return (0, "%s is %s %s" % (name, val, unit), perfdata)
- elif status == 'nc':
- return (1, "%s is %s %s" % (name, val, unit), perfdata)
- else:
- return (2, "%s is %s %s" % (name, val, unit), perfdata)
- return (3, 'item %s not found' % item)
- except:
- return (3, "invalid or incomplete output from agent")
+ for name, val, unit, status, unrec_low, crit_low, \
+ warn_low, warn_high, crit_high, unrec_high in info:
+ if name == item:
+ perfdata = [ (name, val + unit) ] # TODO: add warn and crit levels
+ if status == 'ok':
+ return (0, "%s is %s %s" % (name, val, unit), perfdata)
+ elif status == 'nc':
+ return (1, "%s is %s %s" % (name, val, unit), perfdata)
+ else:
+ return (2, "%s is %s %s" % (name, val, unit), perfdata)
def check_ipmi_summarized(info):
worst_status = 0