| 1234567891011121314151617181920212223242526272829303132333435363738394041 | 
							- #!/usr/bin/env python3
 
- #zammad-service
 
- # -*- encoding: utf-8; py-indent-offset: 4 -*-
 
- # This script if for service-notifications to zammad
 
- # Place this in ~/local/share/check_mk/notifications as your site-user.
 
- # Add the url to send the notifications to as first parameter.
 
- import os
 
- import requests
 
- import sys
 
- def build_context():
 
-     return {
 
-         var[7:]: value
 
-         for (var, value) in os.environ.items()
 
-         if var.startswith("NOTIFY_")
 
-     }
 
- def build_message(ctx):
 
-     data = {
 
-         'event_id': (None, ctx.get('SERVICEPROBLEMID', '')),
 
-         'host': (None, ctx.get('HOSTNAME', '')),
 
-         'hostip': (None, ctx.get('HOSTADDRESS', '')),
 
-         'service': (None, ctx.get('SERVICEDESC', '')),
 
-         'state': (None, ctx.get('SERVICESTATE', '')),
 
-         'text':  (None, ctx.get('SERVICEOUTPUT', '')),
 
-         }
 
-     return data
 
- def main():
 
-     ctx = build_context()
 
-     response =  requests.post(ctx.get("PARAMETER_1"), files=build_message(ctx), verify=False)
 
-     
 
- if __name__ == "__main__":
 
-     try:
 
-         main()
 
-     except Exception as e:
 
-         sys.stderr.write("Unhandled exception: %s\n" % e)
 
-         sys.exit(2)
 
 
  |