From 38c56fe3d8aa6e643b160bf8192a0beb0f99572f Mon Sep 17 00:00:00 2001 From: Pall Sigurdsson Date: Mon, 25 Jun 2012 09:32:55 +0000 Subject: [PATCH] Bugfix, no longer returns problem when not all powermodules are installed (thanks Davide Gandolfi) --- check_ibm_bladecenter/check_ibm_bladecenter.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/check_ibm_bladecenter/check_ibm_bladecenter.py b/check_ibm_bladecenter/check_ibm_bladecenter.py index 7bbc658..b8dc72e 100644 --- a/check_ibm_bladecenter/check_ibm_bladecenter.py +++ b/check_ibm_bladecenter/check_ibm_bladecenter.py @@ -226,20 +226,24 @@ def check_powermodules(): status = 3 details = 4 num_ok = 0 + num_no = 0 for i in powermodules.values(): myIndex = i[index] myStatus = i[status] myDetails = i[details] myExists = i[exists] if myIndex == opts.exclude: continue - if myStatus != "1": - nagios_status(warning) - add_summary( 'Powermodule "%s" status "%s". %s. ' % (myIndex,myStatus,myDetails) ) + if myExists == "0": + num_no = num_no + 1 else: - num_ok = num_ok + 1 + if myStatus != "1": + nagios_status(warning) + add_summary( 'Powermodule "%s" status "%s". %s. ' % (myIndex,myStatus,myDetails) ) + else: + num_ok = num_ok + 1 add_long('Powersupply "%s" status "%s". %s. ' % (myIndex,myStatus,myDetails) ) add_summary( "%s out of %s powermodules are healthy" % (num_ok, len(powermodules) ) ) - add_perfdata( "'Number of powermodules'=%s" % (len(powermodules) ) ) + add_perfdata( "'Number of powermodules'=%s" % (len(powermodules) - num_no ) ) nagios_status(ok)