mirror of
https://github.com/stylersnico/librenms.git
synced 2026-08-01 16:26:55 +02:00
repoll toner capacity
git-svn-id: http://www.observium.org/svn/observer/trunk@3138 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -465,7 +465,7 @@ function discover_mempool(&$valid, $device, $index, $type, $descr, $precision =
|
||||
}
|
||||
}
|
||||
|
||||
function discover_toner(&$valid, $device, $oid, $index, $type, $descr, $capacity = NULL, $current = NULL)
|
||||
function discover_toner(&$valid, $device, $oid, $capacity_oid, $index, $type, $descr, $capacity = NULL, $current = NULL)
|
||||
{
|
||||
global $config, $debug;
|
||||
|
||||
@@ -473,8 +473,8 @@ function discover_toner(&$valid, $device, $oid, $index, $type, $descr, $capacity
|
||||
|
||||
if (mysql_result(mysql_query("SELECT count(toner_id) FROM `toner` WHERE device_id = '".$device['device_id']."' AND toner_type = '$type' AND `toner_index` = '$index'"),0) == '0')
|
||||
{
|
||||
$query = "INSERT INTO toner (`device_id`, `toner_oid`, `toner_index`, `toner_type`, `toner_descr`, `toner_capacity`, `toner_current`) ";
|
||||
$query .= " VALUES ('".$device['device_id']."', '$oid', '$index', '$type', '$descr', '$capacity', '$current')";
|
||||
$query = "INSERT INTO toner (`device_id`, `toner_oid`, `toner_capacity_oid`, `toner_index`, `toner_type`, `toner_descr`, `toner_capacity`, `toner_current`) ";
|
||||
$query .= " VALUES ('".$device['device_id']."', '$oid', '$capacity_oid', '$index', '$type', '$descr', '$capacity', '$current')";
|
||||
mysql_query($query);
|
||||
echo("+");
|
||||
log_event("Toner added: type ".mres($type)." index ".mres($index)." descr ". mres($descr), $device, 'toner', mysql_insert_id());
|
||||
@@ -488,7 +488,7 @@ function discover_toner(&$valid, $device, $oid, $index, $type, $descr, $capacity
|
||||
}
|
||||
else
|
||||
{
|
||||
mysql_query("UPDATE toner SET `toner_descr` = '$descr', `toner_oid` = '$oid', `toner_capacity` = '$capacity' WHERE `device_id` = '".$device['device_id']."' AND toner_type = '$type' AND `toner_index` = '$index' ");
|
||||
mysql_query("UPDATE toner SET `toner_descr` = '$descr', `toner_oid` = '$oid', `toner_capacity_oid` = '$capacity_oid', `toner_capacity` = '$capacity' WHERE `device_id` = '".$device['device_id']."' AND toner_type = '$type' AND `toner_index` = '$index' ");
|
||||
echo("U");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ if ($config['enable_printers'])
|
||||
$current = $current / $capacity * 100;
|
||||
$type = "jetdirect";
|
||||
if (isHexString($descr)) { $descr = snmp_hexstring($descr); }
|
||||
discover_toner($valid_toner,$device, $toner_oid, $index, $type, $descr, $capacity, $current);
|
||||
discover_toner($valid_toner,$device, $toner_oid, $capacity_oid, $index, $type, $descr, $capacity, $current);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ elseif ($device['os'] == "qnap")
|
||||
}
|
||||
elseif ($device['os'] == "dsm")
|
||||
{
|
||||
# FIXME only the build, not the actual version number, so won't use this.. yet?
|
||||
# This only gets us the build, not the actual version number, so won't use this.. yet.
|
||||
# list(,,,$version,) = explode(" ",$poll_device['sysDescr'],5);
|
||||
# $version = "Build " . trim($version,'#');
|
||||
|
||||
|
||||
@@ -8,9 +8,8 @@ if ($config['enable_printers'])
|
||||
{
|
||||
echo("Checking toner " . $toner['toner_descr'] . "... ");
|
||||
|
||||
$toner['toner_capacity'] = snmp_get($device, $toner['toner_capacity_oid'], "-OUqnv");
|
||||
$tonerperc = round(snmp_get($device, $toner['toner_oid'], "-OUqnv") / $toner['toner_capacity'] * 100);
|
||||
# FIXME also repoll capacity, or tonerperc can be incorrect; then line below can go too
|
||||
if ($tonerperc > 100) { $tonerperc = 100; } # ^
|
||||
|
||||
$old_tonerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("toner-" . $toner['toner_descr'] . ".rrd");
|
||||
$tonerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("toner-" . $toner['toner_index'] . ".rrd");
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `toner` ADD `toner_capacity_oid` VARCHAR( 64 );
|
||||
Reference in New Issue
Block a user