mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Always add 'extended' metrics to db and remove option
This commit is contained in:
@ -77,7 +77,6 @@ $config['memcached']['host'] = 'localhost';
|
||||
$config['memcached']['port'] = 11211;
|
||||
$config['memcached']['ttl'] = 240;
|
||||
|
||||
$config['extended_port_metrics'] = false;
|
||||
$config['slow_statistics'] = true;
|
||||
// THIS WILL CHANGE TO FALSE IN FUTURE
|
||||
// RRD Format Settings
|
||||
|
@ -216,13 +216,8 @@ d_echo($port_stats);
|
||||
// FIXME -- this stuff is a little messy, looping the array to make an array just seems wrong. :>
|
||||
// -- i can make it a function, so that you don't know what it's doing.
|
||||
// -- $ports = adamasMagicFunction($ports_db); ?
|
||||
if ($config['extended_port_metrics']) {
|
||||
// select * doesn't do what we want if multiple tables have the same column name -- last one wins :/
|
||||
$ports_db = dbFetchRows('SELECT *, `ports_statistics`.`port_id` AS `ports_statistics_port_id`, `ports`.`port_id` AS `port_id` FROM `ports` LEFT OUTER JOIN `ports_statistics` ON `ports`.`port_id` = `ports_statistics`.`port_id` WHERE `ports`.`device_id` = ?', array($device['device_id']));
|
||||
}
|
||||
else {
|
||||
$ports_db = dbFetchRows('SELECT * FROM `ports` WHERE `device_id` = ?', array($device['device_id']));
|
||||
}
|
||||
// select * doesn't do what we want if multiple tables have the same column name -- last one wins :/
|
||||
$ports_db = dbFetchRows('SELECT *, `ports_statistics`.`port_id` AS `ports_statistics_port_id`, `ports`.`port_id` AS `port_id` FROM `ports` LEFT OUTER JOIN `ports_statistics` ON `ports`.`port_id` = `ports_statistics`.`port_id` WHERE `ports`.`device_id` = ?', array($device['device_id']));
|
||||
|
||||
foreach ($ports_db as $port) {
|
||||
$ports[$port['ifIndex']] = $port;
|
||||
@ -234,9 +229,7 @@ foreach ($port_stats as $ifIndex => $port) {
|
||||
echo 'valid';
|
||||
if (!is_array($ports[$port['ifIndex']])) {
|
||||
$port_id = dbInsert(array('device_id' => $device['device_id'], 'ifIndex' => $ifIndex), 'ports');
|
||||
if ($config['extended_port_metrics']) {
|
||||
dbInsert(array('port_id' => $port_id), 'ports_statistics');
|
||||
}
|
||||
dbInsert(array('port_id' => $port_id), 'ports_statistics');
|
||||
$ports[$port['ifIndex']] = dbFetchRow('SELECT * FROM `ports` WHERE `port_id` = ?', array($port_id));
|
||||
echo 'Adding: '.$port['ifName'].'('.$ifIndex.')('.$ports[$port['ifIndex']]['port_id'].')';
|
||||
// print_r($ports);
|
||||
@ -245,9 +238,8 @@ foreach ($port_stats as $ifIndex => $port) {
|
||||
dbUpdate(array('deleted' => '0'), 'ports', '`port_id` = ?', array($ports[$ifIndex]['port_id']));
|
||||
$ports[$ifIndex]['deleted'] = '0';
|
||||
}
|
||||
if ($config['extended_port_metrics'] &&
|
||||
$ports[$ifIndex]['ports_statistics_port_id'] === null) {
|
||||
// in case someone enabled the option after the port was already created
|
||||
if ($ports[$ifIndex]['ports_statistics_port_id'] === null) {
|
||||
// in case the port was created before we created the table
|
||||
dbInsert(array('port_id' => $ports[$ifIndex]['port_id']), 'ports_statistics');
|
||||
}
|
||||
}
|
||||
@ -430,17 +422,12 @@ foreach ($ports as $port) {
|
||||
|
||||
// End parse ifAlias
|
||||
// Update IF-MIB metrics
|
||||
$_stat_oids = $stat_oids_db;
|
||||
if ($config['extended_port_metrics']) {
|
||||
$_stat_oids = $_stat_oids + $stat_oids_db_extended;
|
||||
}
|
||||
$_stat_oids = $stat_oids_db + $stat_oids_db_extended;
|
||||
foreach ($_stat_oids as $oid) {
|
||||
$port_update = 'update';
|
||||
if ($config['extended_port_metrics']) {
|
||||
$extended_metric = !in_array($oid, $stat_oids_db, true);
|
||||
if ($extended_metric) {
|
||||
$port_update = 'update_extended';
|
||||
}
|
||||
$extended_metric = !in_array($oid, $stat_oids_db, true);
|
||||
if ($extended_metric) {
|
||||
$port_update = 'update_extended';
|
||||
}
|
||||
|
||||
if ($config['slow_statistics'] == true) {
|
||||
@ -587,10 +574,8 @@ foreach ($ports as $port) {
|
||||
// Update Database
|
||||
if (count($port['update'])) {
|
||||
$updated = dbUpdate($port['update'], 'ports', '`port_id` = ?', array($port['port_id']));
|
||||
if ($config['extended_port_metrics'] and count($port['update_extended'])) {
|
||||
// do we want to do something else with this?
|
||||
$updated += dbUpdate($port['update_extended'], 'ports_statistics', '`port_id` = ?', array($port['port_id']));
|
||||
}
|
||||
// do we want to do something else with this?
|
||||
$updated += dbUpdate($port['update_extended'], 'ports_statistics', '`port_id` = ?', array($port['port_id']));
|
||||
d_echo("$updated updated");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user