diff options
Diffstat (limited to 'yardstick/benchmark/scenarios/availability/monitor/monitor_process.py')
-rw-r--r-- | yardstick/benchmark/scenarios/availability/monitor/monitor_process.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py b/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py index 403ec4d37..5f492ad69 100644 --- a/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py +++ b/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py @@ -35,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 |