mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Re-implement Printer as a class based module (#12605)
* Re-implement Printer as a class based module * Rename toner table * wip * wip * Rename to printersupplies * Fixes * Rename * wip * wip
This commit is contained in:
@@ -1678,52 +1678,6 @@ function q_bridge_bits2indices($hex_data)
|
||||
return $indices;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $device
|
||||
* @param int|string $raw_value The value returned from snmp
|
||||
* @param int $capacity the normalized capacity
|
||||
* @return int the toner level as a percentage
|
||||
*/
|
||||
function get_toner_levels($device, $raw_value, $capacity)
|
||||
{
|
||||
// -3 means some toner is left
|
||||
if ($raw_value == '-3') {
|
||||
return 50;
|
||||
}
|
||||
|
||||
// -2 means unknown
|
||||
if ($raw_value == '-2') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// -1 mean no restrictions
|
||||
if ($raw_value == '-1') {
|
||||
return 0; // FIXME: is 0 what we should return?
|
||||
}
|
||||
|
||||
// Non-standard snmp values
|
||||
if ($device['os'] == 'ricoh' || $device['os'] == 'nrg' || $device['os'] == 'lanier') {
|
||||
if ($raw_value == '-100') {
|
||||
return 0;
|
||||
}
|
||||
} elseif ($device['os'] == 'brother') {
|
||||
if (! Str::contains($device['hardware'], 'MFC-L8850')) {
|
||||
switch ($raw_value) {
|
||||
case '0':
|
||||
return 100;
|
||||
case '1':
|
||||
return 5;
|
||||
case '2':
|
||||
return 0;
|
||||
case '3':
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return round($raw_value / $capacity * 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Intialize global stat arrays
|
||||
*/
|
||||
|
Reference in New Issue
Block a user