(self, hosts)
return stats
Get statistics for Hosts, resp. Host entities
Get statistics for Hosts, resp. Host entities
Get statistics for Hosts resp . Host entities
def get_host_stats(self, hosts):
        """ Get statistics for Hosts, resp. Host entities """
        stats = {
            "hosts.total": 0,
            "hosts.ok": 0,
            "hosts.down": 0,
            "hosts.unreachable": 0,
            "hosts.flapping": 0,
            "hosts.in_downtime": 0,
            "hosts.checked": 0,
            "hosts.scheduled": 0,
            "hosts.active_checks": 0,
            "hosts.passive_checks": 0,
        }
        for host in list(hosts):
            if type(host) is not dict:
                continue

            sane = self._sanitize_entity(host)
            stats["hosts.total"] += 1
            stats["hosts.flapping"] += self._trans_binary(sane["flapping"])
            stats[
                "hosts.in_downtime"] += self._trans_dtime(sane["in_downtime"])
            stats["hosts.checked"] += self._trans_binary(sane["checked"])
            stats["hosts.scheduled"] += self._trans_binary(sane["scheduled"])
            stats["hosts.active_checks"] += sane["active_checks"]
            stats["hosts.passive_checks"] += sane["passive_checks"]
            state_key = self._trans_host_state(sane["state"])
            stats["hosts.%s" % (state_key)] += 1

        return stats
def get_host_stats ( self , hosts ) : stats = { "hosts.total" : 0 , "hosts.ok" : 0 , "hosts.down" : 0 , "hosts.unreachable" : 0 , "hosts.flapping" : 0 , "hosts.in_downtime" : 0 , "hosts.checked" : 0 , "hosts.scheduled" : 0 , "hosts.active_checks" : 0 , "hosts.passive_checks" : 0 , } for host in list ( hosts ) : if type ( host ) is not dict : continue sane = self . _sanitize_entity ( host ) stats [ "hosts.total" ] += 1 stats [ "hosts.flapping" ] += self . _trans_binary ( sane [ "flapping" ] ) stats [ "hosts.in_downtime" ] += self . _trans_dtime ( sane [ "in_downtime" ] ) stats [ "hosts.checked" ] += self . _trans_binary ( sane [ "checked" ] ) stats [ "hosts.scheduled" ] += self . _trans_binary ( sane [ "scheduled" ] ) stats [ "hosts.active_checks" ] += sane [ "active_checks" ] stats [ "hosts.passive_checks" ] += sane [ "passive_checks" ] state_key = self . _trans_host_state ( sane [ "state" ] ) stats [ "hosts.%s" % ( state_key ) ] += 1 return stats