Commit version 24.12.13800
This commit is contained in:
@ -4,49 +4,50 @@
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage discovery
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @package observium
|
||||
* @subpackage discovery
|
||||
* @copyright (C) Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
// FIXME. Migrate later to discover_pseudowire() & check_valid_pseudowire()
|
||||
if (!$config['enable_pseudowires']) { return; }
|
||||
if (!$config['enable_pseudowires']) {
|
||||
return;
|
||||
}
|
||||
|
||||
$valid['pseudowires'] = array();
|
||||
$valid['pseudowires'] = [];
|
||||
|
||||
// Pre-cache the existing state of pseudowires for this device from the database
|
||||
$pws_cache = array();
|
||||
$pws_db_raw = dbFetchRows("SELECT * FROM `pseudowires` WHERE `device_id` = ?", array($device['device_id']));
|
||||
foreach ($pws_db_raw as $pw_db)
|
||||
{
|
||||
$pws_cache['pws_db'][$pw_db['mib']][$pw_db['pwIndex']] = $pw_db;
|
||||
// Pre-cache the existing state of pseudowires for this device from the database
|
||||
$pws_cache = [];
|
||||
$pws_db_raw = dbFetchRows("SELECT * FROM `pseudowires` WHERE `device_id` = ?", [$device['device_id']]);
|
||||
foreach ($pws_db_raw as $pw_db) {
|
||||
$pws_cache['pws_db'][$pw_db['mib']][$pw_db['pwIndex']] = $pw_db;
|
||||
$pws_cache['pw_id_db'][$pw_db['mib']][$pw_db['pseudowire_id']] = $pw_db['pseudowire_id'];
|
||||
}
|
||||
unset($pws_db_raw); unset($pw_db);
|
||||
}
|
||||
unset($pws_db_raw);
|
||||
unset($pw_db);
|
||||
|
||||
$include_dir = "includes/discovery/pseudowires";
|
||||
include($config['install_dir']."/includes/include-dir-mib.inc.php");
|
||||
$include_dir = "includes/discovery/pseudowires";
|
||||
include($config['install_dir'] . "/includes/include-dir-mib.inc.php");
|
||||
|
||||
// Cycle the list of pseudowires we cached earlier and make sure we saw them again.
|
||||
//echo("PWS_DB: ".count($pws_cache['pws_db'])."\n"); var_dump($pws_cache['pws_db']);
|
||||
//echo("PWS: ".count($pws_cache['pws'])."\n"); var_dump($pws_cache['pws']);
|
||||
foreach ($pws_cache['pw_id_db'] as $mib => $pw)
|
||||
{
|
||||
foreach ($pw as $pw_id)
|
||||
{
|
||||
if (!isset($valid['pseudowires'][$mib][$pw_id]))
|
||||
{
|
||||
dbDelete('pseudowires', '`pseudowire_id` = ?', array($pw_id));
|
||||
$GLOBALS['module_stats'][$module]['deleted']++;
|
||||
}
|
||||
// Cycle the list of pseudowires we cached earlier and make sure we saw them again.
|
||||
//echo("PWS_DB: ".count($pws_cache['pws_db'])."\n"); var_dump($pws_cache['pws_db']);
|
||||
//echo("PWS: ".count($pws_cache['pws'])."\n"); var_dump($pws_cache['pws']);
|
||||
foreach ($pws_cache['pw_id_db'] as $mib => $pw) {
|
||||
foreach ($pw as $pw_id) {
|
||||
if (!isset($valid['pseudowires'][$mib][$pw_id])) {
|
||||
dbDelete('pseudowires', '`pseudowire_id` = ?', [$pw_id]);
|
||||
$GLOBALS['module_stats'][$module]['deleted']++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$GLOBALS['module_stats'][$module]['status'] = safe_count($valid[$module]);
|
||||
if (OBS_DEBUG && $GLOBALS['module_stats'][$module]['status']) { print_vars($valid[$module]); }
|
||||
$GLOBALS['module_stats'][$module]['status'] = safe_count($valid[$module]);
|
||||
if (OBS_DEBUG && $GLOBALS['module_stats'][$module]['status']) {
|
||||
print_vars($valid[$module]);
|
||||
}
|
||||
|
||||
// Clean
|
||||
unset($pw, $pws_cache, $mib);
|
||||
// Clean
|
||||
unset($pw, $pws_cache, $mib);
|
||||
|
||||
// EOF
|
||||
|
Reference in New Issue
Block a user