<?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'])) + count_mib_mempools($device); $processor = dbFetchCell('select count(*) from processors WHERE device_id = ?', array($device['device_id'])) + count_mib_processors($device); $charge = dbFetchCell("select count(*) from sensors WHERE sensor_class='charge' AND 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'])); $states = dbFetchCell("select count(*) from sensors WHERE sensor_class='state' AND device_id = ?", array($device['device_id'])); $load = dbFetchCell("select count(*) from sensors WHERE sensor_class='load' AND device_id = ?", array($device['device_id'])); $signal = dbFetchCell("select count(*) from sensors WHERE sensor_class='signal' 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';
function count_mib_health($device) { return count_mib_mempools($device) + count_mib_processors($device); }
<?php $graph_type = 'processor_usage'; $i = '1'; if (count_mib_processors($device) > 0) { $processors = get_mib_processors($device); $graph_type = 'device_processor'; } else { $processors = dbFetchRows('SELECT * FROM `processors` WHERE device_id = ?', array($device['device_id'])); } foreach ($processors as $proc) { if ($graph_type == 'device_processor') { $id = 'device'; $val = $device['device_id']; } else { $id = 'id'; $val = $proc['processor_id']; } $proc_url = 'graphs/' . $id . '=' . $val . '/type=' . $graph_type . '/'; $base_url = 'graph.php?' . $id . '=' . $val . '&type=' . $graph_type . '&from=' . $config['time']['day'] . '&to=' . $config['time']['now']; $mini_url = $base_url . '&width=80&height=20&bg=f4f4f4'; $text_descr = rewrite_entity_descr($proc['processor_descr']); $proc_popup = "onmouseover=\"return overlib('<div class=list-large>" . $device['hostname'] . ' - ' . $text_descr; $proc_popup .= "</div><img src=\\'" . $base_url . "&width=400&height=125\\'>"; $proc_popup .= "', RIGHT" . $config['overlib_defaults'] . ');" onmouseout="return nd();"'; $percent = round($proc['processor_usage']); $graph_array[$id] = $val; $graph_array['type'] = $graph_type; echo "<div class='panel panel-default'>\n <div class='panel-heading'>\n <h3 class='panel-title'>{$text_descr} <div class='pull-right'>{$percent}% used</div></h3>\n </div>"; echo "<div class='panel-body'>"; include 'includes/print-graphrow.inc.php';