Skip to content

Commit

Permalink
Merge pull request #503 from nettorta/develop
Browse files Browse the repository at this point in the history
client patches, logging -> logger, sftp test for paramiko ssh connection tester
  • Loading branch information
fomars committed Feb 1, 2018
2 parents 054cfc4 + 78dbfc6 commit 3e8189d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
16 changes: 15 additions & 1 deletion yandextank/common/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def send_file(self, local_path, remote_path):
logger.info(
"Sending [{local}] to {host}:[{remote}]".format(
local=local_path, host=self.host, remote=remote_path))

with self.connect() as client, client.open_sftp() as sftp:
result = sftp.put(local_path, remote_path)
return result
Expand Down Expand Up @@ -148,7 +149,20 @@ def check_ssh_connection():
logging.info(
"Checking SSH to %s@%s:%d", args.username, args.endpoint, args.port)
ssh = SecuredShell(args.endpoint, args.port, args.username, 10)
print(ssh.execute("ls -l"))
data = ssh.execute("ls -l")
logging.info('Output data of ssh.execute("ls -l"): %s', data[0])
logging.info('Output errors of ssh.execute("ls -l"): %s', data[1])
logging.info('Output code of ssh.execute("ls -l"): %s', data[2])

logging.info('Trying to create paramiko ssh connection client')
client = ssh.connect()
logging.info('Created paramiko ssh connection client: %s', client)
logging.info('Trying to open sftp')
sftp = client.open_sftp()
logging.info('Opened sftp: %s', sftp)
logging.info('Trying to send test file to /tmp')
res = sftp.put('/usr/lib/yandex/yandex-tank/bin/tank.log', '/opt')
logging.info('Result of sending test file: %s', res)


class AsyncSession(object):
Expand Down
15 changes: 6 additions & 9 deletions yandextank/plugins/Telegraf/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,9 @@ def install(self):
self.workdir,
self.AGENT_FILENAME))
copyfile(agent_config, os.path.join(self.workdir, 'agent.cfg'))
copyfile(
startup_config,
os.path.join(
self.workdir,
'agent_startup.cfg'))
copyfile(startup_config, os.path.join(
self.workdir,
'agent_startup.cfg'))
copyfile(
customs_script,
os.path.join(
Expand All @@ -87,10 +85,8 @@ def install(self):
self.path['TELEGRAF_LOCAL_PATH'])
return None, None, None
except Exception:
logger.error(
"Failed to copy agent to %s on localhost",
self.workdir,
exc_info=True)
logger.error("Failed to copy agent to %s on localhost", self.workdir)
logger.debug("Failed to copy agent to %s on localhost", self.workdir, exc_info=True)
return None, None, None
return agent_config, startup_config, customs_script

Expand Down Expand Up @@ -219,6 +215,7 @@ def install(self):
return None, None, None
if errors:
logger.error("[%s] error: '%s'", self.host, errors)
logger.error("Cancelling agent installation on %s", self.host)
return None, None, None

if err_code:
Expand Down
2 changes: 1 addition & 1 deletion yandextank/plugins/Telegraf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def get_host_config(self, host, target_hint):
elif (str(metric.tag)).lower() == 'telegrafraw':
telegrafraw.append(metric.text)
if len(host_config) == 0:
logging.info('Empty host config, using defaults')
logger.info('Empty host config, using defaults')
for section in defaults_enabled:
host_config[section] = defaults[section]
result = {
Expand Down
2 changes: 1 addition & 1 deletion yandextank/plugins/Telegraf/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def _save_config_contents(self, contents):
def configure(self):
self.detected_conf = self.__detect_configuration()
if self.detected_conf:
logging.info(
logger.info(
'Detected monitoring configuration: %s', self.detected_conf)
self.SECTION = self.detected_conf
self.default_target = self.get_option("default_target", "localhost")
Expand Down

0 comments on commit 3e8189d

Please sign in to comment.