Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1.2 KiB
PHP
Raw Permalink Normal View History

<?php
2010-06-28 12:52:30 +00:00
2021-02-02 06:40:11 +00:00
use App\Http\Controllers\ServiceTemplateController;
use LibreNMS\Config;
2021-02-02 06:40:11 +00:00
if (Config::get('discover_services_templates')) {
(new ServiceTemplateController())->applyDeviceAll($device['device_id']); // FIXME applyAll() should not be on a controller
2021-02-02 06:40:11 +00:00
}
if (Config::get('discover_services')) {
// FIXME: use /etc/services?
$known_services = [
22 => 'ssh',
25 => 'smtp',
53 => 'dns',
80 => 'http',
110 => 'pop',
143 => 'imap',
];
// Services
if ($device['type'] == 'server') {
$oids = trim(snmp_walk($device, '.1.3.6.1.2.1.6.13.1.1.0.0.0.0', '-Osqn'));
foreach (explode("\n", $oids) as $data) {
$data = trim($data);
if ($data) {
[$oid, $tcpstatus] = explode(' ', $data);
if (trim($tcpstatus) == 'listen') {
$split_oid = explode('.', $oid);
2023-03-13 22:32:22 +01:00
$tcp_port = $split_oid[count($split_oid) - 6];
if ($known_services[$tcp_port]) {
discover_service($device, $known_services[$tcp_port]);
}
}
}
}
}
echo "\n";
2010-06-28 12:52:30 +00:00
}