#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-

def check_mkevents_arguments(params):
    args = ""
    if "remote" in params:
        remote = params["remote"]
        if type(remote) == tuple:
            args += "-H %s:%d " % (quote_shell_string(remote[0]), remote[1])
        elif remote:
            args += "-s %s " % quote_shell_string(remote)

    if params.get("ignore_acknowledged"):
        args += "-a "

    if params.get("less_verbose"):
        args += "-l "

    hostspec = params.get("hostspec", "$HOSTADDRESS$")
    if type(hostspec) == list:
        hostspec = "/".join(hostspec)
    args += hostspec

    if "application" in params:
        args += " " + quote_shell_string(params["application"])
    return args

def check_mkevents_description(params):
    item = params.get('item', params.get('application'))
    if item:
        return "Events %s" % item
    else:
        return "Events"

active_check_info['mkevents'] = {
    "command_line"        : '$USER1$/check_mkevents $ARG1$',
    "argument_function"   : check_mkevents_arguments,
    "service_description" : check_mkevents_description,
    "has_perfdata"        : False,
}
