summaryrefslogtreecommitdiffstats
path: root/doctor_tests/monitor
diff options
context:
space:
mode:
authordongwenjuan <dong.wenjuan@zte.com.cn>2018-03-20 15:13:14 +0800
committerdongwenjuan <dong.wenjuan@zte.com.cn>2018-03-20 16:27:19 +0800
commit631c3f99f0e499edd1adcbc7550dd3d0de393e31 (patch)
treeba85640e823956ea02c2ae045909e74b80c06ec1 /doctor_tests/monitor
parent5bbd044650de0ab4179101bb3156dd315be9391f (diff)
optimize the fault notification test
Change-Id: I47572b4515049c49f9aa04bf7984757779a605f3 Signed-off-by: dongwenjuan <dong.wenjuan@zte.com.cn>
Diffstat (limited to 'doctor_tests/monitor')
-rw-r--r--doctor_tests/monitor/base.py9
-rw-r--r--doctor_tests/monitor/sample.py4
2 files changed, 12 insertions, 1 deletions
diff --git a/doctor_tests/monitor/base.py b/doctor_tests/monitor/base.py
index 119c8a1c..c2341225 100644
--- a/doctor_tests/monitor/base.py
+++ b/doctor_tests/monitor/base.py
@@ -17,6 +17,15 @@ class BaseMonitor(object):
self.conf = conf
self.log = log
self.inspector_url = inspector_url
+ self._detected_time = None
+
+ @property
+ def detected_time(self):
+ return self._detected_time
+
+ @detected_time.setter
+ def detected_time(self, detected_time):
+ self._detected_time = detected_time
@abc.abstractmethod
def start(self, host):
diff --git a/doctor_tests/monitor/sample.py b/doctor_tests/monitor/sample.py
index c207cd9f..9b21750b 100644
--- a/doctor_tests/monitor/sample.py
+++ b/doctor_tests/monitor/sample.py
@@ -94,7 +94,9 @@ class Pinger(Thread):
sock.sendto(self.ICMP_ECHO_MESSAGE, (self.ip_addr, 0))
sock.recv(4096)
except socket.timeout:
- self.log.info("doctor monitor detected at %s" % time.time())
+ detected_time = time.time()
+ self.log.info("doctor monitor detected at %s" % detected_time)
+ self.monitor.detected_time = detected_time
self.monitor.report_error(self.hostname)
self.log.info("ping timeout, quit monitoring...")
self._stopped = True