Module: check_mk
Branch: master
Commit: 8df9db02bd9f7b85a6ddb72961bf4c082abc5a44
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8df9db02bd9f7b…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Wed Nov 5 14:11:51 2014 +0100
cisco_sensor_item: Added another case of items
---
checks/cisco_sensor_item.include | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/checks/cisco_sensor_item.include b/checks/cisco_sensor_item.include
index 717feb8..b188f94 100644
--- a/checks/cisco_sensor_item.include
+++ b/checks/cisco_sensor_item.include
@@ -31,15 +31,26 @@ def cisco_sensor_item(trial_string, fall_back):
# A string seperated by commas with status information
# -> Depends on the device model
try:
- splited = trial_string.split(',')
- if len(splited) == 1:
- return trial_string
# Try to handle all cases found in mkzeug/walks
- if '#' in splited[-1] or 'Power' in splited[-1]:
- return " ".join([ x.strip() for x in
splited]).replace('#',' ')
- if splited[-2].startswith(" Status"):
- return " ".join([ x.strip() for x in
splited[:-2]]).replace('#',' ')
- return " ".join([ x.strip() for x in
splited[:-1]]).replace('#',' ')
+ splited = [ x.strip for x in trial_string.split(',')]
+ if len(splited) == 1:
+ item = trial_string
+ # If the last part contains # or Power, take the complete string
+ elif '#' in splited[-1] or 'Power' in splited[-1]:
+ item = " ".join(splited)
+ # If second last part start with Status, remove that part
+ elif splited[-2].startswith(" Status"):
+ item = " ".join(splited[:-2])
+ # Take anything, but without last part
+ else:
+ item = " ".join(splited[:-1])
+ # Maye there a multiple Items, but always the same string.
+ # Try to prevent that by adding the fall_back number to the end
+ if not item[-1].isdigit():
+ item += " "+ fall_back
+ # Replace unwanted chars and return
+ return item.replace('#',' ')
except:
return fall_back
+