From 4948cf523ca2c93a9e1756b94cd97d97eb969ae7 Mon Sep 17 00:00:00 2001 From: Alexey Lavrenuke Date: Tue, 24 Nov 2015 14:39:20 +0300 Subject: [PATCH] consider ssh timeout parameter --- yandextank/plugins/Monitoring/collector.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/yandextank/plugins/Monitoring/collector.py b/yandextank/plugins/Monitoring/collector.py index 32a30d5..c060e05 100644 --- a/yandextank/plugins/Monitoring/collector.py +++ b/yandextank/plugins/Monitoring/collector.py @@ -44,10 +44,11 @@ class Config(object): class SecuredShell(object): - def __init__(self, host, port, username): + def __init__(self, host, port, username, timeout): self.host = host self.port = port self.username = username + self.timeout = timeout def connect(self): logger.debug("Opening SSH connection to {host}:{port}".format( @@ -59,6 +60,7 @@ class SecuredShell(object): self.host, port=self.port, username=self.username, + timeout=self.timeout, ) return client @@ -124,7 +126,7 @@ class AsyncSession(object): class AgentClient(object): """Agent client connection""" - def __init__(self, adr): + def __init__(self, adr, timeout): self.run = [] self.host = adr['host'] self.username = adr['username'] @@ -138,7 +140,7 @@ class AgentClient(object): self.session = None self.buffer = "" self.ssh = SecuredShell( - self.host, self.port, self.username) + self.host, self.port, self.username, timeout) handle, cfg_path = tempfile.mkstemp('.cfg', 'agent_') os.close(handle) @@ -328,7 +330,7 @@ class MonitoringCollector(object): logger.debug('Creating agents') for adr in agent_config: logger.debug('Creating agent: %s', adr) - agent = AgentClient(adr) + agent = AgentClient(adr, timeout=self.ssh_timeout) logger.debug('Install monitoring agent. Host: %s', agent.host) agent_config = agent.install(loglevel) if agent_config: