Last active
April 2, 2019 16:39
-
-
Save mcktr/63040a8110aa5f2c966d2ae164ba4375 to your computer and use it in GitHub Desktop.
Acknowledge host problem through Icinga 2 API using Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import requests, json | |
# change localhost to your Icinga 2 API | |
url = 'https://localhost:5665/v1/actions/acknowledge-problem?type=Host&host=' | |
header = { | |
'Accept': 'application/json' | |
} | |
# adjust author and comment to your needs | |
data = { | |
'author': 'icingaadmin', | |
'comment': 'Global outage. Working on it.' | |
} | |
# Change hostname to the affected host | |
hostname = 'myhostobject' | |
url += hostname | |
print url | |
# verify=False is lazy; better is to check the actual certificate | |
# an example can be found here https://icinga.com/docs/icinga2/latest/doc/12-icinga2-api/#example-api-client-in-python | |
# change auth=('icinga', 'icinga') to your Icinga 2 API credentials | |
r = requests.post(url, headers=header, auth=('icinga', 'icinga'), data=json.dumps(data), verify=False) | |
print r.status_code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment