mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
cleanups, add epson printer discovery, fix bar colour on device overview for unknown toner colours
git-svn-id: http://www.observium.org/svn/observer/trunk@3036 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
<?php
|
||||
|
||||
function toner2colour($descr)
|
||||
function toner2colour($descr, $percent)
|
||||
{
|
||||
$colour = NULL;
|
||||
$colour = get_percentage_colours(100-$percent);
|
||||
|
||||
if (substr($descr,-1) == 'C' || stripos($descr,"cyan" ) !== false) { $colour = "55D6D3"; }
|
||||
if (substr($descr,-1) == 'M' || stripos($descr,"magenta") !== false) { $colour = "F24AC8"; }
|
||||
if (substr($descr,-1) == 'C' || stripos($descr,"cyan" ) !== false) { $colour['left'] = "55D6D3"; $colour['right'] = "33B4B1"; }
|
||||
if (substr($descr,-1) == 'M' || stripos($descr,"magenta") !== false) { $colour['left'] = "F24AC8"; $colour['right'] = "D028A6"; }
|
||||
if (substr($descr,-1) == 'Y' || stripos($descr,"yellow" ) !== false
|
||||
|| stripos($descr,"giallo" ) !== false
|
||||
|| stripos($descr,"gul" ) !== false) { $colour = "FFF200"; }
|
||||
|| stripos($descr,"gul" ) !== false) { $colour['left'] = "FFF200"; $colour['right'] = "DDD000"; }
|
||||
if (substr($descr,-1) == 'K' || stripos($descr,"black" ) !== false
|
||||
|| stripos($descr,"nero" ) !== false) { $colour = "000000"; }
|
||||
|| stripos($descr,"nero" ) !== false) { $colour['left'] = "000000"; $colour['right'] = "222222"; }
|
||||
|
||||
return $colour;
|
||||
}
|
||||
|
||||
@@ -12,32 +12,32 @@ foreach (dbFetchRows("SELECT * FROM toner where device_id = ?", array($id)) as $
|
||||
{
|
||||
$colour = toner2colour($toner['toner_descr']);
|
||||
|
||||
if ($colour == NULL)
|
||||
if ($colour['left'] == NULL)
|
||||
{
|
||||
# FIXME generic colour function
|
||||
switch ($iter)
|
||||
{
|
||||
case "1":
|
||||
$colour= "000000";
|
||||
$colour['left']= "000000";
|
||||
break;
|
||||
case "2":
|
||||
$colour= "008C00";
|
||||
$colour['left']= "008C00";
|
||||
break;
|
||||
case "3":
|
||||
$colour= "4096EE";
|
||||
$colour['left']= "4096EE";
|
||||
break;
|
||||
case "4":
|
||||
$colour= "73880A";
|
||||
$colour['left']= "73880A";
|
||||
break;
|
||||
case "5":
|
||||
$colour= "D01F3C";
|
||||
$colour['left']= "D01F3C";
|
||||
break;
|
||||
case "6":
|
||||
$colour= "36393D";
|
||||
$colour['left']= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
default:
|
||||
$colour= "FF0000";
|
||||
$colour['left']= "FF0000";
|
||||
unset($iter);
|
||||
break;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ foreach (dbFetchRows("SELECT * FROM toner where device_id = ?", array($id)) as $
|
||||
$toner_id = $toner['toner_id'];
|
||||
|
||||
$rrd_options .= " DEF:toner$toner_id=$rrd_filename:toner:AVERAGE";
|
||||
$rrd_options .= " LINE2:toner$toner_id#".$colour.":'" . $descr . "'";
|
||||
$rrd_options .= " LINE2:toner$toner_id#".$colour['left'].":'" . $descr . "'";
|
||||
$rrd_options .= " GPRINT:toner$toner_id:LAST:'%5.0lf%%'";
|
||||
$rrd_options .= " GPRINT:toner$toner_id:MIN:'%5.0lf%%'";
|
||||
$rrd_options .= " GPRINT:toner$toner_id:MAX:%5.0lf%%\\\\l";
|
||||
|
||||
@@ -7,7 +7,7 @@ include("includes/graphs/common.inc.php");
|
||||
$rrd_options .= " COMMENT:' Cur Max\\n'";
|
||||
|
||||
$colour = toner2colour($toner['toner_descr']);
|
||||
if ($colour == NULL) { $colour="CC0000"; }
|
||||
if ($colour['left'] == NULL) { $colour['left']="CC0000"; }
|
||||
|
||||
$descr = substr(str_pad($toner['toner_descr'],26),0,26);
|
||||
|
||||
@@ -15,7 +15,7 @@ $background = get_percentage_colours(100-$toner['toner_current']);
|
||||
|
||||
$rrd_options .= " DEF:toner" . $toner['toner_id'] . "=".$rrd_filename.":toner:AVERAGE ";
|
||||
|
||||
$rrd_options .= " LINE1:toner" . $toner['toner_id'] . "#" . $colour . ":'" . $descr . "' ";
|
||||
$rrd_options .= " LINE1:toner" . $toner['toner_id'] . "#" . $colour['left'] . ":'" . $descr . "' ";
|
||||
|
||||
$rrd_options .= " AREA:toner" . $toner['toner_id' ] . "#" . $background['right'] . ":";
|
||||
$rrd_options .= " GPRINT:toner" . $toner['toner_id'] . ":LAST:'%5.0lf%%'";
|
||||
|
||||
Reference in New Issue
Block a user