Is it possible to change state with an eventscript?


#1

Hi

I need to change the state from HARD to SOFT or OK.
Is it possible to do that from an event in a service?

My problem is that when I am monitoring a logfile I want a notification every hit. Lets say the monitorscript find two patterns that matches, it sends me a notification in a mail with all matched lines (I use $LONGSERVICEOUTPUT$ instead of $SERVICEOUTPUT$) . Now the service is in CRIT and HARD state. Next minute another error appears in the monitored log but I will not be notified on that. I want all the hits to be sent to me in a mail instead of logging into the server and check it manually) . So if I change the state in the service from HARD to SOFT or OK, next hit in the logfile will cause the state to change from OK/SOFT to HARD and notify me again.

My idea was this:
define service {
use local-service
host_name localhost
service_description Check_logfiles
check_command check_logfiles.pl
max_check_attempts 1
check_interval 1
event_handler
}

Kindly Regards
Claes


#2

check the is_volatile option, i think it’s what you’re looking for.


#3

Thanks Luca

It seems that is_volatile will do the work for me.

I have solved for the momemt by letting an event_handler run an external command from the example at nagios.org/developerinfo/ext … and_id=114

/bin/printf “%lu] PROCESS_SERVICE_CHECK_RESULT;host1;service1;0;OK- Everything Looks Great\n” $now > $commandfile

But is_volatile looks like a clean and more correct solution in every aspect.

Regards
Claes