Пример #1
0
def get_sync_zabbix_host():
    from app.common.zabbix import init
    init()
 
    zabbix_hosts = db.session.query(ZbHost).all()
    db.session.close()
    #不在cache表里的数据
#    select * from server where id not in zabbix_hosts_cmdb_id
    hostid = [zb.cmdb_hostid for zb in zabbix_hosts]  #在缓存表里的服务器id
    servers = db.session.query(Server).filter(~Server.id.in_(hostid)).all() ##~表示取反    
    return json.dumps([{"hostname":s.hostname, "id":s.id} for s in servers]) 
Пример #2
0
def get_sync_zabbix_host():
    from app.common.zabbix import init
    init()

    zabbix_hosts = db.session.query(ZbHost).all()
    db.session.close()
    #不在cache表里的数据
    #    select * from server where id not in zabbix_hosts_cmdb_id
    hostid = [zb.cmdb_hostid for zb in zabbix_hosts]  #在缓存表里的服务器id
    servers = db.session.query(Server).filter(
        ~Server.id.in_(hostid)).all()  ##~表示取反
    return json.dumps([{"hostname": s.hostname, "id": s.id} for s in servers])
Пример #3
0
def get_zabbix_data_by_group():
    from app.common.zabbix import get_zabbix_data,init
    init()
    params = dict(request.form)
    hosts = api_action('server.get',
        {
        'output':['id'],
        'where':{
            'server_purpose':params['server_purpose'][0],
            'service_id':params['service_id'][0]}
        })
    ret = get_zabbix_data(hosts)
    return json.dumps(ret)
Пример #4
0
def get_zabbix_data_by_group():
    from app.common.zabbix import get_zabbix_data, init
    init()
    params = dict(request.form)
    hosts = api_action(
        'server.get', {
            'output': ['id'],
            'where': {
                'server_purpose': params['server_purpose'][0],
                'service_id': params['service_id'][0]
            }
        })
    ret = get_zabbix_data(hosts)
    return json.dumps(ret)
Пример #5
0
def get_zabbix_data_by_group():
    from app.common.zabbix import get_zabbix_data, init
    init()
    params = dict(request.form)
    hosts = api_action(
        "server.get", {
            "output": ["id"],
            "where": {
                "server_purpose": params["server_purpose"][0],
                "service_id": params["service_id"][0]
            }
        })
    ret = get_zabbix_data(hosts)
    return json.dumps(ret)
Пример #6
0
def get_zabbix_data_by_group():
    from app.common.zabbix import get_zabbix_data, init

    init()
    params = dict(request.form)
    hosts = api_action(
        "server.get",
        {
            "output": ["id"],
            "where": {"server_purpose": params["server_purpose"][0], "service_id": params["service_id"][0]},
        },
    )
    ret = get_zabbix_data(hosts)
    return json.dumps(ret)