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,
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
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.
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
You can use my curses client at gitlab com/larsfp/checkmk-commander
If not the most furureproof solution is kdeutsch’s answer above.
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
thx you all.
Dario.
Hi,
Trying with the string indicated by @kdeutsch
Via http gives me the following message.
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
Hi,
Thanks, it works @kdeutsch.
What if I wanted to set a time frame instead?.
By running the string:
http://localhost/checkmk_dev/check_mk/view.py_username=automation
&_secret=Mysecret
&_transid=-1
&_do_confirm=yes
&_do_actions=yes
&view_name=hoststatus
&host=host
&_down_custom=Custom+time+range
&_down_from_date=2020-03-31
&_down_from_time=12:30
&_down_to_date=2020-03-31
&_down_to_time=14:30
&_down_comment=test_downtime
&_down_from_now=yes
I get the following error.
Why the mistake?
Dario.
Hi,
Removing the string “&_down_from_now=yes” and it works
Example:
http://localhost/checkmk_dev/check_mk/view.py?_username=automation
_secret=mysecret
_transid=-1
_do_confirm=yes
_do_actions=yes
view_name=hoststatus
host=host
_down_custom=Custom+time+range
_down_from_date=2020-03-31
_down_from_time=12:30
_down_to_date=2020-03-31
_down_to_time=14:30
_down_comment=test_downtime
I close this topic.
Thx to all.
Dario.
Hi Dario,
you’re welcome
Karl
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.