From 5a9422d2babd3e2accd6ae09bb82f38387ee8378 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Wed, 23 May 2012 15:27:25 +0000 Subject: [PATCH] fix health/sensors git-svn-id: http://www.observium.org/svn/observer/trunk@3231 61d68cd4-352d-0410-923a-c4978735b2b8 --- .../device/overview/generic/sensor.inc.php | 1 + html/pages/health/sensors.inc.php | 61 +++++++++++++------ 2 files changed, 43 insertions(+), 19 deletions(-) diff --git a/html/pages/device/overview/generic/sensor.inc.php b/html/pages/device/overview/generic/sensor.inc.php index 48b10c45e5..01456d55ba 100644 --- a/html/pages/device/overview/generic/sensor.inc.php +++ b/html/pages/device/overview/generic/sensor.inc.php @@ -21,6 +21,7 @@ if (count($sensors)) ### FIXME - make this "four graphs in popup" a function/include and "small graph" a function. ### FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"? + ### FIXME - DUPLICATED IN health/sensors $graph_colour = str_replace("#", "", $row_colour); diff --git a/html/pages/health/sensors.inc.php b/html/pages/health/sensors.inc.php index e682df5424..9f6a476a07 100644 --- a/html/pages/health/sensors.inc.php +++ b/html/pages/health/sensors.inc.php @@ -29,6 +29,7 @@ foreach (dbFetchRows($sql, $param) as $sensor) if ($config['memcached']['enable']) { $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); + if($debug) { echo("Memcached[".'sensor-'.$sensor['sensor_id'].'-value'."=".$sensor['sensor_current']."]"); } } if (empty($sensor['sensor_current'])) @@ -38,28 +39,50 @@ foreach (dbFetchRows($sql, $param) as $sensor) if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = 'alert'; } else { $alert = ""; } } - $weekly_sensor = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['week']."&to=".$config['time']['now']."&width=500&height=150"; - $sensor_popup = "', LEFT);\" onmouseout=\"return nd();\"> - " . $sensor['sensor_descr'] . ""; + ### FIXME - make this "four graphs in popup" a function/include and "small graph" a function. + ### FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"? + ### FIXME - DUPLICATED IN device/overview/sensors - $sensor_day = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=300&height=100"; - $sensor_week = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['week']."&to=".$config['time']['now']."&width=300&height=100"; - $sensor_month = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['time']['month']."&to=".$config['time']['now']."&width=300&height=100"; - $sensor_year = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=".$config['year']."&to=".$config['time']['now']."&width=300&height=100"; + $graph_colour = str_replace("#", "", $row_colour); - $sensor_minigraph = "".$sensor['hostname']." - ".mres($sensor['sensor_descr']); - $sensor_minigraph .= "
', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\" >"; + $graph_array = array(); + $graph_array['height'] = "100"; + $graph_array['width'] = "210"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $sensor['sensor_id']; + $graph_array['type'] = $graph_type; + $graph_array['from'] = $config['time']['day']; + $graph_array['legend'] = "no"; - echo(" - " . generate_device_link($sensor) . " - $sensor_popup - $sensor_minigraph - $alert - " . $sensor['sensor_current'] . $unit . " - " . round($sensor['sensor_limit_low'],2) . $unit . " - " . round($sensor['sensor_limit'],2) . $unit . " - " . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . " - \n"); + $link_array = $graph_array; + $link_array['page'] = "graphs"; + unset($link_array['height'], $link_array['width'], $link_array['legend']); + $link = generate_url($link_array); + + $overlib_content = '

'.$device['hostname']." - ".$sensor['sensor_descr']."

"; + foreach (array('day','week','month','year') as $period) + { + $graph_array['from'] = $config['time'][$period]; + $overlib_content .= str_replace('"', "\'", generate_graph_tag($graph_array)); + } + $overlib_content .= "
"; + + $graph_array['width'] = 80; $graph_array['height'] = 20; $graph_array['bg'] = 'ffffff00'; # the 00 at the end makes the area transparent. + $graph_array['from'] = $config['time']['day']; + $sensor_minigraph = generate_graph_tag($graph_array); + + $sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, ''); + + echo(' + ' . generate_device_link($sensor) . ' + '.overlib_link($link, $sensor['sensor_descr'],$overlib_content).' + '.overlib_link($link, $sensor_minigraph, $overlib_content).' + '.$alert.' + ' . $sensor['sensor_current'] . $unit . ' + ' . round($sensor['sensor_limit_low'],2) . $unit . ' - ' . round($sensor['sensor_limit'],2) . $unit . ' + ' . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . ' + + '); if ($vars['view'] == "graphs") {