Execute script if host is down

Hello guys,

I want to execute a script if a host goes into down state.
I know there is a event console that do this kind of stuff.
But I don’t see how I can detect via Event-Console if a host is down.
I am using check_mk raw edition.

I also found a tutorial for check_mk using nagios event handler but I am uncertain how to apply this for my problem.

Thanks for your help

I`m doing many things with the Alerthandler

what kind of CMK Version do you use ???

Greets Bernd

The version number is 2.0.0p1 (CRE).

Hallo,
be aware of unexpected problems when reacting with a script and take care to save all informations you need to analyse what happened.

Ralf

I do not understand what you mean to onest.
I don’t want to collect information with this script, I want to fix a problem that occurs from time to time and only check mk notice it.

Ok,
the idea is not to delete for example all logfiles using a scripted restart etc. that may help you to analyse why for a system crashed.
Sometime hints are shown on the screen of a frozen system.
Ralf

No, my problem is just that I don’t know how to trigger the script. If a host goes into the down state.

You can use notifications to trigger a script. I use RHEL so the path is:
/opt/omd/sites/<sitename>/local/share/check_mk/notifications

Any script in the dir can be addressed via a notification. The second line of the script needs to be the name of the script that shows.

#!/bin/bash
# <name here>

That shows up in the “WATO → Notifications → Rule” Notification method (dropdown)
And in that rule you can pass variables from a check, to the script, like “NOTIFY_HOSTNAME”

Then you can use that to kick off a host restart, service restart, or a multitude of other stuff like generate a ticket via another system.

I have rules setup for a bunch of activities.

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.