Page 1 of 2

How to trigger Event_handler execution on WARNING?

Posted: Fri Mar 02, 2018 2:45 pm
by dlukinski
Hello XI Support

We've create commands and scripts to execute CMD file (disk cleanup) via Event Handler

How to trigger its execution when DISK space gets WARNING (not CRITICAL), any way to differentiate in between two?

Thank you

Re: How to trigger Event_handler execution on WARNING?

Posted: Fri Mar 02, 2018 2:53 pm
by scottwilkerson
You can pass the state into your event handler script and use it's value to choose when to take action.

Here's some documentation
https://assets.nagios.com/downloads/nag ... ios-XI.pdf

Event Handler does not trigger CMD batch to run

Posted: Wed Mar 07, 2018 3:13 pm
by dlukinski
Hello XI Support

We 've got working (tested) *.cmd batch to run in response to the event, but it is not running or triggered?

1. INI config looks this way

[/settings/external scripts/scripts]
allow arguments = true

diskcleanup1=scripts\\custom\\diskcleanup1.cmd

timeout=300

2. XI command looks this way

Command Name: nrpe_disk_cleanup1
Command Line: $USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c diskcleanup1


3. Event configuration (still unsure how to make it run on WARNING) is as attached (templated vs other configs)

----------------------------------------------------------------------------------------------------------------------------------
Believe we've missed free variable configuration (unsure what and how to configure in this case)

Re: How to trigger Event_handler execution on WARNING?

Posted: Wed Mar 07, 2018 3:14 pm
by dlukinski
scottwilkerson wrote:You can pass the state into your event handler script and use it's value to choose when to take action.

Here's some documentation
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Please provide the sample / example of the configuration. So far thing s do not work for us (another case just created)

Re: How to trigger Event_handler execution on WARNING?

Posted: Wed Mar 07, 2018 4:09 pm
by scottwilkerson
I merged these topics because it is the same issue.

We have documentation in doing this in windows
https://assets.nagios.com/downloads/nag ... ios-XI.pdf

The document is for restarting a service but the same theory applies.

Re: How to trigger Event_handler execution on WARNING?

Posted: Thu Mar 08, 2018 8:31 am
by dlukinski
scottwilkerson wrote:I merged these topics because it is the same issue.

We have documentation in doing this in windows
https://assets.nagios.com/downloads/nag ... ios-XI.pdf

The document is for restarting a service but the same theory applies.
This does NOT help us with fixing the problem.
Please schedule a support session with us!

Re: How to trigger Event_handler execution on WARNING?

Posted: Thu Mar 08, 2018 10:01 am
by scottwilkerson
dlukinski wrote:This does NOT help us with fixing the problem.
Please schedule a support session with us!
With all due respect, support with your licenses does not include "done for you" service, that would be added custom consulting.

Sometime when problems arise on a clients system we may choose to assist via remote session but that is at our discretion when the client has made a reasonable attempt to follow direction and we may need to see the problem to resolve it.

The document I provided gives very precise examples of how to accomplish what you described you are looking to do. Where in the document did you get stuck?

Re: How to trigger Event_handler execution on WARNING?

Posted: Thu Mar 08, 2018 10:46 am
by dlukinski
scottwilkerson wrote:
dlukinski wrote:This does NOT help us with fixing the problem.
Please schedule a support session with us!
With all due respect, support with your licenses does not include "done for you" service, that would be added custom consulting.

Sometime when problems arise on a clients system we may choose to assist via remote session but that is at our discretion when the client has made a reasonable attempt to follow direction and we may need to see the problem to resolve it.

The document I provided gives very precise examples of how to accomplish what you described you are looking to do. Where in the document did you get stuck?
I do not know or understand what kind of Free variable should be created to support script execution on warning. Reboot example is not helping.

Re: How to trigger Event_handler execution on WARNING?

Posted: Thu Mar 08, 2018 10:59 am
by scottwilkerson
I'm sorry I should have been clearer, on page 3-5 starts a section "Create Event Handler Script" there is an example of a script that you can use as your event handler. The service restart example has more information that you need for a less complicated example

This script in the example looks something like this

Code: Select all

#!/bin/sh
case "$1" in
OK)
;;
WARNING)
;;
UNKNOWN)
;;
CRITICAL)
/usr/local/nagios/libexec/check_nrpe -H "$2" -p 5666 -c restart_service -a "$3"
;;
esac
exit 0
$USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c diskcleanup1

But for you, I would make one that looks like this so it only runs on warning
/usr/local/nagios/libexec/diskcleanup.sh

Code: Select all

#!/bin/sh
case "$1" in
    OK)
    ;;
    WARNING)
    /usr/local/nagios/libexec/check_nrpe -H "$2" -p 5666 -c diskcleanup1
    ;;
    UNKNOWN)
    ;;
    CRITICAL)
    ;;
esac
exit 0
Then define your event handler command like this

Code: Select all

$USER1$/diskcleanup.sh $SERVICESTATE$ $HOSTADDRESS$

Re: How to trigger Event_handler execution on WARNING?

Posted: Thu Mar 08, 2018 2:25 pm
by dlukinski
scottwilkerson wrote:I'm sorry I should have been clearer, on page 3-5 starts a section "Create Event Handler Script" there is an example of a script that you can use as your event handler. The service restart example has more information that you need for a less complicated example

This script in the example looks something like this

Code: Select all

#!/bin/sh
case "$1" in
OK)
;;
WARNING)
;;
UNKNOWN)
;;
CRITICAL)
/usr/local/nagios/libexec/check_nrpe -H "$2" -p 5666 -c restart_service -a "$3"
;;
esac
exit 0
$USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c diskcleanup1

But for you, I would make one that looks like this so it only runs on warning
/usr/local/nagios/libexec/diskcleanup.sh

Code: Select all

#!/bin/sh
case "$1" in
    OK)
    ;;
    WARNING)
    /usr/local/nagios/libexec/check_nrpe -H "$2" -p 5666 -c diskcleanup1
    ;;
    UNKNOWN)
    ;;
    CRITICAL)
    ;;
esac
exit 0
Then define your event handler command like this

Code: Select all

$USER1$/diskcleanup.sh $SERVICESTATE$ $HOSTADDRESS$

Thank you

I got fixated on client-side only script solution. Now trying this one instead