mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
fix adding/removal of graphs (DUH). fix UCD-MIB. (also switch to /new/ format graphs soon? :))
git-svn-id: http://www.observium.org/svn/observer/trunk@2267 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -16,6 +16,7 @@ $query = mysql_query("SELECT * FROM device_graphs WHERE device_id = '".$device['
|
|||||||
|
|
||||||
while ($graph = mysql_fetch_assoc($query))
|
while ($graph = mysql_fetch_assoc($query))
|
||||||
{
|
{
|
||||||
|
echo($graph['graph']."</br>");
|
||||||
$section = $config['graph_types']['device'][$graph['graph']]['section'];
|
$section = $config['graph_types']['device'][$graph['graph']]['section'];
|
||||||
$graph_enable[$section][$graph['graph']] = $graph['graph'];
|
$graph_enable[$section][$graph['graph']] = $graph['graph'];
|
||||||
}
|
}
|
||||||
|
@@ -33,6 +33,7 @@ $mem_rrd = $host_rrd . "/ucd_mem.rrd";
|
|||||||
#UCD-SNMP-MIB::ssRawSwapOut.0 = Counter32: 937422
|
#UCD-SNMP-MIB::ssRawSwapOut.0 = Counter32: 937422
|
||||||
|
|
||||||
$ss = snmpwalk_cache_oid($device, "systemStats", array());
|
$ss = snmpwalk_cache_oid($device, "systemStats", array());
|
||||||
|
$ss = $ss[0]; ### Insert Nazi joke here.
|
||||||
|
|
||||||
## Create CPU RRD if it doesn't already exist
|
## Create CPU RRD if it doesn't already exist
|
||||||
$cpu_rrd_create = " --step 300 \
|
$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_create($cpu_rrd, $cpu_rrd_create);
|
||||||
}
|
}
|
||||||
rrdtool_update($cpu_rrd, "N:".$ss['ssCpuRawUser'].":".$ss['ssCpuRawSystem'].":".$ss['ssCpuRawNice'].":".$ss['ssCpuRawIdle']);
|
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.
|
### 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['ssRawContexts'])) { $graphs['ucd_contexts'] = TRUE; }
|
||||||
if (is_numeric($ss['ssRawInterrupts'])) { $graphs['ucd_interrupts'] = 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
|
### Poll mem for load memory utilisation stats on UNIX-like hosts running UCD/Net-SNMPd
|
||||||
|
29
poller.php
29
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_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` = NOW() " . $device['db_update'];
|
||||||
$device['db_update'] .= ", `last_polled_timetaken` = '$device_time'";
|
$device['db_update'] .= ", `last_polled_timetaken` = '$device_time'";
|
||||||
|
Reference in New Issue
Block a user