katprep icon indicating copy to clipboard operation
katprep copied to clipboard

Implement check_mk support

Open stdevel opened this issue 6 years ago • 5 comments

It would be handy to have check_mk support for katprep! 👍

stdevel avatar May 24 '18 12:05 stdevel

Some hints for API calls:

  • https://mathias-kettner.de/cms_web_api.html
  • https://mathias-kettner.de/cms_web_api_references.html
  • https://mathias-kettner.de/checkmk_multisite_automation.html

stdevel avatar Jul 19 '18 19:07 stdevel

Some TODOs:

  • [ ] implement CheckMkAPIClient.py
  • [ ] implement unit tests and cookbook for creating check_mk vagrant boxes

stdevel avatar Nov 24 '18 15:11 stdevel

  1. As a workaround, before it's implemented, can be nagios/icinga url https://${CMK_FQDN}/${CMK_SITE_NAME}/nagios/cgi-bin/status.cgi with NagiosCGIClient
  2. Here are some curl snippets:
output_format=python is maybe reasonable
#show all hosts
curl -ѕ 'https://'${CMK_FQDN}/${CMK_SITE_NAME}'/check_mk/webapi.py?action=get_all_hosts&output_format=json&_username='${CMK_USERNAME}'&_secret='${CMK_APIKEY} |jq -r .
#get all services of one host
curl -s 'https://'${CMK_FQDN}/${CMK_SITE_NAME}'/check_mk/view.py?_do_confirm=yes&_transid=-1&_do_actions=yes&view_name=host&site='${CMK_SITE_NAME}'&output_format=json&_username='${CMK_USERNAME}'&host='${CMK_AFFECTED_HOST}'&_secret='${CMK_APIKEY}  |jq -r '.[] | tostring'
#downtime for 3 minutes recursiv from now
curl -s 'https://'${CMK_FQDN}/${CMK_SITE_NAME}'/check_mk/view.py?_do_confirm=yes&_transid=-1&_do_actions=yes&host='${CMK_AFFECTED_HOST}'&view_name=hoststatus&site=&_down_comment=reboot&_down_from_now=1&_down_minutes=3&_include_childs=1&_include_childs_recurse=1&output_format=json&_username='${CMK_USERNAME}'&_secret='${CMK_APIKEY}
#downtime for 3 minutes recursiv flexible for next hour
curl -s 'https://'${CMK_FQDN}/${CMK_SITE_NAME}'/check_mk/view.py?_do_confirm=yes&_transid=-1&_do_actions=yes&host='${CMK_AFFECTED_HOST}'&view_name=hoststatus&site=&_down_comment=reboot&_down_comment=reboot&_down_from_now=1&_down_minutes=60&_down_flexible=1&_down_duration=00:03&_include_childs=1&_include_childs_recurse=1&output_format=json&_username='${CMK_USERNAME}'&_secret='${CMK_APIKEY}
#remove host downtime
curl -s 'https://'${CMK_FQDN}/${CMK_SITE_NAME}'/check_mk/view.py?_do_confirm=yes&_transid=-1&_do_actions=yes&host='${CMK_AFFECTED_HOST}'&view_name=downtimes_of_host&site=&_remove_downtimes=Remove&output_format=json&_username='${CMK_USERNAME}'&_secret='${CMK_APIKEY}

gratuxri avatar Aug 11 '19 20:08 gratuxri

Awesome, thank you very much for sharing @gratuxri! Looking forward to implement it soon.

stdevel avatar Aug 13 '19 08:08 stdevel

There is new REST based API for CheckMK: https://docs.checkmk.com/master/de/rest_api.html It uses OpenAPI and creating a client should be very straightforward.

okin avatar Mar 14 '22 18:03 okin