コード例 #1
0
ファイル: views.py プロジェクト: jaehoonpaul/i2nsf-soa
def get_triggers(request):
    auth = ZabbixRestAPI.get_auth("Admin", "zabbix")
    zabbix = ZabbixRestAPI(auth)
    templateids = request.POST.get("templateids")
    hostids = request.POST.get("hostids")
    if templateids:
        result = zabbix.get_triggers(output="extend", templateids=templateids)
    else:
        result = zabbix.get_triggers(output="extend", hostids=hostids)

    return JsonResponse(result)
コード例 #2
0
def get_trigger_info(trigger_id):
    auth = ZabbixRestAPI.get_auth("Admin", "zabbix")
    zabbix = ZabbixRestAPI(auth)
    result = zabbix.get_triggers(triggerids=trigger_id, selectHosts="extend")
    if result.get("result"):
        triggers = result.get("result")
        for trigger in triggers:
            hosts = trigger.get("hosts")
            trigger["host_name"] = ""
            for host in hosts:
                trigger["host_name"] += host.get("host")
            trigger["description"] = trigger.get("description").replace(
                "{HOST.NAME}", trigger["host_name"])
        trigger = triggers[0]
        trigger_info = trigger.get("description")
    else:
        trigger_info = result
    return trigger_info