Skip to content

Commit

Permalink
Merge pull request #77 from autodon/checkmk_v2_opsgenie_integration_a…
Browse files Browse the repository at this point in the history
…pi_v1

support Check_MK v2.x python3 environment
  • Loading branch information
faziletozer authored Jun 24, 2021
2 parents da370bf + bdd0e61 commit 7a3b41b
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions check_mk/opsgenie_api-v1_cmk-v2
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python3
# OpsGenie_APIv1_CMKv2

import json
import os
import requests

def main():
header_type = {'Content-Type':'application/json'}
context = dict([(var[7:], value)
for (var, value) in os.environ.items()
if var.startswith("NOTIFY_")])

if "PARAMETER_1" in context:
opsgenie_api_url = context["PARAMETER_1"]

if "PARAMETER_1" in context.keys():
del context["PARAMETER_1"]
if "PARAMETERS" in context.keys():
del context["PARAMETERS"]
else:
return "No API Key Specified."

try:
req = requests.post(opsgenie_api_url, headers=header_type, data=json.dumps(context))
is_success = True
except:
is_success = False

if is_success:
return "Script finished successfully."
else:
return "Script failed."

main()

0 comments on commit 7a3b41b

Please sign in to comment.