adapted printer_supply_ricoh
Message-ID: <559b6eb4./qek347mKmxFd9us%si(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: af3af0e0f615ec988eb1b41f08a84d2436c861ff
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=af3af0e0f615ec…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Jul 6 15:16:42 2015 +0200
changed colors of printer_pages, adapted printer_supply_ricoh
---
checks/printer_supply_ricoh | 106 ++++++++++++++++++++++++++++++---------
web/plugins/metrics/check_mk.py | 43 +++++++++++-----
2 files changed, 112 insertions(+), 37 deletions(-)
diff --git a/checks/printer_supply_ricoh b/checks/printer_supply_ricoh
index f7384f1..e4e9996 100644
--- a/checks/printer_supply_ricoh
+++ b/checks/printer_supply_ricoh
@@ -25,33 +25,89 @@
# Boston, MA 02110-1301 USA.
-printer_supply_ricoh_default = ( 20, 10 )
-
-def inventory_printer_supply_ricoh(info):
- return [ (x[0], "printer_supply_ricoh_default") for x in info ]
-
-def check_printer_supply_ricoh(item, params, info):
- warn, crit = params
- for line in info:
- if item == line[0]:
- state = 0
- level = saveint(line[1])
- if level < crit:
+# .1.3.6.1.4.1.367.3.2.1.2.24.1.1.2.1 Black Toner
+# .1.3.6.1.4.1.367.3.2.1.2.24.1.1.2.2 Cyan Toner
+# .1.3.6.1.4.1.367.3.2.1.2.24.1.1.2.3 Magenta Toner
+# .1.3.6.1.4.1.367.3.2.1.2.24.1.1.2.4 Yellow Toner
+# .1.3.6.1.4.1.367.3.2.1.2.24.1.1.5.1 30
+# .1.3.6.1.4.1.367.3.2.1.2.24.1.1.5.2 20
+# .1.3.6.1.4.1.367.3.2.1.2.24.1.1.5.3 30
+# .1.3.6.1.4.1.367.3.2.1.2.24.1.1.5.4 -100
+
+# some data may look like
+# .1.3.6.1.4.1.367.3.2.1.2.24.1.1.2.1 Toner
+# .1.3.6.1.4.1.367.3.2.1.2.24.1.1.5.1 30
+
+
+factory_settings["printer_supply_ricoh_default_levels"] = {
+ "levels" : ( 20.0, 10.0 )
+}
+
+
+def parse_printer_supply_ricoh(info):
+ parsed = {}
+ for what, pages_text in info:
+ name_reversed = what.split(" ")
+
+ if len(name_reversed) == 2:
+ name_reversed.reverse()
+
+ name = " ".join(name_reversed)
+ parsed[name] = int(pages_text)
+ return parsed
+
+
+def inventory_printer_supply_ricoh(parsed):
+ return [ (key, {}) for key in parsed ]
+
+
+def check_printer_supply_ricoh(item, params, parsed):
+ if type(params) == tuple:
+ params = { "levels" : params }
+
+ warn, crit = params["levels"]
+
+ for name, supply_level in parsed.items():
+ if item == name:
+ if supply_level < 0:
+ supply_level = 0
+
+ infotext = "%.0f%%" % supply_level
+
+ if supply_level <= crit:
state = 2
- elif level < warn:
+ elif supply_level <= warn:
state = 1
- message = "Remaining: %s%% (levels at %d%%/%d%%) " % (level, warn,
crit)
- perfdata = [ ("level", level, warn, crit, 0, 100)]
- return (state, message, perfdata)
- return(3, "Supply information not found")
+ else:
+ state = 0
-check_info['printer_supply_ricoh'] = {
- "inventory_function" : inventory_printer_supply_ricoh,
- "check_function" : check_printer_supply_ricoh,
- "service_description" : "Supply %s",
- "has_perfdata" : True,
- "group" : "printer_supply",
- "snmp_info" : ( ".1.3.6.1.4.1.367.3.2.1.2.24.1.1", [ 2, 5
] ),
- "snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.2.0") in [
".1.3.6.1.4.1.367.1.1" ]
+ if state > 0:
+ infotext += " (levels at %.0f%%/%.0f%%)" % (warn, crit)
+ if "black" in name.lower():
+ perf_type = "black"
+ elif "cyan" in name.lower():
+ perf_type = "cyan"
+ elif "magenta" in name.lower():
+ perf_type = "magenta"
+ elif "yellow" in name.lower():
+ perf_type = "yellow"
+ else:
+ perf_type = "other"
+
+ perfdata = [ ("supply_toner_" + perf_type, supply_level, warn,
crit, 0, 100) ]
+
+ return state, infotext, perfdata
+
+
+check_info['printer_supply_ricoh'] = {
+ "parse_function" : parse_printer_supply_ricoh,
+ "inventory_function" : inventory_printer_supply_ricoh,
+ "check_function" : check_printer_supply_ricoh,
+ "service_description" : "Supply %s",
+ "has_perfdata" : True,
+ "group" : "printer_supply",
+ "snmp_info" : ( ".1.3.6.1.4.1.367.3.2.1.2.24.1.1",
[ 2, 5 ] ),
+ "snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.2.0")
in [ ".1.3.6.1.4.1.367.1.1" ],
+ "default_levels_variable" :
"printer_supply_ricoh_default_levels",
}
diff --git a/web/plugins/metrics/check_mk.py b/web/plugins/metrics/check_mk.py
index 52184f2..b331b27 100644
--- a/web/plugins/metrics/check_mk.py
+++ b/web/plugins/metrics/check_mk.py
@@ -1840,7 +1840,7 @@ metric_info["mail_queue_active_length"] = {
metric_info["pages_total"] = {
"title" : _("Total printed pages"),
"unit" : "count",
- "color" : "#939393",
+ "color" : "46/a",
}
metric_info["pages_color"] = {
@@ -1852,67 +1852,73 @@ metric_info["pages_color"] = {
metric_info["pages_bw"] = {
"title" : _("B/W"),
"unit" : "count",
- "color" : "#111111",
+ "color" : "51/a",
}
metric_info["pages_a4"] = {
"title" : _("A4"),
"unit" : "count",
- "color" : "#45f1ff",
+ "color" : "31/a",
}
metric_info["pages_a3"] = {
"title" : _("A3"),
"unit" : "count",
- "color" : "#48c9fb",
+ "color" : "31/b",
}
metric_info["pages_color_a4"] = {
"title" : _("Color A4"),
"unit" : "count",
- "color" : "#007ff4",
+ "color" : "41/a",
}
metric_info["pages_bw_a4"] = {
"title" : _("B/W A4"),
"unit" : "count",
- "color" : "#2f2f2f",
+ "color" : "51/b",
}
metric_info["pages_color_a3"] = {
"title" : _("Color A3"),
"unit" : "count",
- "color" : "#138eff",
+ "color" : "44/a",
}
metric_info["pages_bw_a3"] = {
"title" : _("B/W A3"),
"unit" : "count",
- "color" : "#3c3c3c",
+ "color" : "52/a",
}
metric_info["supply_toner_cyan"] = {
"title" : _("Supply toner cyan"),
"unit" : "%",
- "color" : "#00ffff",
+ "color" : "34/a",
}
metric_info["supply_toner_magenta"] = {
"title" : _("Supply toner magenta"),
"unit" : "%",
- "color" : "#ff00ff",
+ "color" : "12/a",
}
metric_info["supply_toner_yellow"] = {
"title" : _("Supply toner yellow"),
"unit" : "%",
- "color" : "#ffff00",
+ "color" : "23/a",
}
metric_info["supply_toner_black"] = {
"title" : _("Supply toner black"),
"unit" : "%",
- "color" : "#000000",
+ "color" : "51/a",
+}
+
+metric_info["supply_toner_other"] = {
+ "title" : _("Supply toner"),
+ "unit" : "%",
+ "color" : "52/a",
}
metric_info["pressure"] = {
@@ -3836,6 +3842,12 @@ perfometer_info.append({
})
perfometer_info.append({
+ "type" : "linear",
+ "segments" : [ "supply_toner_other" ],
+ "total" : 100.0,
+})
+
+perfometer_info.append({
"type" : "linear",
"segments" : [ "smoke_ppm" ],
"total" : 10,
@@ -4587,6 +4599,13 @@ graph_info.append({
"range" : (0, 100),
})
+graph_info.append({
+ "metrics" : [
+ ( "supply_toner_other", "area" )
+ ],
+ "range" : (0, 100),
+})
+
graph_info.append({
"title" : _( "Printed pages" ),