diff options
Diffstat (limited to 'yardstick/benchmark/scenarios/availability/monitor/monitor_process.py')
-rw-r--r-- | yardstick/benchmark/scenarios/availability/monitor/monitor_process.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py b/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py index 53a6d8e4d..5f492ad69 100644 --- a/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py +++ b/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py @@ -23,9 +23,11 @@ class MonitorProcess(basemonitor.BaseMonitor): host = self._context[self._config["host"]] ip = host.get("ip", None) user = host.get("user", "root") + ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT) key_filename = host.get("key_filename", "~/.ssh/id_rsa") - self.connection = ssh.SSH(user, ip, key_filename=key_filename) + self.connection = ssh.SSH(user, ip, key_filename=key_filename, + port=ssh_port) self.connection.wait(timeout=600) LOG.debug("ssh host success!") self.check_script = self.get_script_fullpath( @@ -33,21 +35,22 @@ class MonitorProcess(basemonitor.BaseMonitor): self.process_name = self._config["process_name"] def monitor_func(self): - exit_status, stdout, stderr = self.connection.execute( - "/bin/sh -s {0}".format(self.process_name), - stdin=open(self.check_script, "r")) + with open(self.check_script, "r") as stdin_file: + exit_status, stdout, stderr = self.connection.execute( + "/bin/sh -s {0}".format(self.process_name), + stdin=stdin_file) if not stdout or int(stdout) <= 0: - LOG.info("the process (%s) is not running!" % self.process_name) + LOG.info("the process (%s) is not running!", self.process_name) return False return True def verify_SLA(self): - LOG.debug("the _result:%s" % self._result) + LOG.debug("the _result:%s", self._result) outage_time = self._result.get('outage_time', None) max_outage_time = self._config["sla"]["max_recover_time"] if outage_time > max_outage_time: - LOG.error("SLA failure: %f > %f" % (outage_time, max_outage_time)) + LOG.error("SLA failure: %f > %f", outage_time, max_outage_time) return False else: return True |