mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Handle connection timed out errors in unix agent (#14286)
* handle connection timed out errors in unix agent * Update unix-agent.inc.php
This commit is contained in:
@@ -12,8 +12,15 @@ if ($device['os_group'] == 'unix' || $device['os'] == 'windows') {
|
||||
}
|
||||
|
||||
$agent_start = microtime(true);
|
||||
$poller_target = \LibreNMS\Util\Rewrite::addIpv6Brackets(Device::pollerTarget($device['hostname']));
|
||||
$agent = fsockopen($poller_target, $agent_port, $errno, $errstr, \LibreNMS\Config::get('unix-agent.connection-timeout'));
|
||||
$agent = null;
|
||||
try {
|
||||
$poller_target = \LibreNMS\Util\Rewrite::addIpv6Brackets(Device::pollerTarget($device['hostname']));
|
||||
$agent = @fsockopen($poller_target, $agent_port, $errno, $errstr, \LibreNMS\Config::get('unix-agent.connection-timeout'));
|
||||
} catch (ErrorException $e) {
|
||||
echo $e->getMessage() . PHP_EOL; // usually connection timed out
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (! $agent) {
|
||||
echo 'Connection to UNIX agent failed on port ' . $agent_port . '.';
|
||||
|
||||
Reference in New Issue
Block a user