Index: html/pages/device/health/status.inc.php =================================================================== --- html/pages/device/health/status.inc.php (revision 0) +++ html/pages/device/health/status.inc.php (revision 0) @@ -0,0 +1,9 @@ +<?php + +$class = "status"; +$unit = ""; +$graph_type = "sensor_status"; + +include("sensors.inc.php"); + +?> Index: html/pages/device/overview/sensors/status.inc.php =================================================================== --- html/pages/device/overview/sensors/status.inc.php (revision 0) +++ html/pages/device/overview/sensors/status.inc.php (revision 0) @@ -0,0 +1,10 @@ +<?php + +$graph_type = "sensor_status"; +$sensor_class = "status"; +$sensor_unit = ""; +$sensor_type = "state"; + +include('pages/device/overview/generic/sensor.inc.php'); + +?> Index: html/pages/device/status.inc.php =================================================================== --- html/pages/device/status.inc.php (revision 0) +++ html/pages/device/status.inc.php (revision 0) @@ -0,0 +1,86 @@ +<?php + +$storage = dbFetchCell("select count(*) from storage WHERE device_id = ?", array($device['device_id'])); +$diskio = dbFetchCell("select count(*) from ucd_diskio WHERE device_id = ?", array($device['device_id'])); +$mempools = dbFetchCell("select count(*) from mempools WHERE device_id = ?", array($device['device_id'])); +$processor = dbFetchCell("select count(*) from processors WHERE device_id = ?", array($device['device_id'])); + +$temperatures = dbFetchCell("select count(*) from sensors WHERE sensor_class='temperature' AND device_id = ?", array($device['device_id'])); +$humidity = dbFetchCell("select count(*) from sensors WHERE sensor_class='humidity' AND device_id = ?", array($device['device_id'])); +$fans = dbFetchCell("select count(*) from sensors WHERE sensor_class='fanspeed' AND device_id = ?", array($device['device_id'])); +$volts = dbFetchCell("select count(*) from sensors WHERE sensor_class='voltage' AND device_id = ?", array($device['device_id'])); +$current = dbFetchCell("select count(*) from sensors WHERE sensor_class='current' AND device_id = ?", array($device['device_id'])); +$freqs = dbFetchCell("select count(*) from sensors WHERE sensor_class='frequency' AND device_id = ?", array($device['device_id'])); +$power = dbFetchCell("select count(*) from sensors WHERE sensor_class='power' AND device_id = ?", array($device['device_id'])); +$dBm = dbFetchCell("select count(*) from sensors WHERE sensor_class='dBm' AND device_id = ?", array($device['device_id'])); + +unset($datas); +$datas[] = 'overview'; +if ($processor) { $datas[] = 'processor'; } +if ($mempools) { $datas[] = 'mempool'; } +if ($storage) { $datas[] = 'storage'; } +if ($diskio) { $datas[] = 'diskio'; } +if ($temperatures) { $datas[] = 'temperature'; } +if ($humidity) { $datas[] = 'humidity'; } +if ($fans) { $datas[] = 'fanspeed'; } +if ($volts) { $datas[] = 'voltage'; } +if ($freqs) { $datas[] = 'frequency'; } +if ($current) { $datas[] = 'current'; } +if ($power) { $datas[] = 'power'; } +if ($dBm) { $datas[] = 'dbm'; } + +$type_text['overview'] = "Overview"; +$type_text['temperature'] = "Temperature"; +$type_text['humidity'] = "Humidity"; +$type_text['mempool'] = "Memory"; +$type_text['storage'] = "Disk Usage"; +$type_text['diskio'] = "Disk I/O"; +$type_text['processor'] = "Processor"; +$type_text['voltage'] = "Voltage"; +$type_text['fanspeed'] = "Fanspeed"; +$type_text['frequency'] = "Frequency"; +$type_text['current'] = "Current"; +$type_text['power'] = "Power"; +$type_text['dbm'] = "dBm"; + +$link_array = array('page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'status'); + +if (!$vars['metric']) { $vars['metric'] = "overview"; } + +$navbar['brand'] = "Health"; +$navbar['class'] = "navbar-narrow"; + +foreach ($datas as $type) +{ + if ($vars['metric'] == $type) { $navbar['options'][$type]['class'] = "active"; } + $navbar['options'][$type]['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'status', 'metric' => $type)); + $navbar['options'][$type]['text'] = $type_text[$type]; +} +print_navbar($navbar); + +if (is_file("pages/device/status/".mres($vars['metric']).".inc.php")) +{ + include("pages/device/status/".mres($vars['metric']).".inc.php"); +} else { + + echo('<table class="table table-condensed table-striped table-hover">'); + + foreach ($datas as $type) + { + if ($type != "overview") + { + + $graph_title = $type_text[$type]; + $graph_array['type'] = "device_".$type; + + include("includes/print-device-graph.php"); + } + } + echo('</table>'); +} + +$pagetitle[] = "Health"; + +?> Index: html/pages/device/health.inc.php =================================================================== --- html/pages/device/health.inc.php (revision 4037) +++ html/pages/device/health.inc.php (working copy) @@ -13,6 +13,7 @@ $freqs = dbFetchCell("select count(*) from sensors WHERE sensor_class='frequency' AND device_id = ?", array($device['device_id'])); $power = dbFetchCell("select count(*) from sensors WHERE sensor_class='power' AND device_id = ?", array($device['device_id'])); $dBm = dbFetchCell("select count(*) from sensors WHERE sensor_class='dBm' AND device_id = ?", array($device['device_id'])); +$status = dbFetchCell("select count(*) from sensors WHERE sensor_class='status' AND device_id = ?", array($device['device_id'])); unset($datas); $datas[] = 'overview'; @@ -28,6 +29,7 @@ if ($current) { $datas[] = 'current'; } if ($power) { $datas[] = 'power'; } if ($dBm) { $datas[] = 'dbm'; } +if ($status) { $datas[] = 'status'; } $type_text['overview'] = "Overview"; $type_text['temperature'] = "Temperature"; @@ -42,6 +44,7 @@ $type_text['current'] = "Current"; $type_text['power'] = "Power"; $type_text['dbm'] = "dBm"; +$type_text['status'] = "Status"; $link_array = array('page' => 'device', 'device' => $device['device_id'], Index: html/pages/device/overview.inc.php =================================================================== --- html/pages/device/overview.inc.php (revision 4037) +++ html/pages/device/overview.inc.php (working copy) @@ -106,6 +106,7 @@ include("overview/sensors/current.inc.php"); include("overview/sensors/power.inc.php"); include("overview/sensors/frequencies.inc.php"); +include("overview/sensors/status.inc.php"); // Start events ?> Index: html/pages/health/status.inc.php =================================================================== --- html/pages/health/status.inc.php (revision 0) +++ html/pages/health/status.inc.php (revision 0) @@ -0,0 +1,10 @@ +<?php + +$graph_type = "sensor_status"; +$class = 'status'; +$unit = ""; + + +include("pages/health/sensors.inc.php"); + +?> Index: html/pages/health.inc.php =================================================================== --- html/pages/health.inc.php (revision 4037) +++ html/pages/health.inc.php (working copy) @@ -9,6 +9,7 @@ if ($used_sensors['current']) $datas[] = 'current'; if ($used_sensors['power']) $datas[] = 'power'; if ($used_sensors['dBm']) $datas[] = 'dBm'; +if ($used_sensors['status']) $datas[] = 'status'; // FIXME generalize -> static-config ? $type_text['overview'] = "Overview"; @@ -25,6 +26,7 @@ $type_text['power'] = "Power"; $type_text['toner'] = "Toner"; $type_text['dBm'] = "dBm"; +$type_text['status'] = "Status"; if (!$vars['metric']) { $vars['metric'] = "processor"; } if (!$vars['view']) { $vars['view'] = "detail"; } Index: html/includes/graphs/sensor/status.inc.php =================================================================== --- html/includes/graphs/sensor/status.inc.php (revision 0) +++ html/includes/graphs/sensor/status.inc.php (revision 0) @@ -0,0 +1,17 @@ +<?php + +$scale_min = "0"; + +include("includes/graphs/common.inc.php"); + +$rrd_options .= " COMMENT:' Last Max\\n'"; + +$rrd_options .= " DEF:sensor=$rrd_filename:sensor:AVERAGE"; +$rrd_options .= " LINE1.5:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],20)."'"; +$rrd_options .= " GPRINT:sensor:LAST:%3.0lf"; +$rrd_options .= " GPRINT:sensor:MAX:%3.0lf\\\\l"; + +if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes"; +if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes"; + +?> Index: includes/polling/unix-agent/hdarray.inc.php =================================================================== --- includes/polling/unix-agent/hdarray.inc.php (revision 0) +++ includes/polling/unix-agent/hdarray.inc.php (revision 0) @@ -0,0 +1,35 @@ +<?php + +global $agent_sensors; + +if ($agent_data['array'] != '|') +{ + $items = explode("\n",$agent_data['hdarray']); + echo "hdarray: " . print_r($items); + + if (count($items)) + { + foreach ($items as $item) + { + list($param,$status) = explode('=',$item,2); + $itemcount++; + if($status==='Ok') { + $istatus=1; + } else { + $istatus=0; + } + echo "Status: $status istatus: $istatus"; + if ($param==='Controller Status') { + discover_sensor($valid['sensor'], 'status', $device, '', $itemcount, 'state', "$param: $status", '1', '1', 1, NULL, 1, NULL, $istatus, 'agent'); + $agent_sensors['status']['state'][$itemcount] = array('description' => "$param: $status", 'current' => $istatus, 'index' => $itemcount); + } + if (preg_match("/^Drive/","$param")) { + discover_sensor($valid['sensor'], 'status', $device, '', $itemcount, 'state', "$param: $status", '1', '1', 1, NULL, 1, NULL, $istatus, 'agent'); + $agent_sensors['status']['state'][$itemcount] = array('description' => "$param: $status", 'current' => $istatus, 'index' => $itemcount); + } + } + echo "\n"; + } +} + +?>