mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00: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:
BIN
html/images/os/epson.png
Normal file
BIN
html/images/os/epson.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
@@ -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%%'";
|
||||
|
||||
@@ -19,14 +19,7 @@ if (count($toners))
|
||||
$free = formatStorage($toner['toner_free']);
|
||||
$used = formatStorage($toner['toner_used']);
|
||||
|
||||
$background['left'] = toner2colour($toner['toner_descr']);
|
||||
unset($background['right']);
|
||||
for ($i = 0;$i < strlen($background['left']); $i++)
|
||||
{
|
||||
$new = dechex(hexdec("0x" . $background['left'][$i])+1);
|
||||
if (strlen($new) != 1) { $new = 'F'; }
|
||||
$background['right'] .= $new;
|
||||
}
|
||||
$background = toner2colour($toner['toner_descr'], $percent);
|
||||
|
||||
$graph_array = array();
|
||||
$graph_array['height'] = "100";
|
||||
|
||||
8
includes/discovery/os/epson.inc.php
Normal file
8
includes/discovery/os/epson.inc.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
if (!$os)
|
||||
{
|
||||
if (strstr($sysDescr, "EPSON Built-in")) { $os = "epson"; }
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -2,21 +2,15 @@
|
||||
|
||||
## We should walk, so we can discover here too.
|
||||
|
||||
echo("Polling BGP peers\n");
|
||||
|
||||
global $debug;
|
||||
|
||||
if (!$config['enable_bgp'])
|
||||
{
|
||||
echo("BGP Support Disabled\n");
|
||||
}
|
||||
else
|
||||
if ($config['enable_bgp'])
|
||||
{
|
||||
foreach (dbFetchRows("SELECT * FROM bgpPeers WHERE device_id = ?", array($device['device_id'])) as $peer)
|
||||
{
|
||||
### Poll BGP Peer
|
||||
|
||||
echo("Checking ".$peer['bgpPeerIdentifier']." ");
|
||||
echo("Checking BGP peer ".$peer['bgpPeerIdentifier']." ");
|
||||
|
||||
if (!strstr($peer['bgpPeerIdentifier'],':'))
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
echo("Wireless: ");
|
||||
|
||||
if ($device['type'] == 'network' || $device['type'] == 'firewall')
|
||||
{
|
||||
echo("Wireless: ");
|
||||
|
||||
##### GENERIC FRAMEWORK, FILLING VARIABLES
|
||||
if ($device['os'] == 'airport')
|
||||
{
|
||||
|
||||
@@ -739,6 +739,14 @@ $config['os'][$os]['icon'] = "ricoh";
|
||||
$config['os'][$os]['over'][0]['graph'] = "device_toner";
|
||||
$config['os'][$os]['over'][0]['text'] = "Toner";
|
||||
|
||||
$os = "epson";
|
||||
$config['os'][$os]['group'] = "printer";
|
||||
$config['os'][$os]['text'] = "Epson Printer";
|
||||
$config['os'][$os]['type'] = "printer";
|
||||
$config['os'][$os]['icon'] = "epson";
|
||||
$config['os'][$os]['over'][0]['graph'] = "device_toner";
|
||||
$config['os'][$os]['over'][0]['text'] = "Toner";
|
||||
|
||||
$os = "xerox";
|
||||
$config['os'][$os]['group'] = "printer";
|
||||
$config['os'][$os]['text'] = "Xerox Printer";
|
||||
|
||||
Reference in New Issue
Block a user