Module: check_mk
Branch: master
Commit: fb59201503d5216d9e46cea3ed7fd192cfd1274e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fb59201503d521…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Wed Dec 19 08:51:38 2018 +0100
alcatel.include: reduce madness a little
Change-Id: Ib9bb8515fc0b9d2d64a9f46934a23ed48c25a9c9
---
checks/alcatel.include | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/checks/alcatel.include b/checks/alcatel.include
index fc89291..bd7b348 100644
--- a/checks/alcatel.include
+++ b/checks/alcatel.include
@@ -80,13 +80,14 @@ def check_alcatel_fans(item, _no_params, info):
1: "not running",
2: "running",
}
- for nr, value in enumerate(info):
- if nr + 1 == item:
- fan_state = int(value[0])
- state = 0
- if fan_state != 2:
- state = 2
- return state, "Fan " + fan_states[fan_state]
+ try:
+ line = info[int(item) - 1]
+ fan_state = int(line[0])
+ except (ValueError, IndexError):
+ return
+
+ state = 0 if fan_state == 2 else 2
+ return state, "Fan " + fan_states.get(fan_state, "unknown (%s)" %
fan_state)
def inventory_alcatel_power(info):