fix: inconsistent device discovery (#6518)

There were two or more separate $device arrays during discovery. When one was updated, others were not.
Combine those all.
Make sure the new os is loaded if the os changed.
This commit is contained in:
Tony Murray
2017-04-28 16:50:00 -05:00
committed by Neil Lathwood
parent 0211c5864b
commit 374a4041af
3 changed files with 8 additions and 2 deletions

View File

@@ -121,6 +121,7 @@ if (!empty($config['distributed_poller_group'])) {
$where .= ' AND poller_group IN('.$config['distributed_poller_group'].')';
}
global $device;
foreach (dbFetch("SELECT * FROM `devices` WHERE status = 1 AND disabled = 0 $where ORDER BY device_id DESC", $sqlparams) as $device) {
discover_device($device, $options);
}

View File

@@ -88,7 +88,7 @@ function discover_new_device($hostname, $device = '', $method = '', $interface =
//end discover_new_device()
function discover_device($device, $options = null)
function discover_device(&$device, $options = null)
{
global $config, $valid;

View File

@@ -1,10 +1,15 @@
<?php
$os = getHostOS($device);
$os = getHostOS($device);
if ($os != $device['os']) {
log_event('Device OS changed ' . $device['os'] . " => $os", $device, 'system', 3);
$device['os'] = $os;
$sql = dbUpdate(array('os' => $os), 'devices', 'device_id=?', array($device['device_id']));
if (!isset($config['os'][$device['os']])) {
load_os($device);
}
echo "Changed OS! : $os\n";
}