voltage and fanspeeds now on webpage, graphs for fans are broken for now

git-svn-id: http://www.observium.org/svn/observer/trunk@813 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2010-02-11 09:21:32 +00:00
parent 217e119ca2
commit e05223fb40
6 changed files with 180 additions and 2 deletions

View File

@@ -0,0 +1,27 @@
<?php
$scale_min = "0";
include("common.inc.php");
$rrd_options .= " COMMENT:' Last Max\\n'";
$fanspeed = mysql_fetch_array(mysql_query("SELECT * FROM fanspeed where fan_id = '".mres($_GET['id'])."'"));
$hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $fanspeed['fan_host'] . "'"),0);
$fanspeed['fan_descr_fixed'] = str_pad($fanspeed['fan_descr'], 28);
$fanspeed['fan_descr_fixed'] = substr($fanspeed['fan_descr_fixed'],0,28);
$rrd_filename = $config['rrd_dir'] . "/".$hostname."/" . safename("fan-" . $fanspeed['fan_descr'] . ".rrd");
$rrd_options .= " DEF:fan=$rrd_filename:fan:AVERAGE";
$rrd_options .= " CDEF:fanwarm=fan,".$fanspeed['fan_limit'].",GT,fan,UNKN,IF";
$rrd_options .= " AREA:fan#FFFF99";
$rrd_options .= " AREA:fanwarm#FF9999";
$rrd_options .= " LINE1.5:fan#cc0000:'" . str_replace(':','\:',str_replace('\*','*',quotemeta($fanspeed['fan_descr_fixed'])))."'"; # Ugly hack :(
$rrd_options .= " LINE1.5:fanwarm#660000";
$rrd_options .= " GPRINT:fan:LAST:%3.0lfC";
$rrd_options .= " GPRINT:fan:MAX:%3.0lfC\\\\l";
?>

View File

@@ -0,0 +1,27 @@
<?php
$scale_min = "0";
include("common.inc.php");
$rrd_options .= " COMMENT:' Last Max\\n'";
$voltage = mysql_fetch_array(mysql_query("SELECT * FROM voltage where volt_id = '".mres($_GET['id'])."'"));
$hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $voltage['volt_host'] . "'"),0);
$voltage['volt_descr_fixed'] = str_pad($voltage['volt_descr'], 28);
$voltage['volt_descr_fixed'] = substr($voltage['volt_descr_fixed'],0,28);
$rrd_filename = $config['rrd_dir'] . "/".$hostname."/" . safename("volt-" . $voltage['volt_descr'] . ".rrd");
$rrd_options .= " DEF:volt=$rrd_filename:volt:AVERAGE";
$rrd_options .= " CDEF:voltwarm=volt,".$voltage['volt_limit'].",GT,volt,UNKN,IF";
$rrd_options .= " AREA:volt#FFFF99";
$rrd_options .= " AREA:voltwarm#FF9999";
$rrd_options .= " LINE1.5:volt#cc0000:'" . $voltage['volt_descr_fixed']."'";
$rrd_options .= " LINE1.5:voltwarm#660000";
$rrd_options .= " GPRINT:volt:LAST:%3.0lfC";
$rrd_options .= " GPRINT:volt:MAX:%3.0lfC\\\\l";
?>

View File

@@ -158,7 +158,7 @@ echo('<li><a href="interfaces/?status=0"><img src="images/16/link_error.png" bor
<table><tr><td>
<ul>
<li><a href="sensors/temperatures/"><img src="images/icons/temperature.png" border="0" align="absmiddle" /> Temperatures</a></li>
<li><a href="sensors/fans/"><img src="images/icons/fans.png" border="0" align="absmiddle" /> Fans</a></li>
<li><a href="sensors/fanspeeds/"><img src="images/icons/fans.png" border="0" align="absmiddle" /> Fans</a></li>
<li><a href="sensors/voltages/"><img src="images/icons/voltages.png" border="0" align="absmiddle" /> Voltages</a></li>
</ul>
</td></tr></table>

View File

@@ -24,7 +24,7 @@ switch ($_GET['opta'])
{
case 'temperatures':
case 'voltages':
case 'fans':
case 'fanspeeds':
include('pages/sensors/'.$_GET['opta'].'.php');
break;
default:

View File

@@ -0,0 +1,62 @@
<?php
if($_SESSION['userlevel'] >= '5') {
$sql = "SELECT * FROM `fanspeed` AS F, `devices` AS D WHERE F.fan_host = D.device_id ORDER BY D.hostname, F.fan_descr";
} else {
$sql = "SELECT * FROM `fanspeed` AS F, `devices` AS D, devices_perms as P WHERE F.fan_host = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, F.fan_descr";
}
$query = mysql_query($sql);
echo('<table cellspacing="0" cellpadding="2" width="100%">');
echo('<tr class=tablehead>
<th width="280">Device</th>
<th width="280">Fan</th>
<th></th>
<th></th>
<th width="100">Current</th>
<th width="100">Alert</th>
<th>Notes</th>
</tr>');
$row = 1;
while($fan = mysql_fetch_array($query))
{
if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$weekly_fan = "graph.php?id=" . $fan['fan_id'] . "&amp;type=fanspeed&amp;from=$week&amp;to=$now&amp;width=500&amp;height=150";
$fan_popup = "<a onmouseover=\"return overlib('<img src=\'$weekly_fan\'>', LEFT);\" onmouseout=\"return nd();\">
" . $fan['fan_descr'] . "</a>";
if($fan['fan_current'] <= $fan['fan_limit']) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
$fan_day = "graph.php?id=" . $fan['fan_id'] . "&amp;type=fanspeed&amp;from=$day&amp;to=$now&amp;width=300&amp;height=100";
$fan_week = "graph.php?id=" . $fan['fan_id'] . "&amp;type=fanspeed&amp;from=$week&amp;to=$now&amp;width=300&amp;height=100";
$fan_month = "graph.php?id=" . $fan['fan_id'] . "&amp;type=fanspeed&amp;from=$month&amp;to=$now&amp;width=300&amp;height=100";
$fan_year = "graph.php?id=" . $fan['fan_id'] . "&amp;type=fanspeed&amp;from=$year&amp;to=$now&amp;width=300&amp;height=100";
$fan_minigraph = "<img src='graph.php?id=" . $fan['fan_id'] . "&amp;type=fanspeed&amp;from=$day&amp;to=$now&amp;width=100&amp;height=20'";
$fan_minigraph .= " onmouseover=\"return overlib('<div class=list-large>".$fan['hostname']." - ".$fan['fan_descr'];
$fan_minigraph .= "</div><div style=\'width: 750px\'><img src=\'$fan_day\'><img src=\'$fan_week\'><img src=\'$fan_month\'><img src=\'$fan_year\'></div>', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\" >";
echo("<tr bgcolor=$row_colour>
<td class=list-bold>" . generatedevicelink($fan) . "</td>
<td>$fan_popup</td>
<td>$fan_minigraph</td>
<td width=100>$alert</td>
<td style='text-align: center; font-weight: bold;'>" . $fan['fan_current'] . " rpm</td>
<td style='text-align: center'>" . $fan['fan_limit'] . " rpm</td>
<td>" . (isset($fan['fan_notes']) ? $fan['fan_notes'] : '') . "</td>
</tr>\n");
$row++;
}
echo("</table>");
?>

View File

@@ -0,0 +1,62 @@
<?php
if($_SESSION['userlevel'] >= '5') {
$sql = "SELECT * FROM `voltage` AS V, `devices` AS D WHERE V.volt_host = D.device_id ORDER BY D.hostname, V.volt_descr";
} else {
$sql = "SELECT * FROM `voltage` AS V, `devices` AS D, devices_perms as P WHERE V.volt_host = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, V.volt_descr";
}
$query = mysql_query($sql);
echo('<table cellspacing="0" cellpadding="2" width="100%">');
echo('<tr class=tablehead>
<th width="280">Device</th>
<th width="180">Sensor</th>
<th></th>
<th></th>
<th width="100">Current</th>
<th width="250">Range limit</th>
<th>Notes</th>
</tr>');
$row = 1;
while($volt = mysql_fetch_array($query))
{
if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$weekly_volt = "graph.php?id=" . $volt['volt_id'] . "&amp;type=voltage&amp;from=$week&amp;to=$now&amp;width=500&amp;height=150";
$volt_popup = "<a onmouseover=\"return overlib('<img src=\'$weekly_volt\'>', LEFT);\" onmouseout=\"return nd();\">
" . $volt['volt_descr'] . "</a>";
if($volt['volt_current'] >= $volt['volt_limit']) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
$volt_day = "graph.php?id=" . $volt['volt_id'] . "&amp;type=voltage&amp;from=$day&amp;to=$now&amp;width=300&amp;height=100";
$volt_week = "graph.php?id=" . $volt['volt_id'] . "&amp;type=voltage&amp;from=$week&amp;to=$now&amp;width=300&amp;height=100";
$volt_month = "graph.php?id=" . $volt['volt_id'] . "&amp;type=voltage&amp;from=$month&amp;to=$now&amp;width=300&amp;height=100";
$volt_year = "graph.php?id=" . $volt['volt_id'] . "&amp;type=voltage&amp;from=$year&amp;to=$now&amp;width=300&amp;height=100";
$volt_minigraph = "<img src='graph.php?id=" . $volt['volt_id'] . "&amp;type=voltage&amp;from=$day&amp;to=$now&amp;width=100&amp;height=20'";
$volt_minigraph .= " onmouseover=\"return overlib('<div class=list-large>".$volt['hostname']." - ".$volt['volt_descr'];
$volt_minigraph .= "</div><div style=\'width: 750px\'><img src=\'$volt_day\'><img src=\'$volt_week\'><img src=\'$volt_month\'><img src=\'$volt_year\'></div>', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\" >";
echo("<tr bgcolor=$row_colour>
<td class=list-bold>" . generatedevicelink($volt) . "</td>
<td>$volt_popup</td>
<td>$volt_minigraph</td>
<td width=100>$alert</td>
<td style='text-align: center; font-weight: bold;'>" . $volt['volt_current'] . "V</td>
<td style='text-align: center'>" . $volt['volt_limit_low'] . "V - " . $volt['volt_limit'] . "V</td>
<td>" . (isset($volt['volt_notes']) ? $volt['volt_notes'] : '') . "</td>
</tr>\n");
$row++;
}
echo("</table>");
?>