optimize the fault notification test
[doctor.git] / doctor_tests / monitor / sample.py
index 4dc5e60..9b21750 100644 (file)
@@ -51,16 +51,20 @@ class SampleMonitor(BaseMonitor):
         }
 
         auth_token = self.session.get_token() if \
-                     self.conf.inspector.type != 'sample' else None
+            self.conf.inspector.type != 'sample' else None
         headers = {
             'Content-Type': 'application/json',
             'Accept': 'application/json',
             'X-Auth-Token': auth_token,
         }
         if self.conf.inspector.type != Inspector.VITRAGE:
-            requests.put(self.inspector_url, data=json.dumps([data]), headers=headers)
+            requests.put(self.inspector_url,
+                         data=json.dumps([data]),
+                         headers=headers)
         else:
-            requests.post(self.inspector_url, data=json.dumps(data), headers=headers)
+            requests.post(self.inspector_url,
+                          data=json.dumps(data),
+                          headers=headers)
 
 
 class Pinger(Thread):
@@ -90,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