How to trigger Event_handler execution on WARNING?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

How to trigger Event_handler execution on WARNING?

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to trigger Event_handler execution on WARNING?

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Event Handler does not trigger CMD batch to run

Post 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)
You do not have the required permissions to view the files attached to this post.
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: How to trigger Event_handler execution on WARNING?

Post 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)
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to trigger Event_handler execution on WARNING?

Post 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.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: How to trigger Event_handler execution on WARNING?

Post 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!
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to trigger Event_handler execution on WARNING?

Post 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?
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: How to trigger Event_handler execution on WARNING?

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to trigger Event_handler execution on WARNING?

Post 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$
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: How to trigger Event_handler execution on WARNING?

Post 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
Locked