You will have to place/create the example-script provided yourself on the CMK-Server.
It needs to be placed in (as site-user) in ~/local/share/check_mk/notifications/
then make the script executable ( chmod +x <scriptname>
)
After that you will find it in the pull-down option under the notification method.
To flex my own skills i made a similar way to do this in python, but have not had time to validate/test it.
If you are up for the challenge you can try it out instead of the examples given.
added field is the ip of the host where the alert is happening.
#!/usr/bin/env python3
#zammad-service
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# This script is 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)
Field-test of what the script posts to the defined zammad host/endpoint is (done with a netcat listener):
POST / HTTP/1.1
Host: testbak05.mydomain.tld:443
User-Agent: python-requests/2.28.2
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Content-Length: 636
Content-Type: multipart/form-data; boundary=952c782f3caef0fc53b34353c7072c45
--952c782f3caef0fc53b34353c7072c45
Content-Disposition: form-data; name="event_id"
176837
--952c782f3caef0fc53b34353c7072c45
Content-Disposition: form-data; name="host"
myhost.mydomain.tld
--952c782f3caef0fc53b34353c7072c45
Content-Disposition: form-data; name="hostip"
172.16.0.89
--952c782f3caef0fc53b34353c7072c45
Content-Disposition: form-data; name="service"
NTP Time
--952c782f3caef0fc53b34353c7072c45
Content-Disposition: form-data; name="state"
CRITICAL
--952c782f3caef0fc53b34353c7072c45
Content-Disposition: form-data; name="text"
506 Cannot talk to daemon
--952c782f3caef0fc53b34353c7072c45--