mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-12 08:02:23 +02:00
toner polling
git-svn-id: http://www.observium.org/svn/observer/trunk@1014 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Executable
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
if ($config['show_printers'])
|
||||
{
|
||||
$query = "SELECT * FROM toner WHERE device_id = '" . $device['device_id'] . "'";
|
||||
$toner_data = mysql_query($query);
|
||||
|
||||
while($toner = mysql_fetch_array($toner_data))
|
||||
{
|
||||
echo("Checking toner " . $toner['toner_descr'] . "... ");
|
||||
|
||||
$toner_cmd = $config['snmpget'] . " -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $toner['toner_oid'] . "|grep -v \"No Such Instance\"";
|
||||
$tonerperc = trim(str_replace("\"", "", shell_exec($toner_cmd)));
|
||||
$tonerperc = $tonerperc / $toner['toner_capacity'] * 100;
|
||||
|
||||
$tonerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("toner-" . $toner['toner_descr'] . ".rrd");
|
||||
|
||||
if (!is_file($tonerrrd))
|
||||
{
|
||||
`rrdtool create $tonerrrd \
|
||||
--step 300 \
|
||||
DS:toner:GAUGE:100:0:20000 \
|
||||
RRA:AVERAGE:0.5:1:1200 \
|
||||
RRA:MIN:0.5:12:2400 \
|
||||
RRA:MAX:0.5:12:2400 \
|
||||
RRA:AVERAGE:0.5:12:2400`;
|
||||
}
|
||||
|
||||
echo($tonerperc . " %\n");
|
||||
|
||||
rrdtool_update($tonerrrd,"N:$tonerperc");
|
||||
|
||||
#FIXME could report for toner out... :)
|
||||
|
||||
mysql_query("UPDATE toner SET toner_current = '$tonerperc' WHERE toner_id = '" . $toner['toner_id'] . "'");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -164,6 +164,7 @@ while ($device = mysql_fetch_array($device_query)) {
|
||||
include("includes/polling/ports.inc.php");
|
||||
include("includes/polling/cisco-mac-accounting.inc.php");
|
||||
include("includes/polling/bgpPeer.inc.php");
|
||||
include("includes/polling/toner.inc.php")
|
||||
|
||||
unset( $update ) ;
|
||||
unset( $seperator) ;
|
||||
|
||||
Reference in New Issue
Block a user