You are here

Event handler script does not run.

5 posts / 0 new
Last post
bertalan.voros
bertalan.voros's picture
Event handler script does not run.

Hello All,

Is this the correct way of defining an event handler script?

#!/bin/bash
if [[ "$NAGIOS_SERVICESTATE" = "CRITICAL" ]]
then
#Do something.
fi
exit 0

Doesn't seem to get evaluated as true.

If I remove the if then it gets run every time the check runs. So that bit is ok.

Inside the service check only the event handler script name is specified. Would I have to add $NAGIOS_SERVICESTATE$ as an argument to be passed?

smarsh
smarsh's picture
Have you seen this article?

Have you seen this article? It might help! https://www.opsview.com/about-us/blog/opsview-event-handlers

Event handlers are tricky little things. 

bertalan.voros
bertalan.voros's picture
Hi,

Hi,

I have not seen that one but these two:

Correct: http://docs.opsview.com/doku.php?id=opsview-core:usingeventhandlers

Slightly outdated: http://www.opsview.com/about-us/blog/restarting-windows-services

The two combined gave me what I was trying to build.

smarsh
smarsh's picture
Awesome - can you share your

Awesome - can you share your working event handler here, for future users?

bertalan.voros
bertalan.voros's picture
Will do

Hi,

Yes, I will type it up.

It's an event handler for a custom check, so it makes more sense when you have that as well.