####################################################
# COMMAND DEFINITIONS - TO BE IMPORTED
####################################################

####################################################
# EVENT HANDLER COMMANDS
####################################################

define command {
    command_name xi_host_event_handler
    command_line /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_event.php --handler-type=host --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hoststate=$HOSTSTATE$  --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT$" --hostdowntime=$HOSTDOWNTIME$
}

define command {
    command_name xi_service_event_handler
    command_line /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_event.php --handler-type=service --host="$HOSTNAME$" --service="$SERVICEDESC$" --hostaddress="$HOSTADDRESS$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --servicestate=$SERVICESTATE$  --servicestateid=$SERVICESTATEID$ --lastservicestate=$LASTSERVICESTATE$ --lastservicestateid=$LASTSERVICESTATEID$ --servicestatetype=$SERVICESTATETYPE$ --currentattempt=$SERVICEATTEMPT$ --maxattempts=$MAXSERVICEATTEMPTS$ --serviceeventid=$SERVICEEVENTID$ --serviceproblemid=$SERVICEPROBLEMID$ --serviceoutput="$SERVICEOUTPUT$" --longserviceoutput="$LONGSERVICEOUTPUT$" --servicedowntime=$SERVICEDOWNTIME$
}

####################################################
# NOTIFICATION COMMANDS
####################################################

define command {
    command_name xi_host_notification_handler
    command_line /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=host   --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$"  --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT$" --datetime="$LONGDATETIME$"
}

define command {
    command_name xi_service_notification_handler
    command_line /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=service  --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$"  --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --service="$SERVICEDESC$"  --hoststate=$HOSTSTATE$  --hoststateid=$HOSTSTATEID$ --servicestate=$SERVICESTATE$ --servicestateid=$SERVICESTATEID$ --lastservicestate=$LASTSERVICESTATE$ --lastservicestateid=$LASTSERVICESTATEID$ --servicestatetype=$SERVICESTATETYPE$ --currentattempt=$SERVICEATTEMPT$ --maxattempts=$MAXSERVICEATTEMPTS$ --serviceeventid=$SERVICEEVENTID$ --serviceproblemid=$SERVICEPROBLEMID$ --serviceoutput="$SERVICEOUTPUT$" --longserviceoutput="$LONGSERVICEOUTPUT$" --datetime="$LONGDATETIME$"
}

####################################################
# HOST CHECK COMMANDS
####################################################

define command {
    command_name    check_xi_host_ping
    command_line    $USER1$/check_icmp -H $HOSTADDRESS$ -w $ARG1$,$ARG2$ -c $ARG3$,$ARG4$ -p 5
}

define command {
    command_name    check_xi_host_http
    command_line    $USER1$/check_http -H $HOSTADDRESS$ $ARG1$
}

####################################################
# SERVICE CHECK COMMANDS
####################################################

define command {
    command_name    check_xi_service_none
    command_line    $USER1$/check_dummy 0 "Nothing to monitor"
}
    
define command {
    command_name    check_xi_service_http
    command_line    $USER1$/check_http -H $HOSTADDRESS$ $ARG1$
}

define command {
    command_name    check_xi_service_http_cert
    command_line    $USER1$/check_http -H $HOSTADDRESS$ -C $ARG1$
}

# Deprecated

define command {
    command_name    check_xi_service_http_content
    command_line    $USER1$/check_http -H $HOSTADDRESS$ --onredirect=follow -s "$ARG1$"
}

define command {
    command_name    check_xi_service_ping
    command_line    $USER1$/check_icmp -H $HOSTADDRESS$ -w $ARG1$,$ARG2$ -c $ARG3$,$ARG4$ -p 5
}

define command {
    command_name    check_xi_service_dns
    command_line    $USER1$/check_dns -H $HOSTADDRESS$ $ARG1$
}

define command {
    command_name    check_xi_service_hpjd
    command_line    $USER1$/check_hpjd -H $HOSTADDRESS$ -C $ARG1$
}

define command {
    command_name    check_xi_service_nsclient
    command_line    $USER1$/check_nt -H $HOSTADDRESS$ -s "$ARG1$" -p 12489 -v $ARG2$ $ARG3$ $ARG4$
}

define command {
    command_name    check_xi_service_ifoperstatus
    command_line    $USER1$/check_ifoperstatus -H $HOSTADDRESS$ -C $ARG1$ -k $ARG2$ $ARG3$
}

define command {
    command_name    check_xi_service_mrtgtraf
    command_line    $USER1$/check_rrdtraf -f /var/lib/mrtg/$ARG1$ -w $ARG2$ -c $ARG3$ -l $ARG4$
}

define command {
    command_name    check_xi_service_webinject
    command_line    $USER1$/check_webinject.sh $ARG1$
}

define command {
    command_name    check_xi_service_ftp
    command_line    $USER1$/check_ftp -H $HOSTADDRESS$ $ARG1$
}

define command {
    command_name    check_xi_service_imap
    command_line    $USER1$/check_imap -H $HOSTADDRESS$ $ARG1$
}

define command {
    command_name    check_xi_service_pop
    command_line    $USER1$/check_pop -H $HOSTADDRESS$ $ARG1$
}

define command {
    command_name    check_xi_service_smtp
    command_line    $USER1$/check_smtp -H $HOSTADDRESS$ $ARG1$
}

define command {
    command_name    check_xi_service_ssh
    command_line    $USER1$/check_ssh $ARG1$ $HOSTADDRESS$
}

define command {
    command_name    check_xi_service_tcp
    command_line    $USER1$/check_tcp -H $HOSTADDRESS$ $ARG1$
}

define command {
    command_name    check_xi_service_udp
    command_line    $USER1$/check_udp -H $HOSTADDRESS$ $ARG1$
}

define command {
    command_name    check_xi_service_snmp
    command_line    $USER1$/check_snmp -H $HOSTADDRESS$ $ARG1$
}

define command {
    command_name check_xi_service_status
    command_line sudo /usr/local/nagiosxi/scripts/manage_services.sh status $ARG1$
}
