[Xymon] email add-on other than html_mail.pl?
Fabian Wendlandt
fabian.wendlandt at innowerk-it.de
Tue Mar 24 16:55:17 CET 2020
Hi Christian,
I'm using the following setup to post Xymon messages to an incoming webhook of a Teams channel.
Create a bash script send-teamsnotification.sh, replace the webhook URL and the path to the json template:
###########################################################
#!/bin/bash
# Incoming webhook of the teams channel
URI='https://outlook.office.com/webhook/<some-long-uid>@<another-uid>/IncomingWebhook/<one-more-uid>/<the-final-uid>'
# Prepend newlines with three spaces to display correctly in teams
BBALPHAMSG="${BBALPHAMSG//$'\n'/' \n'}"
# Replace variables in the json template (replace the path to the template)
TMPFILE=$(mktemp)
envsubst < /path/to/teamsmsg.json > "$TMPFILE"
# Post message to teams channel
curl -X POST -H 'Content-Type: application/json' -d @${TMPFILE} "$URI"
rm -f $TMPFILE
###########################################################
Put the teamsmsg.json template somewhere on your xymon host, replace the Xymon hostname with your own:
###########################################################
{
"title": "Alert for $BBHOSTSVC",
"sections": [
{
"activitySubtitle": "$BBHOSTSVC is $BBCOLORLEVEL",
"activityImage": "https://<xymon-hostname>/gifs/${BBCOLORLEVEL}.gif",
"activityTitle": "$BBHOSTSVC",
"activityText": "Status of service $BBSVCNAME on $BBHOSTNAME changed to $BBCOLORLEVEL"
},
{
"facts": [
{
"value": "$BBHOSTNAME",
"name": "Hostname"
},
{
"value": "$BBSVCNAME",
"name": "Service"
},
{
"value": "$BBCOLORLEVEL",
"name": "Color"
},
{
"value": "$BBALPHAMSG",
"name": "Message"
}
],
"title": "Details"
}
],
"potentialAction": [
{
"@context": "http://schema.org",
"name": "Click here to visit the status page",
"target": [
"http://<xymon-hostname>/xymon-cgi/svcstatus.sh?HOST=${BBHOSTNAME}&SERVICE=${BBSVCNAME}"
],
"@type": "ViewAction"
}
],
"text": "Status of service $BBSVCNAME on $BBHOSTNAME changed to $BBCOLORLEVEL"
}
###########################################################
Configure alerts.cfg to send alerts to a script recipient (the parameter 'param' is just there because Xymon expects it, it has no effect), replace the path to the script:
###########################################################
HOST=hostname.fqdn.com SERVICE=http COLOR=red
SCRIPT /path/to/send-teamsnotification.sh param FORMAT=PLAIN
###########################################################
The resulting notification includes animated gifs of the status color, a clickable button with a link to the service page and includes an expendable status message.
You're Xymon host must be reachable via https, otherwise the gif won't display.
Best regards,
Fabian Wendlandt
Von: Xymon <xymon-bounces at xymon.com> Im Auftrag von Becker Christian
Gesendet: Dienstag, 24. März 2020 16:34
An: xymon at xymon.com
Betreff: [Xymon] email add-on other than html_mail.pl?
Hello to the list,
i'm looking for another email add-on to Xymon (or another script) other than html_mail.pl which I'm currently using.
The html_mail.pl works fine, but now I'm in the situation to send emails to a MS Teams subchannel, and the result is useless, because it's totally mis-formatted in MS Teams.
I tried using the Xymon built-in mail function without html_mail.pl, but this is also not really nice, I'ld like to have at least the red / yellow / green icons together with a black background.
My knowledge isn't good enough to modify html_mail.pl to my needs.
Any idea?
Stay at home - stay healthy!
Best regards from Germany
Christian
More information about the Xymon
mailing list