def execute(self, args): for arg in args.host: obj = self.traverse(arg) if ICompute.providedBy(obj): address = obj.hostname.encode('utf-8') else: address = arg res = ping(address) self.write("%s is %s\n" % (address, ["unreachable", "alive"][res]))
def _execute(self, cmd, args): address = self.context.hostname.encode('utf-8') res = ping(address) self.context.last_ping = (res == 1) self.context.pingcheck.append({'timestamp': datetime.utcnow(), 'result': res}) history_len = len(self.context.pingcheck) if history_len > self.mem_limit: del self.context.pingcheck[:-self.mem_limit] ping_results = map(lambda i: i['result'] == 1, self.context.pingcheck[:3]) self.context.suspicious = not all(ping_results) self.context.failure = not any(ping_results)
def _execute(self, cmd, args): address = self.context.hostname.encode('utf-8') res = ping(address) self.context.last_ping = (res == 1) self.context.pingcheck.append({ 'timestamp': datetime.utcnow(), 'result': res }) history_len = len(self.context.pingcheck) if history_len > self.mem_limit: del self.context.pingcheck[:-self.mem_limit] ping_results = map(lambda i: i['result'] == 1, self.context.pingcheck[:3]) self.context.suspicious = not all(ping_results) self.context.failure = not any(ping_results)