From e42c60e8b07c82bad7b78dc5c7d36e6bb384ebaf Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Wed, 11 Aug 2010 13:06:35 +0000 Subject: [PATCH] genericise device health pages git-svn-id: http://www.observium.org/svn/observer/trunk@1667 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/pages/device/health/current.inc.php | 36 ++-------------- html/pages/device/health/fanspeeds.inc.php | 40 ++---------------- html/pages/device/health/frequencies.inc.php | 39 ++---------------- html/pages/device/health/humidity.inc.php | 40 ++---------------- html/pages/device/health/sensors.inc.php | 38 +++++++++++++++++ html/pages/device/health/temperatures.inc.php | 40 ++---------------- html/pages/device/health/voltages.inc.php | 41 ++----------------- 7 files changed, 62 insertions(+), 212 deletions(-) create mode 100644 html/pages/device/health/sensors.inc.php diff --git a/html/pages/device/health/current.inc.php b/html/pages/device/health/current.inc.php index 69a04ca71..0fa318a9b 100644 --- a/html/pages/device/health/current.inc.php +++ b/html/pages/device/health/current.inc.php @@ -1,37 +1,9 @@ "); - -$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(" - " . $current['sensor_descr'] . " - " . $current['sensor_current'] . "A - " . $current['sensor_limit_low'] . 'A - ' . $current['sensor_limit'] . "A - " . $current['sensor_notes'] . " - \n"); - echo(""); - - $graph_type = "sensor_current"; - - $graph_array['id'] = $current['sensor_id']; - $graph_array['type'] = $graph_type; - - include("includes/print-quadgraphs.inc.php"); - - $i++; - -} - -echo(""); +$class = "current"; +$unit = "A"; +$graph_type = "sensor_current"; +include("sensors.inc.php"); ?> - diff --git a/html/pages/device/health/fanspeeds.inc.php b/html/pages/device/health/fanspeeds.inc.php index d9e513aad..accf2d896 100644 --- a/html/pages/device/health/fanspeeds.inc.php +++ b/html/pages/device/health/fanspeeds.inc.php @@ -1,41 +1,9 @@ "); - -$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(" - " . $fan['sensor_descr'] . " - " . $fan['sensor_current'] . " rpm - " . $fan['sensor_limit'] . " rpm - " . $fan['sensor_notes'] . " - \n"); - echo(""); - - $graph_type = "sensor_fanspeed"; - - $graph_array['id'] = $fan['sensor_id']; - $graph_array['type'] = $graph_type; - - include("includes/print-quadgraphs.inc.php"); - - - echo(""); - - - $row++; - -} - -echo(""); +$class = "fanspeed"; +$unit = "RPM"; +$graph_type = "sensor_fanspeed"; +include("sensors.inc.php"); ?> - diff --git a/html/pages/device/health/frequencies.inc.php b/html/pages/device/health/frequencies.inc.php index 036be198e..dffb79c93 100644 --- a/html/pages/device/health/frequencies.inc.php +++ b/html/pages/device/health/frequencies.inc.php @@ -1,40 +1,9 @@ "); - -$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(" - " . $sensor['sensor_descr'] . " - " . $sensor['sensor_current'] . "Hz - " . $sensor['sensor_limit_low'] . 'Hz - ' . $sensor['sensor_limit'] . "Hz - " . $sensor['sensor_notes'] . " - \n"); - echo(""); - - $graph_type = "sensor_frequency"; - - $graph_array['id'] = $sensor['sensor_id']; - $graph_array['type'] = $graph_type; - - include("includes/print-quadgraphs.inc.php"); - - - echo(""); - - - $row++; - -} - -echo(""); +$class = "freq"; +$unit = "Hz"; +$graph_type = "sensor_frequency"; +include("sensors.inc.php"); ?> diff --git a/html/pages/device/health/humidity.inc.php b/html/pages/device/health/humidity.inc.php index 14856c2ff..93b4772a3 100644 --- a/html/pages/device/health/humidity.inc.php +++ b/html/pages/device/health/humidity.inc.php @@ -1,41 +1,9 @@ "); - -$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(" - " . $humidity['sensor_descr'] . " - " . $humidity['sensor_current'] . " % - " . $humidity['sensor_limit'] . " % - " . $humidity['sensor_notes'] . " - \n"); - echo(""); - - $graph_type = "sensor_humidity"; - - $graph_array['id'] = $humidity['sensor_id']; - $graph_array['type'] = $graph_type; - - include("includes/print-quadgraphs.inc.php"); - - - echo(""); - - - $row++; - -} - -echo(""); +$class = "humidity"; +$unit = "%"; +$graph_type = "sensor_humidity"; +include("sensors.inc.php"); ?> - diff --git a/html/pages/device/health/sensors.inc.php b/html/pages/device/health/sensors.inc.php new file mode 100644 index 000000000..0479cd610 --- /dev/null +++ b/html/pages/device/health/sensors.inc.php @@ -0,0 +1,38 @@ +"); + +$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(" + " . $temp['sensor_descr'] . " + " . $temp['sensor_type'] . " + " . print_temperature($temp['sensor_current'], $temp['sensor_limit']) .$unit. " + " . $temp['sensor_limit'] . $unit . " + " . $temp['sensor_limit_low'] . $unit ." + \n"); + echo(""); + + $graph_array['id'] = $temp['sensor_id']; + $graph_array['type'] = $graph_type; + + include("includes/print-quadgraphs.inc.php"); + + echo(""); + + + $row++; + +} + +echo(""); + + +?> diff --git a/html/pages/device/health/temperatures.inc.php b/html/pages/device/health/temperatures.inc.php index ed9452243..dd2c8878b 100644 --- a/html/pages/device/health/temperatures.inc.php +++ b/html/pages/device/health/temperatures.inc.php @@ -1,41 +1,9 @@ "); - -$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(" - " . $temp['sensor_descr'] . " - " . $temp['sensor_type'] . " - " . print_temperature($temp['sensor_current'], $temp['sensor_limit']) . "°C - " . $temp['sensor_limit'] . "°C - " . $temp['sensor_limit_low'] . "°C - " . $temp['sensor_notes'] . " - \n"); - echo(""); - - $graph_type = "sensor_temperature"; - - $graph_array['id'] = $temp['sensor_id']; - $graph_array['type'] = $graph_type; - - include("includes/print-quadgraphs.inc.php"); - - echo(""); - - - $row++; - -} - -echo(""); +$class = "temperature"; +$unit = "°C"; +$graph_type = "sensor_temperature"; +include("sensors.inc.php"); ?> diff --git a/html/pages/device/health/voltages.inc.php b/html/pages/device/health/voltages.inc.php index 7f0deed99..900db5c18 100644 --- a/html/pages/device/health/voltages.inc.php +++ b/html/pages/device/health/voltages.inc.php @@ -1,42 +1,9 @@ "); - -$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(" - " . $volt['sensor_descr'] . " - " . $volt['sensor_type'] . " - " . $volt['sensor_current'] . "V - " . $volt['sensor_limit_low'] . 'V - ' . $volt['sensor_limit'] . "V - " . $volt['sensor_notes'] . " - \n"); - echo(""); - - $graph_type = "sensor_voltage"; - - $graph_array['id'] = $volt['sensor_id']; - $graph_array['type'] = $graph_type; - - include("includes/print-quadgraphs.inc.php"); - - - echo(""); - - - $row++; - -} - -echo(""); +$class = "voltage"; +$unit = "V"; +$graph_type = "sensor_voltage"; +include("sensors.inc.php"); ?> -