mirror of
https://github.com/stylersnico/librenms.git
synced 2026-08-02 00:32:09 +02:00
Merge pull request #1319 from spinza/timeout
Add timeout on unix agent execution after connect.
This commit is contained in:
@@ -622,4 +622,9 @@ $config['ipmi']['type'][] = "open";
|
|||||||
// Options needed for dyn config - do NOT edit
|
// Options needed for dyn config - do NOT edit
|
||||||
$dyn_config['email_backend'] = array('mail','sendmail','smtp');
|
$dyn_config['email_backend'] = array('mail','sendmail','smtp');
|
||||||
$dyn_config['email_smtp_secure'] = array('', 'tls', 'ssl');
|
$dyn_config['email_smtp_secure'] = array('', 'tls', 'ssl');
|
||||||
|
|
||||||
|
// Unix-agent poller module config settings
|
||||||
|
$config['unix-agent-connection-time-out'] = 10; //seconds
|
||||||
|
$config['unix-agent-read-time-out'] = 10; //seconds
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -10,15 +10,25 @@ if ($device['os_group'] == "unix")
|
|||||||
$agent_port='6556';
|
$agent_port='6556';
|
||||||
|
|
||||||
$agent_start = utime();
|
$agent_start = utime();
|
||||||
$agent = fsockopen($device['hostname'], $agent_port, $errno, $errstr, 10);
|
$agent = fsockopen($device['hostname'], $agent_port, $errno, $errstr, $config['unix-agent-connection-time-out'] );
|
||||||
|
|
||||||
|
// Set stream timeout (for timeouts during agent fetch
|
||||||
|
stream_set_timeout($agent,$config['unix-agent-read-time-out']);
|
||||||
|
$agentinfo = stream_get_meta_data($agent);
|
||||||
|
|
||||||
if (!$agent)
|
if (!$agent)
|
||||||
{
|
{
|
||||||
echo "Connection to UNIX agent failed on port ".$port.".";
|
echo "Connection to UNIX agent failed on port ".$port.".";
|
||||||
} else {
|
} else {
|
||||||
while (!feof($agent))
|
// fetch data while not eof and not timed-out
|
||||||
|
while ((!feof($agent)) && (!$agentinfo['timed_out']))
|
||||||
{
|
{
|
||||||
$agent_raw .= fgets($agent, 128);
|
$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