Skip to content

Commit

Permalink
Add OS as a software entry for network devices where we have an os na…
Browse files Browse the repository at this point in the history
…me and version.
  • Loading branch information
mark-unwin committed Aug 7, 2024
1 parent dcd20c7 commit 7d81967
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/Helpers/discoveries_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,21 @@ function ip_audit($ip_scan = null)
}
}

if ($device->type !== 'computer' and !empty($device->os_version) and !empty($device->os_name)) {
$sql = "SELECT COUNT(*) AS `count` FROM software WHERE device_id = ?";
$result = $db->query($sql, [$device->id])->getResult();
if (intval($result[0]->count) < 2) {
// We have one or no entries in software - insert this
$software = new stdCLass();
$software->name = $device->os_name;
$software->version = $device->os_version;
$log->command_status = 'notice';
$log->message = 'Processing Software OS for ' . $device->ip;
$discoveryLogModel->create($log);
$componentsModel->upsert('software', $device, [$software]);
}
}

// Now run our rules to update the device if any match
$instance->rulesModel->execute(null, intval($discovery->id), 'update', intval($device->id));

Expand Down

0 comments on commit 7d81967

Please sign in to comment.