Writing to nagios.cmd in Distributed Monitoring

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?

I would suggest to use the web API for that.

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

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.

Hi,
do you know this: https://checkmk.com/cms_livestatus_references.html

Karl

1 Like

Hi @ways

I opened a topic about it log time ago here:

https://forum.checkmk.com/t/create-downtime-host/16814

The Multisite-API is hidden in the legacy documentation: https://checkmk.com/cms_legacy_multisite_automation.html

1 Like

thanks for sharing @r.sander that help me a alot :+1: , 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…?

Aha. Thanks. That worked. Migrating to only use web api!

1 Like

@ways can you Post the solution here for us :flushed:

Thanks

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

Yes, you just “call” a view via URL with output_format=json appended.

1 Like