コード例 #1
0
ファイル: grapher.py プロジェクト: jsianard/omeganoc
def _create_logical_hosts_graph_structure(hostgroups = None):
    """
    Creates a graph containing one node per service, grouped by host.
    Services may be filtered by containing hostgroup, using the hostgroup
    parameter that may contain an array of strings (hostgroup names)
    """
    g = Graph()
    slist = get_all_services()
    hlist = get_all_hosts()
    permissions = utils.get_contact_permissions(current_user.shinken_contact)
    tmp = {}
    for s in slist:
        if s in permissions['services']:
            tmp[s] = slist[s]
    slist = tmp

    # Nodes
    for sname in slist:
        for hname, s in slist[sname].iteritems():
            h = hlist[hname]
            filtered = False
            # Filter by hostgroups
            if hostgroups is not None:
                filtered = any([test in hostgroups for g in s['host_groups']])
            if not filtered:
                g.add_or_get_group_from_host(h).add_node(g.add_node_from_service(s))
    # Edges
    for sname in slist:
        for s in slist[sname].itervalues():
            for parent_host, parent_service in _extract_service_dependencies(s):
                g.add_link_from_service_dependency(parent_host, parent_service, s['host_name'], s['description'])
    return g
コード例 #2
0
 def get_livestatus_components():
     """ 
     Returns the full list of components known to Livestatus.
     The result is an array of tuples (hostname, servicename)
     in which servicename may be null to describe a host component.
     """
     result = []
     hlist = get_all_hosts()
     for hname in hlist:
         result.append((hname, None))
         for sname in hlist[hname]['services']:
             result.append((hname, sname))
     return result
コード例 #3
0
ファイル: grapher.py プロジェクト: jsianard/omeganoc
def _create_physical_hosts_graph_structure(hostgroups = None):
    """
    Generates a graph from the Shinken configuration, with hosts as nodes and parent dependencies as edges.
    The hostgroups parameter may contain an array of hostgroup names and can be used for including only hosts belonging to those hostgroups.
    """
    g = Graph()
    permissions = utils.get_contact_permissions(current_user.shinken_contact)
    all_hosts = get_all_hosts()

    for hname, h in all_hosts.iteritems():
        if hname not in permissions['hosts']:
            continue
        if hostgroups is not None:
            if any([group in hostgroups for group in h['groups']]):
                g.add_node_from_host(h)
        else:
            g.add_node_from_host(h)
    
    for hname, h in all_hosts.iteritems():
        if hname not in permissions['hosts']:
            continue
        g.add_link_from_host_parents(h)
    
    return g
コード例 #4
0
def _create_logical_hosts_graph_structure(hostgroups=None):
    """
    Creates a graph containing one node per service, grouped by host.
    Services may be filtered by containing hostgroup, using the hostgroup
    parameter that may contain an array of strings (hostgroup names)
    """
    g = Graph()
    slist = get_all_services()
    hlist = get_all_hosts()
    permissions = utils.get_contact_permissions(current_user.shinken_contact)
    tmp = {}
    for s in slist:
        if s in permissions['services']:
            tmp[s] = slist[s]
    slist = tmp

    # Nodes
    for sname in slist:
        for hname, s in slist[sname].iteritems():
            h = hlist[hname]
            filtered = False
            # Filter by hostgroups
            if hostgroups is not None:
                filtered = any([test in hostgroups for g in s['host_groups']])
            if not filtered:
                g.add_or_get_group_from_host(h).add_node(
                    g.add_node_from_service(s))
    # Edges
    for sname in slist:
        for s in slist[sname].itervalues():
            for parent_host, parent_service in _extract_service_dependencies(
                    s):
                g.add_link_from_service_dependency(parent_host, parent_service,
                                                   s['host_name'],
                                                   s['description'])
    return g
コード例 #5
0
def _create_physical_hosts_graph_structure(hostgroups=None):
    """
    Generates a graph from the Shinken configuration, with hosts as nodes and parent dependencies as edges.
    The hostgroups parameter may contain an array of hostgroup names and can be used for including only hosts belonging to those hostgroups.
    """
    g = Graph()
    permissions = utils.get_contact_permissions(current_user.shinken_contact)
    all_hosts = get_all_hosts()

    for hname, h in all_hosts.iteritems():
        if hname not in permissions['hosts']:
            continue
        if hostgroups is not None:
            if any([group in hostgroups for group in h['groups']]):
                g.add_node_from_host(h)
        else:
            g.add_node_from_host(h)

    for hname, h in all_hosts.iteritems():
        if hname not in permissions['hosts']:
            continue
        g.add_link_from_host_parents(h)

    return g
コード例 #6
0
ファイル: structureservice.py プロジェクト: jsianard/omeganoc
def hostsservice():
    return jsondump(get_all_hosts(), True)
コード例 #7
0
ファイル: structureservice.py プロジェクト: jsianard/omeganoc
def hostsservice():
    return jsondump(get_all_hosts(), True)