mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-27 08:02:51 +02:00
Add timeout on unix agent execution after connect.
This commit is contained in:
@@ -12,13 +12,23 @@ if ($device['os_group'] == "unix")
|
||||
$agent_start = utime();
|
||||
$agent = fsockopen($device['hostname'], $agent_port, $errno, $errstr, 10);
|
||||
|
||||
// Set stream timeout (for timeouts during agent fetch
|
||||
stream_set_timeout($agent,10);
|
||||
$agentinfo = stream_get_meta_data($agent);
|
||||
|
||||
if (!$agent)
|
||||
{
|
||||
echo "Connection to UNIX agent failed on port ".$port.".";
|
||||
} else {
|
||||
while (!feof($agent))
|
||||
// fetch data while not eof and not timed-out
|
||||
while ((!feof($agent)) && (!$agentinfo['timed_out']))
|
||||
{
|
||||
$agent_raw .= fgets($agent, 128);
|
||||
$agentinfo = stream_get_meta_data($agent);
|
||||
}
|
||||
if ($agentinfo['timed_out'])
|
||||
{
|
||||
echo "Connection to UNIX agent timed out during fetch on port ".$port.".";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user