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:
Tom Laermans
2012-04-09 23:00:31 +00:00
parent cc5ec6c1e6
commit 08952e40c6
8 changed files with 129 additions and 53 deletions

View File

@@ -48,10 +48,10 @@ if ($services['total'])
foreach (dbFetchRows("SELECT * FROM services WHERE device_id = ? ORDER BY service_type", array($device['device_id'])) as $data)
{
if ($data[service_status] == "0" && $data[service_ignore] == "1") { $status = "grey"; }
if ($data[service_status] == "1" && $data[service_ignore] == "1") { $status = "green"; }
if ($data[service_status] == "0" && $data[service_ignore] == "0") { $status = "red"; }
if ($data[service_status] == "1" && $data[service_ignore] == "0") { $status = "blue"; }
if ($data['service_status'] == "0" && $data['service_ignore'] == "1") { $status = "grey"; }
if ($data['service_status'] == "1" && $data['service_ignore'] == "1") { $status = "green"; }
if ($data['service_status'] == "0" && $data['service_ignore'] == "0") { $status = "red"; }
if ($data['service_status'] == "1" && $data['service_ignore'] == "0") { $status = "blue"; }
echo("$break<a class=$status>" . strtolower($data[service_type]) . "</a>");
$break = ", ";
}
@@ -86,6 +86,7 @@ include("overview/storage.inc.php");
if(is_array($entity_state['group']['c6kxbar'])) { include("overview/c6kxbar.inc.php"); }
include("overview/toner.inc.php");
include("overview/sensors/temperatures.inc.php");
include("overview/sensors/humidity.inc.php");
include("overview/sensors/fanspeeds.inc.php");

View File

@@ -0,0 +1,69 @@
<?php
$graph_type = "toner_usage";
$toners = dbFetchRows("SELECT * FROM `toner` WHERE device_id = ?", array($device['device_id']));
if (count($toners))
{
echo("<div style='background-color: #eeeeee; margin: 5px; padding: 5px;'>");
echo("<p style='padding: 0px 5px 5px;' class=sectionhead>");
echo('<a class="sectionhead" href="device/device='.$device['device_id'].'/tab=toner/">');
echo("<img align='absmiddle' src='images/icons/toner.png'> Toner</a></p>");
echo("<table width=100% cellspacing=0 cellpadding=5>");
$toner_rows = '0';
foreach ($toners as $toner)
{
if (is_integer($toner_rows/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$percent = round($toner['toner_current'], 0);
$total = formatStorage($toner['toner_size']);
$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;
}
$graph_array = array();
$graph_array['height'] = "100";
$graph_array['width'] = "210";
$graph_array['to'] = $now;
$graph_array['id'] = $toner['toner_id'];
$graph_array['type'] = $graph_type;
$graph_array['from'] = $day;
$graph_array['legend'] = "no";
$link_array = $graph_array;
$link_array['page'] = "graphs";
unset($link_array['height'], $link_array['width'], $link_array['legend']);
$link = generate_url($link_array);
$overlib_content = generate_overlib_content($graph_array, $device['hostname'] . " - " . $toner['toner_descr']);
$graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = $graph_colour;
$minigraph = generate_graph_tag($graph_array);
echo("<tr bgcolor=$row_colour>
<td class=tablehead>".overlib_link($link, $toner['toner_descr'], $overlib_content)."</td>
<td width=90>".overlib_link($link, $minigraph, $overlib_content)."</td>
<td width=200>".overlib_link($link, print_percentage_bar (200, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right']), $overlib_content)."
</a></td>
</tr>");
$toner_rows++;
}
echo("</table>");
echo("</div>");
}
unset ($toner_rows);
?>