Last active
November 27, 2018 13:29
-
-
Save foamrider/02e0496328b8839ca17b to your computer and use it in GitHub Desktop.
Observium: Add separate pagecounters for color and black
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From ffc9255934b84a1094d936cd0c38365d6cf306d3 Mon Sep 17 00:00:00 2001 | |
From: drtomasso | |
Date: Tue, 30 Jun 2015 11:08:13 +0200 | |
Subject: [PATCH] add separate counters for color and black/white prints (testet on Ricoh) | |
--- | |
.../includes/graphs/device/pagecount_black.inc.php | 17 ++++++++++ | |
.../includes/graphs/device/pagecount_color.inc.php | 17 ++++++++++ | |
html/pages/device/printing.inc.php | 20 ++++++++++++ | |
includes/discovery/toner.inc.php | 24 +++++++++++++++ | |
includes/polling/toner.inc.php | 36 ++++++++++++++++++++++ | |
5 files changed, 114 insertions(+) | |
create mode 100644 html/includes/graphs/device/pagecount_black.inc.php | |
create mode 100644 html/includes/graphs/device/pagecount_color.inc.php | |
diff --git a/html/includes/graphs/device/pagecount_black.inc.php b/html/includes/graphs/device/pagecount_black.inc.php | |
new file mode 100644 | |
index 0000000..6a9bb1f | |
--- /dev/null | |
+++ b/html/includes/graphs/device/pagecount_black.inc.php | |
@@ -0,0 +1,17 @@ | |
+<?php | |
+ | |
+include_once($config['html_dir']."/includes/graphs/common.inc.php"); | |
+ | |
+$rrd_options .= " -l 0 -E "; | |
+ | |
+$pagecount_rrd = get_rrd_path($device, "pagecountblack.rrd"); | |
+ | |
+if (file_exists($pagecount_rrd)) | |
+{ | |
+ $rrd_options .= " COMMENT:' Cur\\n'"; | |
+ $rrd_options .= " DEF:pagecount_black=".$pagecount_rrd.":pagecount_black:AVERAGE "; | |
+ $rrd_options .= " LINE1:pagecount_black#CC0000:'Black pages printed ' "; | |
+ $rrd_options .= " GPRINT:pagecount_black:LAST:%3.0lf\\\l"; | |
+} | |
+ | |
+// EOF | |
diff --git a/html/includes/graphs/device/pagecount_color.inc.php b/html/includes/graphs/device/pagecount_color.inc.php | |
new file mode 100644 | |
index 0000000..1b0c202 | |
--- /dev/null | |
+++ b/html/includes/graphs/device/pagecount_color.inc.php | |
@@ -0,0 +1,17 @@ | |
+<?php | |
+ | |
+include_once($config['html_dir']."/includes/graphs/common.inc.php"); | |
+ | |
+$rrd_options .= " -l 0 -E "; | |
+ | |
+$pagecount_rrd = get_rrd_path($device, "pagecountcolor.rrd"); | |
+ | |
+if (file_exists($pagecount_rrd)) | |
+{ | |
+ $rrd_options .= " COMMENT:' Cur\\n'"; | |
+ $rrd_options .= " DEF:pagecount_color=".$pagecount_rrd.":pagecount_color:AVERAGE "; | |
+ $rrd_options .= " LINE1:pagecount_color#CC0000:'Color pages printed ' "; | |
+ $rrd_options .= " GPRINT:pagecount_color:LAST:%3.0lf\\\l"; | |
+} | |
+ | |
+// EOF | |
diff --git a/html/pages/device/printing.inc.php b/html/pages/device/printing.inc.php | |
index 1607a30..2215231 100644 | |
--- a/html/pages/device/printing.inc.php | |
+++ b/html/pages/device/printing.inc.php | |
@@ -30,6 +30,26 @@ if (get_dev_attrib($device, "pagecount_oid")) | |
unset($graph_array); | |
+if (get_dev_attrib($device, "pagecount_color_oid")) | |
+{ | |
+ $graph_title = "Pagecounter Color"; | |
+ $graph_type = "device_pagecount_color"; | |
+ | |
+ include("includes/print-device-graph.php"); | |
+} | |
+ | |
+unset($graph_array); | |
+ | |
+if (get_dev_attrib($device, "pagecount_black_oid")) | |
+{ | |
+ $graph_title = "Pagecounter Black"; | |
+ $graph_type = "device_pagecount_black"; | |
+ | |
+ include("includes/print-device-graph.php"); | |
+} | |
+ | |
+unset($graph_array); | |
+ | |
if (get_dev_attrib($device, "imagingdrum_c_oid")) | |
{ | |
$graph_title = "Imaging Drums"; | |
diff --git a/includes/discovery/toner.inc.php b/includes/discovery/toner.inc.php | |
index 8128085..fad39ad 100644 | |
--- a/includes/discovery/toner.inc.php | |
+++ b/includes/discovery/toner.inc.php | |
@@ -178,6 +178,30 @@ if ($config['enable_printers'] && $device['os_group'] == 'printer') | |
} | |
} | |
+ $pagecounters_color = array("1.3.6.1.4.1.367.3.2.1.2.19.5.1.9.21"); | |
+ | |
+ foreach ($pagecounters_color as $oid) | |
+ { | |
+ if (snmp_get($device, $oid, "-OUqnv")) | |
+ { | |
+ echo(" Pagecounter Color"); | |
+ set_dev_attrib($device, "pagecount_color_oid", $oid); | |
+ break; | |
+ } | |
+ } | |
+ | |
+ $pagecounters_black = array("1.3.6.1.4.1.367.3.2.1.2.19.5.1.9.22"); | |
+ | |
+ foreach ($pagecounters_black as $oid) | |
+ { | |
+ if (snmp_get($device, $oid, "-OUqnv")) | |
+ { | |
+ echo(" Pagecounter Black"); | |
+ set_dev_attrib($device, "pagecount_black_oid", $oid); | |
+ break; | |
+ } | |
+ } | |
+ | |
echo(PHP_EOL); | |
} # if ($config['enable_printers'] && $device['os_group'] == 'printers') | |
diff --git a/includes/polling/toner.inc.php b/includes/polling/toner.inc.php | |
index 10e3a6d..8be1337 100644 | |
--- a/includes/polling/toner.inc.php | |
+++ b/includes/polling/toner.inc.php | |
@@ -79,6 +79,42 @@ if ($config['enable_printers']) | |
echo("$pages\n"); | |
} | |
+ $oid = get_dev_attrib($device, 'pagecount_color_oid'); | |
+ | |
+ if ($oid) | |
+ { | |
+ echo("Checking color page count... "); | |
+ $pages = snmp_get($device, $oid, "-OUqnv"); | |
+ | |
+ $pagecountcolorrrd = "pagecountcolor.rrd"; | |
+ | |
+ rrdtool_create($device, $pagecountcolorrrd," \ | |
+ DS:pagecount_color:GAUGE:600:0:U "); | |
+ | |
+ set_dev_attrib($device, "pagecounter_color", $pages); | |
+ rrdtool_update($device, $pagecountcolorrrd,"N:$pages"); | |
+ | |
+ echo("$pages\n"); | |
+ } | |
+ | |
+ $oid = get_dev_attrib($device, 'pagecount_black_oid'); | |
+ | |
+ if ($oid) | |
+ { | |
+ echo("Checking black page count... "); | |
+ $pages = snmp_get($device, $oid, "-OUqnv"); | |
+ | |
+ $pagecountblackrrd = "pagecountblack.rrd"; | |
+ | |
+ rrdtool_create($device, $pagecountblackrrd," \ | |
+ DS:pagecount_black:GAUGE:600:0:U "); | |
+ | |
+ set_dev_attrib($device, "pagecounter_black", $pages); | |
+ rrdtool_update($device, $pagecountblackrrd,"N:$pages"); | |
+ | |
+ echo("$pages\n"); | |
+ } | |
+ | |
$oid = get_dev_attrib($device, 'imagingdrum_oid'); | |
if ($oid) | |
-- | |
1.8.4.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dear friend, I'm doing a test for xerox printers, your code is very interesting, so I ask for your help if you can share the files, I appreciate your help and time. (pagecount_black.inc.php, pagecount_color.inc.php, printing.inc.php,toner.inc.php, toner.inc.php)
Best Regards.