diff --git a/html/pages/device/graphs.inc.php b/html/pages/device/graphs.inc.php index 2bd9089fa..3bcdc578d 100644 --- a/html/pages/device/graphs.inc.php +++ b/html/pages/device/graphs.inc.php @@ -16,6 +16,7 @@ $query = mysql_query("SELECT * FROM device_graphs WHERE device_id = '".$device[' while ($graph = mysql_fetch_assoc($query)) { + echo($graph['graph']."
"); $section = $config['graph_types']['device'][$graph['graph']]['section']; $graph_enable[$section][$graph['graph']] = $graph['graph']; } diff --git a/includes/polling/ucd-mib.inc.php b/includes/polling/ucd-mib.inc.php index 46f816321..ddbfacf7b 100755 --- a/includes/polling/ucd-mib.inc.php +++ b/includes/polling/ucd-mib.inc.php @@ -33,6 +33,7 @@ $mem_rrd = $host_rrd . "/ucd_mem.rrd"; #UCD-SNMP-MIB::ssRawSwapOut.0 = Counter32: 937422 $ss = snmpwalk_cache_oid($device, "systemStats", array()); +$ss = $ss[0]; ### Insert Nazi joke here. ## Create CPU RRD if it doesn't already exist $cpu_rrd_create = " --step 300 \ @@ -60,6 +61,7 @@ if (is_numeric($ss['ssCpuRawUser']) && is_numeric($ss['ssCpuRawNice']) && is_num rrdtool_create($cpu_rrd, $cpu_rrd_create); } rrdtool_update($cpu_rrd, "N:".$ss['ssCpuRawUser'].":".$ss['ssCpuRawSystem'].":".$ss['ssCpuRawNice'].":".$ss['ssCpuRawIdle']); + $graphs['ucd_cpu'] = TRUE; } ### This is how we'll collect in the future, start now so people don't have zero data. @@ -88,7 +90,6 @@ if (is_numeric($ss['ssIORawSent'])) { $graphs['ucd_io'] = TRUE; } if (is_numeric($ss['ssRawContexts'])) { $graphs['ucd_contexts'] = TRUE; } if (is_numeric($ss['ssRawInterrupts'])) { $graphs['ucd_interrupts'] = TRUE; } - ############################################################################################################################################ ### Poll mem for load memory utilisation stats on UNIX-like hosts running UCD/Net-SNMPd diff --git a/poller.php b/poller.php index c0e6f54b4..c30965994 100755 --- a/poller.php +++ b/poller.php @@ -178,6 +178,35 @@ function poll_device($device, $options) { } } +if (!$options['m']) +{ + + ## FIXME EVENTLOGGING -- MAKE IT SO WE DO THIS PER-MODULE? + ### This code cycles through the graphs already known in the database and the ones we've defined as being polled here + ### If there any don't match, they're added/deleted from the database. + ### Ideally we should hold graphs for xx days/weeks/polls so that we don't needlessly hide information. + + $query = mysql_query("SELECT `graph` FROM `device_graphs` WHERE `device_id` = '".$device['device_id']."'"); + while ($graph = mysql_fetch_assoc($query)) + { + if (!isset($graphs[$graph["graph"]])) + { + mysql_query("DELETE FROM `device_graphs` WHERE `device_id` = '".$device['device_id']."' AND `graph` = '".$graph["graph"]."'"); + } else { + $oldgraphs[$graph["graph"]] = TRUE; + } + } + + foreach ($graphs as $graph => $value) + { + if (!isset($oldgraphs[$graph])) + { + mysql_query("INSERT INTO `device_graphs` (`device_id`, `graph`) VALUES ('".$device['device_id']."','".$graph."')"); + } + } + +} + $device_end = utime(); $device_run = $device_end - $device_start; $device_time = substr($device_run, 0, 5); $device['db_update'] = " `last_polled` = NOW() " . $device['db_update']; $device['db_update'] .= ", `last_polled_timetaken` = '$device_time'";