Downtimes set via Api-http or Command Line

Hi,

I don’t see this option in the official documentation.

But Is there any way to activate / deactivate downtime via API-http or command line for example “cmk”?

thus avoiding the use of the graphical interface.

Thx.
Dario.

Hi,
yes there is a way e.g.: Set downtime for 2 hours:

curl --insecure "http://YourCMKHost/YourSite/check_mk/view.py?_do_confirm&_transid=-1&_do_actions=yes&_username=YourUser&_secret=YourSecret&view_name=hoststatus&host=YourTargetHost&_down_2h=2+hours&_down_comment=COMMENT"

Remove the downtime:

curl --insecure "http://YourCMKHost/YourSite/check_mk/view.py?_do_confirm&_transid=-1&_do_actions=yes&_username=YourUser&_secret=YourSecret&view_name=hoststatus&host=YourTargetHost&_down_remove=Remove"

Karl

1 Like

There is a script in $OMD_ROOT/share/doc/check_mk/treasures/downtime that could be used as a starting point on how to talk to the API.

1 Like

You can write the command to the nagios.cmd socket file. See docs here:
https://assets.nagios.com/downloads/nagioscore/docs/externalcmds/cmdinfo.php?command_id=119

1 Like

thanks for sharing, @ways can you explain a little bit more please :slight_smile:

You can use my curses client at gitlab com/larsfp/checkmk-commander

If not the most furureproof solution is kdeutsch’s answer above.

1 Like

Hi,

@r.sander My knowledge of python is quite poor so can I ask you for more information? from what i can see this script is official. there’s no documentation?

For more information I mean an example of using this script.

On the internet I find only a pdf of 2015.
link: https://checkmk.de/download/2015-Konferenz-Treasures.pdf

In which two examples are made:

Set a downtime
./downtime -v -d 10 -c “Check_MK Conference demo” -S DIWWGYFHXGUVLXJQAJKD
sdtcsynomd1

Remove a downtime
./downtime -r -v -d 10 -S DIWWGYFHXGUVLXJQAJKD sdtcsynomd1

but, I get the following error:

@ways I try to see your script. thank you :slight_smile:

thx you all.
Dario.

Hi,

Trying with the string indicated by @kdeutsch

Via http gives me the following message.

image

Why the mistake? In the var/log/apache/error_log i doesen’t see any error.

thx.
Dario.

Hi,
I’ve tested with this string - and it worked:

http://localhost/kurs/check_mk/view.py?_username=automation&_secret=MySecret&_transid=-1&_do_confirm=yes&_do_actions=yes&host=host21&_down_from_now=yes&_down_minutes=30&_down_comment=Test_Downtime&view_name=hoststatus

Karl

2 Likes