コード例 #1
0
ファイル: views.py プロジェクト: jaehoonpaul/i2nsf-soa
def info(request, host_id):
    auth = ZabbixRestAPI.get_auth("Admin", "zabbix")
    zabbix = ZabbixRestAPI(auth)
    # 호스트 리스트
    host_result = zabbix.get_hosts(output=["hostid", "host", "name"])
    if host_result.get("result"):
        hosts = host_result.get("result")
    else:
        hosts = host_result

    # 호스트 정보가 없을 경우
    if '1' == host_id:
        return redirect("/dashboard/monitoring/" + hosts[0].get("hostid") + "/detail")

    # 이벤트 정보
    result = zabbix.get_host_events(hostid=host_id, output="extend", sortfield=["clock", "eventid"])
    if result.get("result"):
        events = result.get("result")
    else:
        events = result

    host_flag = True
    result_host_interfaces = zabbix.get_host_interfaces(output=["hostid", "ip", "port"])
    if result_host_interfaces.get("result"):
        host_interfaces = result_host_interfaces["result"]
        for host_interface in host_interfaces:
            # host와 interface 매칭
            if host_id == host_interface.get("hostid"):
                if "127.0.0.1" in host_interface.get("ip") or "localhost" in host_interface.get("ip"):
                    host_flag = False
    return render(request, "monitoring/info.html", {"hostid": host_id, "hosts": hosts, "events": events, "host_flag": host_flag})
コード例 #2
0
ファイル: views.py プロジェクト: jaehoonpaul/i2nsf-soa
def chart(request, host_id):
    auth = ZabbixRestAPI.get_auth("Admin", "zabbix")
    zabbix = ZabbixRestAPI(auth)
    # 이벤트 정보
    result = zabbix.get_host_events(hostid=host_id, output="extend", sortfield=["clock", "eventid"])
    if result.get("result"):
        events = result.get("result")
    else:
        events = result
    return render(request, "monitoring/chart.html", {"events": events})