コード例 #1
0
ファイル: sensugrid.py プロジェクト: daghan/sensu-grid
def events(d, filters=''):
    results = []

    dc_found = False

    if dcs:
        for dc in dcs:
            if dc['name'] == d:
                dc_found = True
                if check_connection(dc):
                    results += get_events(dc, timeout, filters.split(','))
                break

    if dc_found is False:
        abort(404)

    results = sorted(
        results,
        lambda x, y: _cmp(x['check']['status'], y['check']['status']),
        reverse=True)

    return render_template('events.html',
                           dc=dc,
                           data=results,
                           filter_data=get_filter_data(dcs, timeout),
                           appcfg=appcfg)
コード例 #2
0
ファイル: sensugrid.py プロジェクト: daghan/sensu-grid
def filtered(filters):
    aggregated = []
    for dc in dcs:
        if check_connection(dc):
            aggregated.append(
                agg_data(dc, get_data(dc, timeout), get_stashes(dc, timeout),
                         get_clients(dc, timeout), filters))

    return render_template('data.html',
                           dcs=dcs,
                           data=aggregated,
                           filter_data=get_filter_data(dcs, timeout),
                           appcfg=appcfg)
コード例 #3
0
ファイル: sensugrid.py プロジェクト: daghan/sensu-grid
def healthcheck():
    """
    Returns a json formatted message
    """
    ret = []

    for dc in dcs:
        retdata = {}
        retdata[dc['name']] = {}
        retdata[dc['name']]['url'] = dc['url']
        retdata[dc['name']]['port'] = dc['port']
        if 'user' in dc:
            retdata[dc['name']]['user'] = dc['user']
        if 'password' in dc:
            retdata[dc['name']]['password'] = '******'
        if check_connection(dc):
            retdata[dc['name']]['connected'] = 'True'
            retdata[dc['name']]['error'] = 'False'
        if not check_connection(dc):
            retdata[dc['name']]['connected'] = 'False'
            retdata[dc['name']]['error'] = 'True'
        ret.append(retdata)

    return jsonify(ret)
コード例 #4
0
ファイル: sensugrid.py プロジェクト: daghan/sensu-grid
def showgrid(d, filters=None):
    data_detail = {}
    if dcs:
        for dc in dcs:
            if dc['name'] == d:
                if check_connection(dc):
                    if filters:
                        clients = get_clients(dc, timeout)
                    else:
                        clients = None

                    data_detail = agg_host_data(get_data(dc, timeout),
                                                get_stashes(dc, timeout),
                                                clients, filters)
                    if data_detail:
                        break
    else:
        abort(404)
    return render_template('detail.html',
                           dc=dc,
                           data=data_detail,
                           filter_data=get_filter_data(dcs, timeout),
                           appcfg=appcfg)