ways
(Ways)
March 21, 2020, 6:26pm
1
Hi
I’m attempting to write a curses based interface for day-to-day checkmk usage: https://gitlab.com/larsfp/checkmk-commander
I hoped that I could write all commands (like ACKNOWLEDGE_SVC_PROBLEM) to the master nagios.cmd, but it seems I can not. Is there another way to do it, or do I have to connect to each and every node via ssh to access the nagios sockets?
r.sander
(Robert Sander)
March 21, 2020, 7:04pm
2
I would suggest to use the web API for that.
ways
(Ways)
March 21, 2020, 9:36pm
3
Thanks, but from https://checkmk.com/cms_web_api.html and https://checkmk.com/cms_web_api_references.html it seems to only support WATO stuff, like add and edit hosts. Not ack, downtime, add comment, which are what I’m looking for.
1 Like
ways
(Ways)
March 21, 2020, 9:53pm
4
Ok, I found some bits around the net about using the URLs seen in the web interface, but with output_format=cvs or json
Like this:
https://example.com/front/check_mk/view.py?is_service_acknowledged=0&view_name=svcproblems
Will experiment and see if I can run my commands like that. I’ll post the results.
kdeutsch
(Karl Deutsch)
March 22, 2020, 9:02am
5
1 Like
neeloj
(Neeloj A.)
March 22, 2020, 9:48am
6
r.sander
(Robert Sander)
March 22, 2020, 11:58am
7
The Multisite-API is hidden in the legacy documentation: https://checkmk.com/cms_legacy_multisite_automation.html
1 Like
neeloj
(Neeloj A.)
March 22, 2020, 2:01pm
8
thanks for sharing @r.sander that help me a alot , is there a way to get a check status via api, e.g if its crit/warn/ok I want use that in Bash/Python…?
ways
(Ways)
March 22, 2020, 10:11pm
9
Aha. Thanks. That worked. Migrating to only use web api!
1 Like
neeloj
(Neeloj A.)
March 23, 2020, 6:43am
10
@ways can you Post the solution here for us
Thanks
ways
(Ways)
March 23, 2020, 7:48am
11
Hi. Of course. My solution was to use the web API. The exact implementation can be seen here:
The link should be permanent, but including a copy/paste of it. It’s python code making a web request.
r = requests.get(self.checkmkhost + \
'check_mk/view.py' + \
'?_transid=-1&_do_actions=yes&view_name=service&_do_confirm=yes' + \
'&host=' + host + \
'&service=' + service + \
'&_acknowledge=Acknowledge&_ack_sticky=on&_ack_notify=on' + \
'&_ack_comment=' + comment + \
'&output_format=json&_username=' + \
self.checkmkusername + \
'&_secret=' + \
self.checkmksecret)
1 Like
r.sander
(Robert Sander)
March 23, 2020, 8:38am
12
Yes, you just “call” a view via URL with output_format=json appended.
1 Like
system
(system)
Closed
April 22, 2020, 6:38pm
13
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.