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
This commit is contained in:
Kevin Zink
2021-03-20 17:19:09 +01:00
committed by GitHub
parent c09158dad0
commit 6cb7fb4da7
+4 -4
View File
@@ -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);