genericise device health pages

git-svn-id: http://www.observium.org/svn/observer/trunk@1667 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2010-08-11 13:06:35 +00:00
parent 3b5ed3524e
commit e42c60e8b0
7 changed files with 62 additions and 212 deletions

View File

@@ -1,37 +1,9 @@
<?php
$sql = "SELECT * FROM `sensors` WHERE sensor_class='current' AND device_id = '" . mres($_GET['id']) . "' ORDER BY sensor_descr";
$query = mysql_query($sql);
echo("<table cellspacing=0 cellpadding=5 width=100%>");
$row = 1;
while($current = 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>" . $current['sensor_descr'] . "</td>
<td>" . $current['sensor_current'] . "A</td>
<td>" . $current['sensor_limit_low'] . 'A - ' . $current['sensor_limit'] . "A</td>
<td>" . $current['sensor_notes'] . "</td>
</tr>\n");
echo("<tr bgcolor=$row_colour><td colspan='4'>");
$graph_type = "sensor_current";
$graph_array['id'] = $current['sensor_id'];
$graph_array['type'] = $graph_type;
include("includes/print-quadgraphs.inc.php");
$i++;
}
echo("</table>");
$class = "current";
$unit = "A";
$graph_type = "sensor_current";
include("sensors.inc.php");
?>

View File

@@ -1,41 +1,9 @@
<?php
$sql = "SELECT * FROM `sensors` WHERE sensor_class='fanspeed' AND device_id = '" . mres($_GET['id']) . "' ORDER BY sensor_descr";
$query = mysql_query($sql);
echo("<table cellspacing=0 cellpadding=5 width=100%>");
$row = 1;
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['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'>");
$graph_type = "sensor_fanspeed";
$graph_array['id'] = $fan['sensor_id'];
$graph_array['type'] = $graph_type;
include("includes/print-quadgraphs.inc.php");
echo("</td></tr>");
$row++;
}
echo("</table>");
$class = "fanspeed";
$unit = "RPM";
$graph_type = "sensor_fanspeed";
include("sensors.inc.php");
?>

View File

@@ -1,40 +1,9 @@
<?php
$sql = "SELECT * FROM `sensors` WHERE device_id = '" . mres($_GET['id']) . "' AND `sensor_class` = 'freq' ORDER BY sensor_descr";
$query = mysql_query($sql);
echo("<table cellspacing=0 cellpadding=5 width=100%>");
$row = 1;
while($sensor = 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>" . $sensor['sensor_descr'] . "</td>
<td>" . $sensor['sensor_current'] . "Hz</td>
<td>" . $sensor['sensor_limit_low'] . 'Hz - ' . $sensor['sensor_limit'] . "Hz</td>
<td>" . $sensor['sensor_notes'] . "</td>
</tr>\n");
echo("<tr bgcolor=$row_colour><td colspan='4'>");
$graph_type = "sensor_frequency";
$graph_array['id'] = $sensor['sensor_id'];
$graph_array['type'] = $graph_type;
include("includes/print-quadgraphs.inc.php");
echo("</td></tr>");
$row++;
}
echo("</table>");
$class = "freq";
$unit = "Hz";
$graph_type = "sensor_frequency";
include("sensors.inc.php");
?>

View File

@@ -1,41 +1,9 @@
<?php
$sql = "SELECT * FROM `sensors` WHERE sensor_class='humidity' AND device_id = '" . mres($_GET['id']) . "' ORDER BY sensor_descr";
$query = mysql_query($sql);
echo("<table cellspacing=0 cellpadding=5 width=100%>");
$row = 1;
while($humidity = 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>" . $humidity['sensor_descr'] . "</td>
<td>" . $humidity['sensor_current'] . " %</td>
<td>" . $humidity['sensor_limit'] . " %</td>
<td>" . $humidity['sensor_notes'] . "</td>
</tr>\n");
echo("<tr bgcolor=$row_colour><td colspan='4'>");
$graph_type = "sensor_humidity";
$graph_array['id'] = $humidity['sensor_id'];
$graph_array['type'] = $graph_type;
include("includes/print-quadgraphs.inc.php");
echo("</td></tr>");
$row++;
}
echo("</table>");
$class = "humidity";
$unit = "%";
$graph_type = "sensor_humidity";
include("sensors.inc.php");
?>

View File

@@ -0,0 +1,38 @@
<?php
$sql = "SELECT * FROM `sensors` WHERE sensor_class='".$class."' AND device_id = '" . mres($_GET['id']) . "' ORDER BY sensor_descr";
$query = mysql_query($sql);
echo("<table cellspacing=0 cellpadding=5 width=100%>");
$row = 1;
while($temp = 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=500>" . $temp['sensor_descr'] . "</td>
<td>" . $temp['sensor_type'] . "</td>
<td width=50>" . print_temperature($temp['sensor_current'], $temp['sensor_limit']) .$unit. "</td>
<td width=50>" . $temp['sensor_limit'] . $unit . "</td>
<td width=50>" . $temp['sensor_limit_low'] . $unit ."</td>
</tr>\n");
echo("<tr bgcolor=$row_colour><td colspan='5'>");
$graph_array['id'] = $temp['sensor_id'];
$graph_array['type'] = $graph_type;
include("includes/print-quadgraphs.inc.php");
echo("</td></tr>");
$row++;
}
echo("</table>");
?>

View File

@@ -1,41 +1,9 @@
<?php
$sql = "SELECT * FROM `sensors` WHERE sensor_class='temperature' AND device_id = '" . mres($_GET['id']) . "' ORDER BY sensor_descr";
$query = mysql_query($sql);
echo("<table cellspacing=0 cellpadding=5 width=100%>");
$row = 1;
while($temp = 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=400>" . $temp['sensor_descr'] . "</td>
<td width=100>" . $temp['sensor_type'] . "</td>
<td width=50>" . print_temperature($temp['sensor_current'], $temp['sensor_limit']) . "&deg;C</td>
<td width=50>" . $temp['sensor_limit'] . "&deg;C</td>
<td width=50>" . $temp['sensor_limit_low'] . "&deg;C</td>
<td width=350>" . $temp['sensor_notes'] . "</td>
</tr>\n");
echo("<tr bgcolor=$row_colour><td colspan='6'>");
$graph_type = "sensor_temperature";
$graph_array['id'] = $temp['sensor_id'];
$graph_array['type'] = $graph_type;
include("includes/print-quadgraphs.inc.php");
echo("</td></tr>");
$row++;
}
echo("</table>");
$class = "temperature";
$unit = "&deg;C";
$graph_type = "sensor_temperature";
include("sensors.inc.php");
?>

View File

@@ -1,42 +1,9 @@
<?php
$sql = "SELECT * FROM `sensors` WHERE sensor_class='voltage' AND device_id = '" . mres($_GET['id']) . "' ORDER BY sensor_descr";
$query = mysql_query($sql);
echo("<table cellspacing=0 cellpadding=5 width=100%>");
$row = 1;
while($volt = 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=450>" . $volt['sensor_descr'] . "</td>
<td>" . $volt['sensor_type'] . "</td>
<td width=50>" . $volt['sensor_current'] . "V</td>
<td width=75>" . $volt['sensor_limit_low'] . 'V - ' . $volt['sensor_limit'] . "V</td>
<td width=200>" . $volt['sensor_notes'] . "</td>
</tr>\n");
echo("<tr bgcolor=$row_colour><td colspan='5'>");
$graph_type = "sensor_voltage";
$graph_array['id'] = $volt['sensor_id'];
$graph_array['type'] = $graph_type;
include("includes/print-quadgraphs.inc.php");
echo("</td></tr>");
$row++;
}
echo("</table>");
$class = "voltage";
$unit = "V";
$graph_type = "sensor_voltage";
include("sensors.inc.php");
?>