Module: check_mk
Branch: master
Commit: 14b34a948c850f82442f5f6a6543d67250089fa0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=14b34a948c850f…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Jun 26 12:00:15 2017 +0200
4873 FIX printer_supply: Fixed IndexError in case of missing colour information
Some devices such as HP Laser Jet 1200 do not provide colour
information which caused above error during discovery.
Change-Id: Ie8497ec673881252e644fba700e63b57be9b9984
---
.werks/4873 | 12 ++++++++++++
checks/printer_supply | 7 +++++--
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/.werks/4873 b/.werks/4873
new file mode 100644
index 0000000..ffa0ea9
--- /dev/null
+++ b/.werks/4873
@@ -0,0 +1,12 @@
+Title: printer_supply: Fixed IndexError in case of missing colour information
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1498470954
+
+Some devices such as HP Laser Jet 1200 do not provide colour
+information which caused above error during discovery.
diff --git a/checks/printer_supply b/checks/printer_supply
index 6aaf181..611a3cb 100644
--- a/checks/printer_supply
+++ b/checks/printer_supply
@@ -76,9 +76,12 @@ def printer_supply_fix_infos(info):
if line[4]:
colors += [ line[4] ]
color = line[4]
- elif line[4] == '':
+ elif line[4] == '' and colors:
color = colors[index - len(colors)]
- line_0 = '%s %s' % (color.title(), line_0)
+ else:
+ color = None
+ if color:
+ line_0 = '%s %s' % (color.title(), line_0)
if " S/N:" in line_0:
line_0 = line_0[:line_0.find(" S/N:")]