Get the number of host not monitored (active and passive checks disabled)

        :return: Number of hosts which are not monitored
        :rtype: int
420226
def _get_total_hosts_not_monitored(self):
        
        return sum(1 for h in self.hosts if not h.active_checks_enabled and
                   not h.passive_checks_enabled)
505723
def manage_host_check_result_brok(self, b):  # pylint: disable=too-many-branches
        """"""
        host_name = b.data.get('host_name', None)
        if not host_name:
            return
        logger.debug("host check result: %s", host_name)

        # If host initial status brok has not been received, ignore ...
        if host_name not in self.hosts_cache and not self.ignore_unknown:
            logger.warning("received host check result for an unknown host: %s", host_name)
            return

        # Decode received metrics
        metrics = self.get_metrics_from_perfdata('host_check', b.data['perf_data'])
        if not metrics:
            logger.debug("no metrics to send ...")
            return

        # If checks latency is ignored
        if self.ignore_latency_limit >= b.data['latency'] > 0:
            check_time = int(b.data['last_chk']) - int(b.data['latency'])
        else:
            check_time = int(b.data['last_chk'])

        # Custom hosts variables
        hname = sanitize_name(host_name)
        if host_name in self.hosts_cache:
            if self.hosts_cache[host_name].get('_GRAPHITE_GROUP', None):
                hname = ".".join((self.hosts_cache[host_name].get('_GRAPHITE_GROUP'), hname))

            if self.hosts_cache[host_name].get('_GRAPHITE_PRE', None):
                hname = ".".join((self.hosts_cache[host_name].get('_GRAPHITE_PRE'), hname))

        # Graphite data source
        if self.graphite_data_source:
            path = '.'.join((hname, self.graphite_data_source))
            if self.hostcheck:
                path = '.'.join((hname, self.graphite_data_source, self.hostcheck))
        else:
            path = '.'.join((hname, self.hostcheck))

        # Realm as a prefix
        if self.realms_prefix and self.hosts_cache[host_name].get('realm_name', None):
            path = '.'.join((self.hosts_cache[host_name].get('realm_name'), path))

        realm_name = None
        if host_name in self.hosts_cache:
            realm_name = self.hosts_cache[host_name].get('realm_name', None)

        # Send metrics
        self.send_to_tsdb(realm_name, host_name, self.hostcheck, metrics, check_time, path)
694274
def fail_hosts(self, hosts_to_fail, activated_count=None):
        '''
        
        '''

        if not hosts_to_fail:
            return

        activated_count = activated_count or len(self.activated_hosts)

        logger.debug('Failing hosts: {0}'.format(', '.join(
            (host.name for host in hosts_to_fail),
        )))

        # Remove the failed hosts from the inventory
        self.active_hosts -= hosts_to_fail

        # Check we're not above the fail percent
        active_hosts = self.active_hosts

        # No hosts left!
        if not active_hosts:
            raise PyinfraError('No hosts remaining!')

        if self.config.FAIL_PERCENT is not None:
            percent_failed = (
                1 - len(active_hosts) / activated_count
            ) * 100

            if percent_failed > self.config.FAIL_PERCENT:
                raise PyinfraError('Over {0}% of hosts failed ({1}%)'.format(
                    self.config.FAIL_PERCENT,
                    int(round(percent_failed)),
                ))
1259923
def status(self, host=None):
        
        if host is None:
            host_cores = self.host_cores
        else:
            host_cores = [hc for hc in self.host_cores if hc[0] == host]
        lst = []
        for host, _ in host_cores:
            ready = general.socket_ready((host, self.ctrl_port))
            lst.append((host, 'running' if ready else 'not-running'))
        return lst
946278
def stop_accepting_passive_host_checks(self):
        
        if self.my_conf.accept_passive_host_checks:
            self.my_conf.modified_attributes |= DICT_MODATTR["MODATTR_PASSIVE_CHECKS_ENABLED"].value
            self.my_conf.accept_passive_host_checks = False
            self.my_conf.explode_global_conf()
            self.daemon.update_program_status()
784494
def nonempty_set(C, mincount_connectivity=0):
    
    # truncate to states with at least one observed incoming or outgoing count.
    if mincount_connectivity > 0:
        C = C.copy()
        C[np.where(C < mincount_connectivity)] = 0
    return np.where(C.sum(axis=0) + C.sum(axis=1) > 0)[0]
1359984
def count(self):
        
        total = 0
        for test in self.protocol_model.allTests():
            total += test.traceCount()*test.loopCount()*test.repCount() + test.repCount()
        return total
284984
def hosts(self):
        
        network = int(self.network_address)
        broadcast = int(self.broadcast_address)
        for x in long_range(1, broadcast - network + 1):
            yield self._address_class(network + x)
929299
def disable_host_notifications(self, host):
        
        if host.notifications_enabled:
            host.modified_attributes |= DICT_MODATTR["MODATTR_NOTIFICATIONS_ENABLED"].value
            host.notifications_enabled = False
            self.send_an_element(host.get_update_status_brok())
7810
def count(self, until=None):
        

        until = rationalize_until(until)
        return self.connection.zcount(self.scheduled_jobs_key, 0, until)
111343
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
479687
def find_guest(name, quiet=False, path=None):
    '''
    
    '''
    if quiet:
        log.warning("'quiet' argument is being deprecated."
                 ' Please migrate to --quiet')
    for data in _list_iter(path=path):
        host, l = next(six.iteritems(data))
        for x in 'running', 'frozen', 'stopped':
            if name in l[x]:
                if not quiet:
                    __jid_event__.fire_event(
                        {'data': host,
                         'outputter': 'lxc_find_host'},
                        'progress')
                return host
    return None
458055
def get_num_nodes(properties=None, hadoop_conf_dir=None, offline=False):
    
    return len(get_task_trackers(properties, hadoop_conf_dir, offline))
1154894
def _get_total_hosts_problems_handled(self):
        
        return sum(1 for h in self.hosts if h.is_problem and h.problem_has_been_acknowledged)
594568
def proxy_bypass_environment(host):
    
    no_proxy = os.environ.get('no_proxy', '') or os.environ.get('NO_PROXY', '')
    # '*' is special case for always bypass
    if no_proxy == '*':
        return 1
    # strip port off host
    hostonly, port = splitport(host)
    # check if the host ends with any of the DNS suffixes
    no_proxy_list = [proxy.strip() for proxy in no_proxy.split(',')]
    for name in no_proxy_list:
        if name and (hostonly.endswith(name) or host.endswith(name)):
            return 1
    # otherwise, don't bypass
    return 0
461429
def get_hostnames(self):
        
        hosts = set()
        for entry in self._config:
            hosts.update(entry["host"])
        return hosts
864684
def count(self):
        
        if hasattr(self, '_response'):
            return self._response.hits.total

        es = connections.get_connection(self._using)

        d = self.to_dict(count=True)
        # TODO: failed shards detection
        return es.count(
            index=self._index,
            body=d,
            **self._params
        )['count']