From 6cb7fb4da7fb8e9dd971997167821bd86a7a7baa Mon Sep 17 00:00:00 2001 From: Kevin Zink Date: Sat, 20 Mar 2021 17:19:09 +0100 Subject: [PATCH] Bugfix for no sockets on Unix Agents (#12637) * Bugfix for no sockets on Unix Agents Fix Bug: Argument #1 ($stream) must be of type resource, bool given... * Update unix-agent.inc.php Fix Style --- includes/polling/unix-agent.inc.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/polling/unix-agent.inc.php b/includes/polling/unix-agent.inc.php index b99617b906..02bcd3098f 100644 --- a/includes/polling/unix-agent.inc.php +++ b/includes/polling/unix-agent.inc.php @@ -15,13 +15,13 @@ if ($device['os_group'] == 'unix' || $device['os'] == 'windows') { $poller_target = Device::pollerTarget($device['hostname']); $agent = fsockopen($poller_target, $agent_port, $errno, $errstr, \LibreNMS\Config::get('unix-agent.connection-timeout')); - // Set stream timeout (for timeouts during agent fetch - stream_set_timeout($agent, \LibreNMS\Config::get('unix-agent.read-timeout')); - $agentinfo = stream_get_meta_data($agent); - if (! $agent) { echo 'Connection to UNIX agent failed on port ' . $agent_port . '.'; } else { + // Set stream timeout (for timeouts during agent fetch + stream_set_timeout($agent, \LibreNMS\Config::get('unix-agent.read-timeout')); + $agentinfo = stream_get_meta_data($agent); + // fetch data while not eof and not timed-out while ((! feof($agent)) && (! $agentinfo['timed_out'])) { $agent_raw .= fgets($agent, 128);