mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
show toner on device overview (beta), minor fixes
git-svn-id: http://www.observium.org/svn/observer/trunk@3014 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -1,5 +1,20 @@
|
||||
<?php
|
||||
|
||||
function toner2colour($descr)
|
||||
{
|
||||
$colour = NULL;
|
||||
|
||||
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) == 'Y' || stripos($descr,"yellow" ) !== false
|
||||
|| stripos($descr,"giallo" ) !== false
|
||||
|| stripos($descr,"gul" ) !== false) { $colour = "FFF200"; }
|
||||
if (substr($descr,-1) == 'K' || stripos($descr,"black" ) !== false
|
||||
|| stripos($descr,"nero" ) !== false) { $colour = "000000"; }
|
||||
|
||||
return $colour;
|
||||
}
|
||||
|
||||
function generate_link($text, $vars, $new_vars = array())
|
||||
{
|
||||
return '<a href="'.generate_url($vars, $new_vars).'">'.$text.'</a>';
|
||||
|
||||
@@ -10,40 +10,39 @@ $iter = "1";
|
||||
$rrd_options .= " COMMENT:'Toner level Cur Min Max\\n'";
|
||||
foreach (dbFetchRows("SELECT * FROM toner where device_id = ?", array($id)) as $toner)
|
||||
{
|
||||
# FIXME generic colour function
|
||||
switch ($iter)
|
||||
$colour = toner2colour($toner['toner_descr']);
|
||||
|
||||
if ($colour == NULL)
|
||||
{
|
||||
case "1":
|
||||
$colour= "000000";
|
||||
break;
|
||||
case "2":
|
||||
$colour= "008C00";
|
||||
break;
|
||||
case "3":
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
case "4":
|
||||
$colour= "73880A";
|
||||
break;
|
||||
case "5":
|
||||
$colour= "D01F3C";
|
||||
break;
|
||||
case "6":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
default:
|
||||
$colour= "FF0000";
|
||||
unset($iter);
|
||||
break;
|
||||
# FIXME generic colour function
|
||||
switch ($iter)
|
||||
{
|
||||
case "1":
|
||||
$colour= "000000";
|
||||
break;
|
||||
case "2":
|
||||
$colour= "008C00";
|
||||
break;
|
||||
case "3":
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
case "4":
|
||||
$colour= "73880A";
|
||||
break;
|
||||
case "5":
|
||||
$colour= "D01F3C";
|
||||
break;
|
||||
case "6":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
default:
|
||||
$colour= "FF0000";
|
||||
unset($iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (stripos($toner['toner_descr'],"cyan" ) !== false || substr($toner['toner_descr'],-1) == 'C') { $colour = "55D6D3"; }
|
||||
if (stripos($toner['toner_descr'],"magenta") !== false || substr($toner['toner_descr'],-1) == 'M') { $colour = "F24AC8"; }
|
||||
if (stripos($toner['toner_descr'],"yellow" ) !== false || substr($toner['toner_descr'],-1) == 'Y' || stripos($toner['toner_descr'],"giallo" ) !== false) { $colour = "FFF200"; }
|
||||
if (stripos($toner['toner_descr'],"black" ) !== false || substr($toner['toner_descr'],-1) == 'K' || stripos($toner['toner_descr'],"nero" ) !== false) { $colour = "000000"; }
|
||||
|
||||
|
||||
$hostname = gethostbyid($toner['device_id']);
|
||||
|
||||
$descr = substr(str_pad($toner['toner_descr'], 16),0,16);
|
||||
|
||||
@@ -4,20 +4,12 @@ $scale_max = "100";
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
$iter = "1";
|
||||
$rrd_options .= " COMMENT:' Cur Max\\n'";
|
||||
|
||||
$rrd_options .= " COMMENT:' Cur Max\\n'";
|
||||
$colour = toner2colour($toner['toner_descr']);
|
||||
if ($colour == NULL) { $colour="CC0000"; }
|
||||
|
||||
if ($iter=="1") { $colour="CC0000"; } elseif ($iter=="2") { $colour="008C00"; } elseif ($iter=="3") { $colour="4096EE"; }
|
||||
elseif ($iter=="4") { $colour="73880A"; } elseif ($iter=="5") { $colour="D01F3C"; } elseif ($iter=="6") { $colour="36393D"; }
|
||||
elseif ($iter=="7") { $colour="FF0084"; unset($iter); }
|
||||
|
||||
$descr = substr(str_pad($toner['toner_descr']),0,28);
|
||||
|
||||
if (stripos($toner['toner_descr'],"cyan" ) !== false || substr($toner['toner_descr'],-1) == 'C') { $colour = "55D6D3"; }
|
||||
if (stripos($toner['toner_descr'],"magenta") !== false || substr($toner['toner_descr'],-1) == 'M') { $colour = "F24AC8"; }
|
||||
if (stripos($toner['toner_descr'],"yellow" ) !== false || substr($toner['toner_descr'],-1) == 'Y') { $colour = "FFF200"; }
|
||||
if (stripos($toner['toner_descr'],"black" ) !== false || substr($toner['toner_descr'],-1) == 'K') { $colour = "000000"; }
|
||||
$descr = substr(str_pad($toner['toner_descr'],26),0,26);
|
||||
|
||||
$background = get_percentage_colours(100-$toner['toner_current']);
|
||||
|
||||
@@ -26,8 +18,7 @@ $rrd_options .= " DEF:toner" . $toner['toner_id'] . "=".$rrd_filename.":toner:AV
|
||||
$rrd_options .= " LINE1:toner" . $toner['toner_id'] . "#" . $colour . ":'" . $descr . "' ";
|
||||
|
||||
$rrd_options .= " AREA:toner" . $toner['toner_id' ] . "#" . $background['right'] . ":";
|
||||
$rrd_options .= " GPRINT:toner" . $toner['toner_id'] . ":AVERAGE:'%5.0lf%%'";
|
||||
$rrd_options .= " GPRINT:toner" . $toner['toner_id'] . ":MIN:'%5.0lf%%'";
|
||||
$rrd_options .= " GPRINT:toner" . $toner['toner_id'] . ":LAST:'%5.0lf%%'";
|
||||
$rrd_options .= " GPRINT:toner" . $toner['toner_id'] . ":MAX:%5.0lf%%\\\\l";
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user