API alert integration with FreshService ITSM

I am trying to replicate our Nagios setup for sending notification alerts to our ITSM tool for automated ticket logging and management.

FreshService has a pre-configured Nagios plugin, and how-to guide to set it up, and this has been working for us nicely. However we are migrating away from Nagios to Checkmk, and would like to effectively replicate this setup. I am struggling however, as I am so lost in API hell!

Here is the Nagios guide: Integrate Nagios XI with Freshservice Alert Management : Freshservice

Can anyone see a way we can do this exact same setup in Checkmk? I want to avoid using Emails if possible and I dont understand how to setup a custom check. I just dont know enough about API’s.

Apparently if the Nagios pre-configured integration doesnt work, we can setup our own custom webhooks to send to FreshService, but this requires the alert JSON to even begin setting up, and I cannot see a way to add a custom alert destination in CheckMK - there are only preconfigured settings.

Help!

For reference, I basically want to setup these commands in Checkmk:

curl -X POST -H "Authorization: <api-auth-token>" -H "Content-Type: application/json" --data "{\"metric_name\": \"Availability\", \"hostname\": \"$HOSTNAME$\", \"message\": \"$NOTIFICATIONTYPE$ - $HOSTNAME$ is $HOSTSTATE$\", \"ip_address\": \"$HOSTADDRESS$\", \"severity\": \"$HOSTSTATE$\", \"event_id\": \"$HOSTEVENTID$\", \"output\": \"$HOSTOUTPUT$\", \"perf_data\": \"$HOSTPERFDATA$\", \"action_url\": \"$HOSTACTIONURL$\", \"check_command\": \"$HOSTCHECKCOMMAND$\", \"problem_id\": \"$HOSTPROBLEMID$\" , \"long_datetime\": \"$LONGDATETIME$\", \"notification_comment\": \"$NOTIFICATIONCOMMENT$\", \"notification_type\": \"$NOTIFICATIONTYPE$\", \"contact_name\": \"$CONTACTNAME$\" }" <api-url>

curl -X POST -H "Authorization: <api-auth-token>" -H "Content-Type: application/json" --data "{\"metric_name\": \"$SERVICEDESC$\", \"hostname\": \"$HOSTNAME$\", \"message\": \"$NOTIFICATIONTYPE$ - $SERVICEDESC$\", \"description\": \"$SERVICEDESC$\", \"ip_address\": \"$HOSTADDRESS$\", \"severity\": \"$SERVICESTATE$\", \"event_id\": \"$SERVICEEVENTID$\", \"output\": \"$SERVICEOUTPUT$\", \"perf_data\": \"$SERVICEPERFDATA$\", \"action_url\": \"$SERVICEACTIONURL$\", \"check_command\": \"$SERVICECHECKCOMMAND$\", \"problem_id\": \"$SERVICEPROBLEMID$\" , \"long_datetime\": \"$LONGDATETIME$\", \"notification_comment\": \"$NOTIFICATIONCOMMENT$\", \"notification_type\": \"$NOTIFICATIONTYPE$\", \"contact_name\": \"$CONTACTNAME$\" }" <api-url>

I can then use the same Nagios pre-built plugin, as the JSON output will be the same - correct me if I’m wrong here! But I cannot find any way to add these commands as a notification type.

Well, after some serious head scratching and reading, then re-reading of the Checkmk documentation on notifications (specifically the custom scripts/commands folder) I have an idea I want some help refining…

Basically I think that if I create 2 scripts in the ~/local/share/check_mk/notifications folder (one for host notifications, one for service, same as Nagios), and use the following scripts:

Hosts:

#!/bin/bash
# FreshService Host Notification

curl -X POST -H "Authorization: auth-key <key>" -H "Content-Type: application/json" --data "{\"metric_name\": \"Availability\", \"hostname\": \"$HOSTNAME$\", \"message\": \"$NOTIFICATIONTYPE$ - $HOSTNAME$ is $HOSTSTATE$\", \"ip_address\": \"$HOSTADDRESS$\", \"severity\": \"$HOSTSTATE$\", \"event_id\": \"$HOSTEVENTID$\", \"output\": \"$HOSTOUTPUT$\", \"perf_data\": \"$HOSTPERFDATA$\", \"action_url\": \"$HOSTACTIONURL$\", \"check_command\": \"$HOSTCHECKCOMMAND$\", \"problem_id\": \"$HOSTPROBLEMID$\" , \"long_datetime\": \"$LONGDATETIME$\", \"notification_comment\": \"$NOTIFICATIONCOMMENT$\", \"notification_type\": \"$NOTIFICATIONTYPE$\", \"contact_name\": \"$CONTACTNAME$\" }" <api-url>

Services:

#!/bin/bash
# FreshService Service Notification

curl -X POST -H "Authorization: auth-key <key>" -H "Content-Type: application/json" --data "{\"metric_name\": \"$SERVICEDESC$\", \"hostname\": \"$HOSTNAME$\", \"message\": \"$NOTIFICATIONTYPE$ - $HOSTNAME$ - $SERVICEDESC$\", \"description\": \"$SERVICEDESC$\", \"ip_address\": \"$HOSTADDRESS$\", \"severity\": \"$SERVICESTATE$\", \"event_id\": \"$SERVICEEVENTID$\", \"output\": \"$SERVICEOUTPUT$\", \"perf_data\": \"$SERVICEPERFDATA$\", \"action_url\": \"http://nagios/$SERVICEACTIONURL$\", \"check_command\": \"$SERVICECHECKCOMMAND$\", \"problem_id\": \"$SERVICEPROBLEMID$\" , \"long_datetime\": \"$LONGDATETIME$\", \"notification_comment\": \"$NOTIFICATIONCOMMENT$\", \"notification_type\": \"$NOTIFICATIONTYPE$\", \"notification_url\": \"http://nagios/adagios/status/detail?host_name=$HOSTNAME$&service_description=$SERVICEDESC$&backend=\", \"contact_name\": \"$CONTACTNAME$\" }" <api-url>

Will this work? The fields are already mapped in FreshService using the pre-built plugin, so as long as Checkmk is outputting the same JSON (assuming that it is, due to using OMD on Nagios too), then this should work. I can see these now appear on my notification method lists, and I’m thinking it will work if the JSON matches!

Thoughts/suggestions??

Well it kinda works, but the data is all messed up. I configured it, added the API keys and URL’s, and ran some fake critical checks - the tickets got logged in FreshService, so yay! However looks like the JSON is all out of whack, as the data was unintelligible.

Any ideas how to clean this up? How can I view the JSON output of a check?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.