diff --git a/app/Helpers/integrations_nmis_helper.php b/app/Helpers/integrations_nmis_helper.php index 09b2c609c..45b4507f1 100644 --- a/app/Helpers/integrations_nmis_helper.php +++ b/app/Helpers/integrations_nmis_helper.php @@ -754,7 +754,7 @@ function integrations_update($integration, $devices) unlink($ckfile); return array(); } else { - $message = '[integrations_update] Device ' . $device->configuration->host . ' updated in NMIS.'; + $message = '[integrations_update] Device ' . $device->name . ' at ' . $device->configuration->host . ' updated in NMIS.'; $count = count($external_devices); $sql = "INSERT INTO integrations_log VALUES (null, ?, null, ?, 'info', ?)"; $db->query($sql, [$integration->id, microtime(true), $message]); diff --git a/app/Models/IntegrationsModel.php b/app/Models/IntegrationsModel.php index 187559023..3008d5109 100644 --- a/app/Models/IntegrationsModel.php +++ b/app/Models/IntegrationsModel.php @@ -451,15 +451,16 @@ public function execute(int $id = 0) $sql = "SELECT omk_uuid FROM devices WHERE id = ?"; $result = $this->db->query($sql, [intval($device->devices->id)])->getResult(); foreach ($integration->attributes->fields as $field) { + $message = 'Not updating device ID: ' . $device->devices->id . ' for ' . $device->devices->name . ' in Open-AudIT because no changed fields.'; if (($field->priority === 'external' or (empty($result[0]->uuid) and $integration->attributes->type === 'nmis')) and strpos($field->internal_field_name, 'devices.') !== false) { // a regular field in Open-AudIT that we should update $system_field = str_replace('devices.', '', $field->internal_field_name); if (!empty($device->devices->{$system_field})) { # TODO - something better than not empty $temp_device->{$system_field} = $device->devices->{$system_field}; + $message = 'Updating device ID: ' . $device->devices->id . ' for ' . $device->devices->name . ' in Open-AudIT because ' . $system_field . ' is ' . $device->devices->{$system_field} . ' and priority is external.'; } } } - $message = 'Updating device ID: ' . $device->devices->id . ' for ' . $device->devices->name . ' in Open-AudIT.'; $sql = "INSERT INTO integrations_log VALUES (null, ?, null, ?, 'info', ?)"; $this->db->query($sql, [$integration->id, microtime(true), $message]); $devicesModel->update($temp_device->id, $temp_device); @@ -746,7 +747,7 @@ public function execute(int $id = 0) $hit = true; if ($integration->debug) { // TODO - ip not seeing in logs - $message = "Updating {$local_device->name} at {$local_device->configuration->host} because {$ifield->external_field_name} == $test"; + $message = "Updating {$local_device->name} at {$local_device->configuration->host} in NMIS because {$ifield->external_field_name} == $test and priority is internal."; $sql = "INSERT INTO integrations_log VALUES (null, ?, null, ?, 'debug', ?)"; $this->db->query($sql, [$integration->id, microtime(true), $message]); } @@ -770,12 +771,6 @@ public function execute(int $id = 0) $sql = "UPDATE integrations SET update_external_count = ? WHERE id = ?"; $this->db->query($sql, [count($update_external_devices), $integration->id]); - // if ($integration->debug and count($update_external_devices) > 0) { - // $message = json_encode($update_external_devices); - // $sql = "INSERT INTO integrations_log VALUES (null, ?, null, ?, 'debug', ?)"; - // $this->db->query($sql, [$integration->id, microtime(true), $message]); - // } - integrations_update($integration, $update_external_devices); } @@ -795,7 +790,7 @@ public function execute(int $id = 0) $test2 = $this->getValue($external_device, $field->external_field_name); if ($test1 == $test2) { if ($integration->debug) { - $message = 'Removing ' . $external_device->name . ' delete from list.'; + $message = 'Removing ' . $external_device->name . ' from delete list (not deleting this device in NMIS).'; $sql = "INSERT INTO integrations_log VALUES (null, ?, null, ?, 'info', ?)"; $this->db->query($sql, [$integration->id, microtime(true), $message]); } @@ -813,7 +808,7 @@ public function execute(int $id = 0) integrations_delete($integration, $delete_external_devices); } else { $message = '0 devices require deleting in ' . $integration->attributes->type . ' for ' . $integration->attributes->name . '.'; - $sql = "/* m_integrations::execute */ " . "INSERT INTO integrations_log VALUES (null, ?, null, ?, 'info', ?)"; + $sql = "INSERT INTO integrations_log VALUES (null, ?, null, ?, 'info', ?)"; $this->db->query($sql, [$integration->id, microtime(true), $message]); } }