mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
stealth toner overview health page
git-svn-id: http://www.observium.org/svn/observer/trunk@2561 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
18
html/includes/graphs/toner/auth.inc.php
Executable file
18
html/includes/graphs/toner/auth.inc.php
Executable file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
if (is_numeric($id))
|
||||
{
|
||||
$toner = dbFetchRow("SELECT * FROM `toner` WHERE `toner_id` = ?", array($id));
|
||||
|
||||
if (is_numeric($toner['device_id']) && ($config['allow_unauth_graphs'] || device_permitted($toner['device_id'])))
|
||||
{
|
||||
$device = device_by_id_cache($toner['device_id']);
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("toner-" . $toner['toner_index'] . ".rrd");
|
||||
|
||||
$title = generate_device_link($device);
|
||||
$title .= " :: Toner :: " . htmlentities($toner['toner_descr']);
|
||||
$auth = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
33
html/includes/graphs/toner/usage.inc.php
Executable file
33
html/includes/graphs/toner/usage.inc.php
Executable file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
$scale_min = "0";
|
||||
$scale_max = "100";
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
$iter = "1";
|
||||
|
||||
$rrd_options .= " COMMENT:' Cur Max\\n'";
|
||||
|
||||
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"; }
|
||||
|
||||
$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 .= " 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'] . ":MAX:%5.0lf%%\\\\l";
|
||||
|
||||
?>
|
@ -22,6 +22,7 @@ $type_text['fanspeed'] = "Fanspeed";
|
||||
$type_text['frequency'] = "Frequency";
|
||||
$type_text['current'] = "Current";
|
||||
$type_text['power'] = "Power";
|
||||
$type_text['toner'] = "Toner";
|
||||
|
||||
if (!$vars['metric']) { $vars['metric'] = "processor"; }
|
||||
if (!$vars['view']) { $vars['view'] = "detail"; }
|
||||
@ -84,6 +85,7 @@ print_optionbar_end();
|
||||
if (in_array($vars['metric'],array_keys($used_sensors))
|
||||
|| $vars['metric'] == 'processor'
|
||||
|| $vars['metric'] == 'storage'
|
||||
|| $vars['metric'] == 'toner'
|
||||
|| $vars['metric'] == 'mempool')
|
||||
{
|
||||
include('pages/health/'.$vars['metric'].'.inc.php');
|
||||
|
70
html/pages/health/toner.inc.php
Normal file
70
html/pages/health/toner.inc.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
$graph_type = "toner_usage";
|
||||
|
||||
echo("<div style='padding: 5px;'>
|
||||
<table width=100% cellspacing=0 cellpadding=6 class='sortable'>");
|
||||
|
||||
echo("<tr class=tablehead>
|
||||
<th width=280>Device</th>
|
||||
<th>Toner</th>
|
||||
<th width=100></th>
|
||||
<th width=280>Usage</th>
|
||||
<th width=50>Used</th>
|
||||
</tr>");
|
||||
|
||||
$row = 1;
|
||||
|
||||
foreach (dbFetchRows("SELECT * FROM `toner` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY D.hostname, S.toner_descr") as $toner)
|
||||
{
|
||||
if (device_permitted($toner['device_id']))
|
||||
{
|
||||
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
|
||||
|
||||
$total = $toner['toner_capacity'];
|
||||
$perc = $toner['toner_current'];
|
||||
|
||||
$graph_array['type'] = $graph_type;
|
||||
$graph_array['id'] = $toner['toner_id'];
|
||||
$graph_array['from'] = $config['time']['day'];
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
$graph_array['height'] = "20";
|
||||
$graph_array['width'] = "80";
|
||||
$graph_array_zoom = $graph_array;
|
||||
$graph_array_zoom['height'] = "150";
|
||||
$graph_array_zoom['width'] = "400";
|
||||
$link = "graphs/id=" . $graph_array['id'] . "/type=" . $graph_array['type'] . "/from=" . $graph_array['from'] . "/to=" . $graph_array['to'] . "/";
|
||||
$mini_graph = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL);
|
||||
|
||||
$background = get_percentage_colours(100 - $perc);
|
||||
|
||||
echo("<tr bgcolor='$row_colour'><td>" . generate_device_link($toner) . "</td><td class=tablehead>" . $toner['toner_descr'] . "</td>
|
||||
<td>$mini_graph</td>
|
||||
<td>
|
||||
<a href='#' $store_popup>".print_percentage_bar (400, 20, $perc, "$perc%", "ffffff", $background['left'], $free, "ffffff", $background['right'])."</a>
|
||||
</td><td>$perc"."%</td></tr>");
|
||||
|
||||
if ($vars['view'] == "graphs")
|
||||
{
|
||||
|
||||
echo("<tr bgcolor='$row_colour'><td colspan=5>");
|
||||
|
||||
$graph_array['height'] = "100";
|
||||
$graph_array['width'] = "216";
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
$graph_array['id'] = $toner['toner_id'];
|
||||
$graph_array['type'] = $graph_type;
|
||||
|
||||
include("includes/print-quadgraphs.inc.php");
|
||||
|
||||
echo("</td></tr>");
|
||||
|
||||
} # endif graphs
|
||||
|
||||
$row++;
|
||||
}
|
||||
}
|
||||
|
||||
echo("</table></div>");
|
||||
|
||||
?>
|
Reference in New Issue
Block a user