# Path: app/lib/livestatusconnection.py

# 
# Path: app/lib/datasources.py



from app.lib.livestatusconnection import live
from app.lib.datasources import multisite_datasources as datasources
    # Most layouts need current state of object in order to
    # choose background color - even if no painter for state
    # is selected. Make sure those columns are fetched. This
    # must not be done for the table 'log' as it cannot correctly
    # distinguish between service_state and host_state
    if "log" not in datasource["infos"]:
        state_columns = []
        if "service" in datasource["infos"]:
            state_columns += [ "service_has_been_checked", "service_state" ]
        if "host" in datasource["infos"]:
            state_columns += [ "host_has_been_checked", "host_state" ]
        for c in state_columns:
            if c not in columns:
                columns.append(c)

    # Remove columns which are implicitely added by the datasource
    if add_columns:
        columns = [ c for c in columns if c not in add_columns ]

    query = "GET %s\n" % tablename
    query += "Columns: %s\n" % " ".join(columns)
    query += add_headers
    query += filters_string
    live.set_prepend_site(True)
    if limit != None:
        live.set_limit(limit + 1) # + 1: We need to know, if limit is exceeded

    if only_sites:
        live.set_only_sites(only_sites)
    data = live.query(query)

# Path: app/lib/livestatusconnection.py

# 
# Path: app/lib/datasources.py



# Path: app/lib/livestatus_query.py
from app.lib.livestatusconnection import live
from app.lib.datasources import multisite_datasources as datasources

    # Most layouts need current state of object in order to
    # choose background color - even if no painter for state
    # is selected. Make sure those columns are fetched. This
    # must not be done for the table 'log' as it cannot correctly
    # distinguish between service_state and host_state
    if "log" not in datasource["infos"]:
        state_columns = []
        if "service" in datasource["infos"]:
            state_columns += [ "service_has_been_checked", "service_state" ]
        if "host" in datasource["infos"]:
            state_columns += [ "host_has_been_checked", "host_state" ]
        for c in state_columns:
            if c not in columns:
                columns.append(c)

    # Remove columns which are implicitely added by the datasource
    if add_columns:
        columns = [ c for c in columns if c not in add_columns ]

    query = "GET %s\n" % tablename
    query += "Columns: %s\n" % " ".join(columns)
    query += add_headers
    query += filters_string
    live.set_prepend_site(True)
    if limit != None:
        live.set_limit(limit + 1) # + 1: We need to know, if limit is exceeded

    if only_sites:
        live.set_only_sites(only_sites)
    data = live.query(query)

    live.set_only_sites(None)