Compare commits
2 commits
02454ebd39
...
72cf4e570c
Author | SHA1 | Date | |
---|---|---|---|
Micke Nordin | 72cf4e570c | ||
Micke Nordin | 51a695ed9e |
|
@ -30,7 +30,10 @@ def add_downtime(fqdn: str,
|
||||||
post_url = 'https://{}/thruk/r/hosts/{}/cmd/{}'.format(
|
post_url = 'https://{}/thruk/r/hosts/{}/cmd/{}'.format(
|
||||||
monitor_host, fqdn, action)
|
monitor_host, fqdn, action)
|
||||||
headers = {'X-Thruk-Auth-Key': apikey}
|
headers = {'X-Thruk-Auth-Key': apikey}
|
||||||
requests.post(post_url, data=data, headers=headers)
|
try:
|
||||||
|
requests.post(post_url, data=data, headers=headers)
|
||||||
|
except Exception:
|
||||||
|
print("Failed to add downtime for {}".format(fqdn))
|
||||||
|
|
||||||
|
|
||||||
def remove_downtime(fqdn: str,
|
def remove_downtime(fqdn: str,
|
||||||
|
@ -42,12 +45,15 @@ def remove_downtime(fqdn: str,
|
||||||
get_url = 'https://{}/thruk/r/hosts?name={}&columns=services'.format(
|
get_url = 'https://{}/thruk/r/hosts?name={}&columns=services'.format(
|
||||||
monitor_host, fqdn)
|
monitor_host, fqdn)
|
||||||
headers = {'X-Thruk-Auth-Key': apikey}
|
headers = {'X-Thruk-Auth-Key': apikey}
|
||||||
req = requests.get(get_url, headers=headers)
|
try:
|
||||||
action = 'del_active_service_downtimes'
|
req = requests.get(get_url, headers=headers)
|
||||||
for service in req.json()[0]['services']:
|
action = 'del_active_service_downtimes'
|
||||||
post_url = 'https://{}/thruk/r/services/{}/{}/cmd/{}'.format(
|
for service in req.json()[0]['services']:
|
||||||
monitor_host, fqdn, urllib.parse.quote(service), action)
|
post_url = 'https://{}/thruk/r/services/{}/{}/cmd/{}'.format(
|
||||||
requests.post(post_url, headers=headers)
|
monitor_host, fqdn, urllib.parse.quote(service), action)
|
||||||
|
requests.post(post_url, headers=headers)
|
||||||
|
except Exception:
|
||||||
|
print("Failed to remove downtime for {}".format(fqdn))
|
||||||
|
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
|
|
Loading…
Reference in a new issue