Exemple #1
0
def get_operation(request):
    data = {}
    if request.GET.get("operation"):
        data["operation"] = json.loads(request.GET.get("operation"))
    else:
        data["operation"] = {
            "esc_step_from": 1,
            "esc_step_to": 1,
            "esc_period": 0
        }
    auth = ZabbixRestAPI.get_auth("Admin", "zabbix")
    zabbix = ZabbixRestAPI(auth)
    user_result = zabbix.get_user(filters={"alias": "Admin"})
    if user_result.get("result"):
        data["user"] = user_result["result"]
    media_result = zabbix.get_mediatype()
    if media_result.get("result"):
        data["mediatype"] = media_result["result"]

    return render(request, "monitoring/action/loadpage/operation.html", data)
Exemple #2
0
def get_user_info(user_id):
    auth = ZabbixRestAPI.get_auth("Admin", "zabbix")
    zabbix = ZabbixRestAPI(auth)
    result = zabbix.get_user(userids=user_id)
    if result.get("result"):
        users = result.get("result")
        user_name = ""
        for user in users:
            user_name = user.get("alias")
            if user.get("name") or user.get("surname"):
                # first_name + family_name
                user_name += " ("
                if user.get("name"):
                    user_name += user["name"]
                    if user.get("surname"):
                        user_name += " "
                if user.get("surname"):
                    user_name += user["surname"]
                user_name += ")"
        user_info = user_name
    else:
        user_info = result
    return user_info