stdevel / katprep

Python toolkit for automating system maintenance and generating patch reports along with Foreman/Katello and Red Hat Satellite 6.x
GNU General Public License v3.0
35 stars 6 forks source link

Implement check_mk support #45

Open stdevel opened 6 years ago

stdevel commented 6 years ago

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

stdevel commented 6 years ago

Some hints for API calls:

stdevel commented 5 years ago

Some TODOs:

gratuxri commented 5 years ago
  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}
stdevel commented 5 years ago

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

okin commented 2 years ago

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.