2010-06-28 12:47:27 +00:00
|
|
|
<?php
|
2010-06-28 12:52:30 +00:00
|
|
|
|
2021-02-02 06:40:11 +00:00
|
|
|
use App\Http\Controllers\ServiceTemplateController;
|
2017-09-11 15:26:41 -05:00
|
|
|
use LibreNMS\Config;
|
|
|
|
|
|
2021-02-02 06:40:11 +00:00
|
|
|
if (Config::get('discover_services_templates')) {
|
2023-08-05 08:05:07 +08:00
|
|
|
(new ServiceTemplateController())->applyDeviceAll($device['device_id']); // FIXME applyAll() should not be on a controller
|
2021-02-02 06:40:11 +00:00
|
|
|
}
|
2017-09-11 15:26:41 -05:00
|
|
|
if (Config::get('discover_services')) {
|
2015-07-10 13:36:21 +02:00
|
|
|
// FIXME: use /etc/services?
|
|
|
|
|
$known_services = [
|
2024-01-05 05:39:12 +01:00
|
|
|
22 => 'ssh',
|
|
|
|
|
25 => 'smtp',
|
|
|
|
|
53 => 'dns',
|
|
|
|
|
80 => 'http',
|
2015-07-10 13:36:21 +02:00
|
|
|
110 => 'pop',
|
|
|
|
|
143 => 'imap',
|
|
|
|
|
];
|
2010-06-28 12:47:27 +00:00
|
|
|
|
2015-07-10 13:36:21 +02:00
|
|
|
// 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];
|
2015-07-10 13:36:21 +02:00
|
|
|
if ($known_services[$tcp_port]) {
|
|
|
|
|
discover_service($device, $known_services[$tcp_port]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-03-09 12:13:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-06-28 12:47:27 +00:00
|
|
|
|
2015-07-10 13:36:21 +02:00
|
|
|
echo "\n";
|
2010-06-28 12:52:30 +00:00
|
|
|
}
|