mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 00:24:21 +02:00
move fanspeed to sensors table - please run discovery immediately after svn up
git-svn-id: http://www.observium.org/svn/observer/trunk@1270 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -7,7 +7,7 @@ $device = device_by_id_cache($id);
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
|
||||
$iter = "1";
|
||||
$sql = mysql_query("SELECT * FROM fanspeed where device_id = '$id'");
|
||||
$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='fanspeed' AND device_id = '$id'");
|
||||
$rrd_options .= " COMMENT:'RPM Cur Min Max\\n'";
|
||||
while($fanspeed = mysql_fetch_array($sql))
|
||||
{
|
||||
@@ -38,9 +38,9 @@ while($fanspeed = mysql_fetch_array($sql))
|
||||
break;
|
||||
}
|
||||
|
||||
$descr = substr(str_pad($fanspeed['fan_descr'], 17),0,17);
|
||||
$rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("fan-" . $fanspeed['fan_descr'] . ".rrd");
|
||||
$fan_id = $fanspeed['fan_id'];
|
||||
$descr = substr(str_pad($fanspeed['sensor_descr'], 17),0,17);
|
||||
$rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("fan-" . $fanspeed['sensor_descr'] . ".rrd");
|
||||
$fan_id = $fanspeed['sensor_id'];
|
||||
|
||||
$rrd_options .= " DEF:fan$fan_id=$rrd_filename:fan:AVERAGE";
|
||||
$rrd_options .= " LINE1:fan$fan_id#".$colour.":'" . $descr . "'";
|
||||
@@ -51,5 +51,4 @@ while($fanspeed = mysql_fetch_array($sql))
|
||||
$iter++;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -6,16 +6,16 @@ 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'])."'"));
|
||||
$fanspeed = mysql_fetch_array(mysql_query("SELECT * FROM sensors WHERE sensor_class='fanspeed' AND fan_id = '".mres($_GET['id'])."'"));
|
||||
|
||||
$hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $fanspeed['device_id'] . "'"),0);
|
||||
|
||||
$fanspeed['fan_descr_fixed'] = substr(str_pad($fanspeed['fan_descr'], 20),0,20);
|
||||
$fanspeed['sensor_descr_fixed'] = substr(str_pad($fanspeed['sensor_descr'], 20),0,20);
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/".$hostname."/" . safename("fan-" . $fanspeed['fan_descr'] . ".rrd");
|
||||
$rrd_filename = $config['rrd_dir'] . "/".$hostname."/" . safename("fan-" . $fanspeed['sensor_descr'] . ".rrd");
|
||||
|
||||
$rrd_options .= " DEF:fan=$rrd_filename:fan:AVERAGE";
|
||||
$rrd_options .= " LINE1.5:fan#cc0000:'" . str_replace(':','\:',str_replace('\*','*',quotemeta($fanspeed['fan_descr_fixed'])))."'"; # Ugly hack :(
|
||||
$rrd_options .= " LINE1.5:fan#cc0000:'" . str_replace(':','\:',str_replace('\*','*',quotemeta($fanspeed['sensor_descr_fixed'])))."'"; # Ugly hack :(
|
||||
$rrd_options .= " GPRINT:fan:LAST:%3.0lfrpm";
|
||||
$rrd_options .= " GPRINT:fan:MAX:%3.0lfrpm\\\\l";
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ $storage = mysql_result(mysql_query("select count(*) from storage WHERE device_i
|
||||
$diskio = mysql_result(mysql_query("select count(*) from ucd_diskio WHERE device_id = '" . $device['device_id'] . "'"), 0);
|
||||
$memory = mysql_result(mysql_query("select count(*) from mempools WHERE device_id = '" . $device['device_id'] . "'"), 0);
|
||||
$processor = mysql_result(mysql_query("select count(*) from processors WHERE device_id = '" . $device['device_id'] . "'"), 0);
|
||||
$fans = mysql_result(mysql_query("select count(*) from fanspeed WHERE device_id = '" . $device['device_id'] . "'"), 0);
|
||||
$fans = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_class='fanspeed' AND device_id = '" . $device['device_id'] . "'"), 0);
|
||||
$volts = mysql_result(mysql_query("select count(*) from voltage WHERE device_id = '" . $device['device_id'] . "'"), 0);
|
||||
$freqs = mysql_result(mysql_query("select count(*) from frequency WHERE device_id = '" . $device['device_id'] . "'"), 0);
|
||||
$current = mysql_result(mysql_query("select count(*) from current WHERE device_id = '" . $device['device_id'] . "'"), 0);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$sql = "SELECT * FROM `fanspeed` WHERE device_id = '" . $_GET[id] . "' ORDER BY fan_descr";
|
||||
$sql = "SELECT * FROM `sensors` WHERE sensor_class='fanspeed' AND device_id = '" . $_GET[id] . "' ORDER BY sensor_descr";
|
||||
$query = mysql_query($sql);
|
||||
|
||||
echo("<table cellspacing=0 cellpadding=5 width=100%>");
|
||||
@@ -12,10 +12,10 @@ while($fan = mysql_fetch_array($query)) {
|
||||
if(!is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
|
||||
|
||||
echo("<tr class=list-large style=\"background-color: $row_colour; padding: 5px;\">
|
||||
<td width=350>" . $fan['fan_descr'] . "</td>
|
||||
<td>" . $fan['fan_current'] . " rpm</td>
|
||||
<td>" . $fan['fan_limit'] . " rpm</td>
|
||||
<td>" . $fan['fan_notes'] . "</td>
|
||||
<td width=350>" . $fan['sensor_descr'] . "</td>
|
||||
<td>" . $fan['sensor_current'] . " rpm</td>
|
||||
<td>" . $fan['sensor_limit'] . " rpm</td>
|
||||
<td>" . $fan['sensor_notes'] . "</td>
|
||||
</tr>\n");
|
||||
echo("<tr bgcolor=$row_colour><td colspan='4'>");
|
||||
|
||||
@@ -23,17 +23,17 @@ while($fan = mysql_fetch_array($query)) {
|
||||
|
||||
// start fanspeed graphs
|
||||
|
||||
$daily_fan = "graph.php?id=" . $fan['fan_id'] . "&type=$graph_type&from=$day&to=$now&width=211&height=100";
|
||||
$daily_url = "graph.php?id=" . $fan['fan_id'] . "&type=$graph_type&from=$day&to=$now&width=400&height=150";
|
||||
$daily_fan = "graph.php?id=" . $fan['sensor_id'] . "&type=$graph_type&from=$day&to=$now&width=211&height=100";
|
||||
$daily_url = "graph.php?id=" . $fan['sensor_id'] . "&type=$graph_type&from=$day&to=$now&width=400&height=150";
|
||||
|
||||
$weekly_fan = "graph.php?id=" . $fan['fan_id'] . "&type=$graph_type&from=$week&to=$now&width=211&height=100";
|
||||
$weekly_url = "graph.php?id=" . $fan['fan_id'] . "&type=$graph_type&from=$week&to=$now&width=400&height=150";
|
||||
$weekly_fan = "graph.php?id=" . $fan['sensor_id'] . "&type=$graph_type&from=$week&to=$now&width=211&height=100";
|
||||
$weekly_url = "graph.php?id=" . $fan['sensor_id'] . "&type=$graph_type&from=$week&to=$now&width=400&height=150";
|
||||
|
||||
$monthly_fan = "graph.php?id=" . $fan['fan_id'] . "&type=$graph_type&from=$month&to=$now&width=211&height=100";
|
||||
$monthly_url = "graph.php?id=" . $fan['fan_id'] . "&type=$graph_type&from=$month&to=$now&width=400&height=150";
|
||||
$monthly_fan = "graph.php?id=" . $fan['sensor_id'] . "&type=$graph_type&from=$month&to=$now&width=211&height=100";
|
||||
$monthly_url = "graph.php?id=" . $fan['sensor_id'] . "&type=$graph_type&from=$month&to=$now&width=400&height=150";
|
||||
|
||||
$yearly_fan = "graph.php?id=" . $fan['fan_id'] . "&type=$graph_type&from=$year&to=$now&width=211&height=100";
|
||||
$yearly_url = "graph.php?id=" . $fan['fan_id'] . "&type=$graph_type&from=$year&to=$now&width=400&height=150";
|
||||
$yearly_fan = "graph.php?id=" . $fan['sensor_id'] . "&type=$graph_type&from=$year&to=$now&width=211&height=100";
|
||||
$yearly_url = "graph.php?id=" . $fan['sensor_id'] . "&type=$graph_type&from=$year&to=$now&width=400&height=150";
|
||||
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$daily_fan' border=0></a> ");
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<?php
|
||||
|
||||
unset($fan_seperator);
|
||||
if(mysql_result(mysql_query("SELECT count(fan_id) from fanspeed WHERE device_id = '" . $device['device_id'] . "'"),0)) {
|
||||
$total = mysql_result(mysql_query("SELECT count(fan_id) from fanspeed WHERE device_id = '" . $device['device_id'] . "'"),0);
|
||||
if($total = mysql_result(mysql_query("SELECT count(sensor_id) from sensors WHERE sensor_class='fanspeed' AND device_id = '" . $device['device_id'] . "'"),0)) {
|
||||
$rows = round($total / 2,0);
|
||||
echo("<div style='background-color: #eeeeee; margin: 5px; padding: 5px;'>");
|
||||
echo("<p style='padding: 0px 5px 5px;' class=sectionhead><img align='absmiddle' src='".$config['base_url']."/images/icons/fanspeeds.png'> Fanspeeds</p>");
|
||||
@@ -16,21 +15,21 @@ if(mysql_result(mysql_query("SELECT count(fan_id) from fanspeed WHERE device_id
|
||||
|
||||
$graph_colour = str_replace("#", "", $row_colour);
|
||||
|
||||
$fan_day = "graph.php?id=" . $fan['fan_id'] . "&type=fanspeed&from=$day&to=$now&width=300&height=100";
|
||||
$fan_week = "graph.php?id=" . $fan['fan_id'] . "&type=fanspeed&from=$week&to=$now&width=300&height=100";
|
||||
$fan_month = "graph.php?id=" . $fan['fan_id'] . "&type=fanspeed&from=$month&to=$now&width=300&height=100";
|
||||
$fan_year = "graph.php?id=" . $fan['fan_id'] . "&type=fanspeed&from=$year&to=$now&width=300&height=100";
|
||||
$fan_minigraph = "<img src='graph.php?id=" . $fan['fan_id'] . "&type=fanspeed&from=$day&to=$now&width=80&height=20&bg=$graph_colour' align='absmiddle'>";
|
||||
$fan_day = "graph.php?id=" . $fan['sensor_id'] . "&type=fanspeed&from=$day&to=$now&width=300&height=100";
|
||||
$fan_week = "graph.php?id=" . $fan['sensor_id'] . "&type=fanspeed&from=$week&to=$now&width=300&height=100";
|
||||
$fan_month = "graph.php?id=" . $fan['sensor_id'] . "&type=fanspeed&from=$month&to=$now&width=300&height=100";
|
||||
$fan_year = "graph.php?id=" . $fan['sensor_id'] . "&type=fanspeed&from=$year&to=$now&width=300&height=100";
|
||||
$fan_minigraph = "<img src='graph.php?id=" . $fan['sensor_id'] . "&type=fanspeed&from=$day&to=$now&width=80&height=20&bg=$graph_colour' align='absmiddle'>";
|
||||
|
||||
$fan_link = "<a href='/device/".$device['device_id']."/health/fanspeeds/' onmouseover=\"return ";
|
||||
$fan_link .= "overlib('<div class=list-large>".$device['hostname']." - ".$fan['fan_descr'];
|
||||
$fan_link .= "overlib('<div class=list-large>".$device['hostname']." - ".$fan['sensor_descr'];
|
||||
$fan_link .= "</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();\" >";
|
||||
|
||||
$fan_link_b = $fan_link . $fan_minigraph . "</a>";
|
||||
$fan_link_c = $fan_link . "<span style='" . ($fan['fan_current'] <= $fan['fan_limit'] ? "color: red" : '') . "'>" . $fan['fan_current'] . "rpm</span></a>";
|
||||
$fan_link_a = $fan_link . $fan['fan_descr'] . "</a>";
|
||||
$fan_link_c = $fan_link . "<span style='" . ($fan['sensor_current'] <= $fan['sensor_limit'] ? "color: red" : '') . "'>" . $fan['sensor_current'] . "rpm</span></a>";
|
||||
$fan_link_a = $fan_link . $fan['sensor_descr'] . "</a>";
|
||||
|
||||
$fan['fan_descr'] = truncate($fan['fan_descr'], 25, '');
|
||||
$fan['sensor_descr'] = truncate($fan['sensor_descr'], 25, '');
|
||||
echo("<tr bgcolor='$row_colour'><td class=tablehead><strong>$fan_link_a</strong></td><td width=80 align=right class=tablehead>$fan_link_b<td width=80 align=right class=tablehead>$fan_link_c</td></tr>");
|
||||
if($i == $rows) { echo("</table></td><td valign=top><table width=100% cellspacing=0 cellpadding=2>"); }
|
||||
$i++;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
if($_SESSION['userlevel'] >= '5') {
|
||||
$sql = "SELECT * FROM `fanspeed` AS F, `devices` AS D WHERE F.device_id = D.device_id ORDER BY D.hostname, F.fan_descr";
|
||||
$sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='fanspeed' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr";
|
||||
} else {
|
||||
$sql = "SELECT * FROM `fanspeed` AS F, `devices` AS D, devices_perms as P WHERE F.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, F.fan_descr";
|
||||
$sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='fanspeed' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, S.sensor_descr";
|
||||
}
|
||||
|
||||
$query = mysql_query($sql);
|
||||
@@ -26,19 +26,19 @@ 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'] . "&type=fanspeed&from=$week&to=$now&width=500&height=150";
|
||||
$weekly_fan = "graph.php?id=" . $fan['sensor_id'] . "&type=fanspeed&from=$week&to=$now&width=500&height=150";
|
||||
$fan_popup = "<a onmouseover=\"return overlib('<img src=\'$weekly_fan\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
" . $fan['fan_descr'] . "</a>";
|
||||
" . $fan['sensor_descr'] . "</a>";
|
||||
|
||||
if($fan['fan_current'] <= $fan['fan_limit']) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
|
||||
if($fan['sensor_current'] <= $fan['sensor_limit']) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
|
||||
|
||||
$fan_day = "graph.php?id=" . $fan['fan_id'] . "&type=fanspeed&from=$day&to=$now&width=300&height=100";
|
||||
$fan_week = "graph.php?id=" . $fan['fan_id'] . "&type=fanspeed&from=$week&to=$now&width=300&height=100";
|
||||
$fan_month = "graph.php?id=" . $fan['fan_id'] . "&type=fanspeed&from=$month&to=$now&width=300&height=100";
|
||||
$fan_year = "graph.php?id=" . $fan['fan_id'] . "&type=fanspeed&from=$year&to=$now&width=300&height=100";
|
||||
$fan_day = "graph.php?id=" . $fan['sensor_id'] . "&type=fanspeed&from=$day&to=$now&width=300&height=100";
|
||||
$fan_week = "graph.php?id=" . $fan['sensor_id'] . "&type=fanspeed&from=$week&to=$now&width=300&height=100";
|
||||
$fan_month = "graph.php?id=" . $fan['sensor_id'] . "&type=fanspeed&from=$month&to=$now&width=300&height=100";
|
||||
$fan_year = "graph.php?id=" . $fan['sensor_id'] . "&type=fanspeed&from=$year&to=$now&width=300&height=100";
|
||||
|
||||
$fan_minigraph = "<img src='graph.php?id=" . $fan['fan_id'] . "&type=fanspeed&from=$day&to=$now&width=100&height=20'";
|
||||
$fan_minigraph .= " onmouseover=\"return overlib('<div class=list-large>".$fan['hostname']." - ".$fan['fan_descr'];
|
||||
$fan_minigraph = "<img src='graph.php?id=" . $fan['sensor_id'] . "&type=fanspeed&from=$day&to=$now&width=100&height=20'";
|
||||
$fan_minigraph .= " onmouseover=\"return overlib('<div class=list-large>".$fan['hostname']." - ".$fan['sensor_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>
|
||||
@@ -46,26 +46,26 @@ while($fan = mysql_fetch_array($query))
|
||||
<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>
|
||||
<td style='text-align: center; font-weight: bold;'>" . $fan['sensor_current'] . " rpm</td>
|
||||
<td style='text-align: center'>" . $fan['sensor_limit'] . " rpm</td>
|
||||
<td>" . (isset($fan['sensor_notes']) ? $fan['sensor_notes'] : '') . "</td>
|
||||
</tr>\n");
|
||||
|
||||
if($_GET['optb'] == "graphs") { ## If graphs
|
||||
|
||||
echo("<tr bgcolor='$row_colour'><td colspan=6>");
|
||||
|
||||
$daily_graph = "graph.php?id=" . $fan['fan_id'] . "&type=fanspeed&from=$day&to=$now&width=211&height=100";
|
||||
$daily_url = "graph.php?id=" . $fan['fan_id'] . "&type=fanspeed&from=$day&to=$now&width=400&height=150";
|
||||
$daily_graph = "graph.php?id=" . $fan['sensor_id'] . "&type=fanspeed&from=$day&to=$now&width=211&height=100";
|
||||
$daily_url = "graph.php?id=" . $fan['sensor_id'] . "&type=fanspeed&from=$day&to=$now&width=400&height=150";
|
||||
|
||||
$weekly_graph = "graph.php?id=" . $fan['fan_id'] . "&type=fanspeed&from=$week&to=$now&width=211&height=100";
|
||||
$weekly_url = "graph.php?id=" . $fan['fan_id'] . "&type=fanspeed&from=$week&to=$now&width=400&height=150";
|
||||
$weekly_graph = "graph.php?id=" . $fan['sensor_id'] . "&type=fanspeed&from=$week&to=$now&width=211&height=100";
|
||||
$weekly_url = "graph.php?id=" . $fan['sensor_id'] . "&type=fanspeed&from=$week&to=$now&width=400&height=150";
|
||||
|
||||
$monthly_graph = "graph.php?id=" . $fan['fan_id'] . "&type=fanspeed&from=$month&to=$now&width=211&height=100";
|
||||
$monthly_url = "graph.php?id=" . $fan['fan_id'] . "&type=fanspeed&from=$month&to=$now&width=400&height=150";
|
||||
$monthly_graph = "graph.php?id=" . $fan['sensor_id'] . "&type=fanspeed&from=$month&to=$now&width=211&height=100";
|
||||
$monthly_url = "graph.php?id=" . $fan['sensor_id'] . "&type=fanspeed&from=$month&to=$now&width=400&height=150";
|
||||
|
||||
$yearly_graph = "graph.php?id=" . $fan['fan_id'] . "&type=fanspeed&from=$year&to=$now&width=211&height=100";
|
||||
$yearly_url = "graph.php?id=" . $fan['fan_id'] . "&type=fanspeed&from=$year&to=$now&width=400&height=150";
|
||||
$yearly_graph = "graph.php?id=" . $fan['sensor_id'] . "&type=fanspeed&from=$year&to=$now&width=211&height=100";
|
||||
$yearly_url = "graph.php?id=" . $fan['sensor_id'] . "&type=fanspeed&from=$year&to=$now&width=400&height=150";
|
||||
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$daily_graph' border=0></a> ");
|
||||
|
||||
Reference in New Issue
Block a user