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
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
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
I didn't know about this script. Thanks. I was about to write something similar, but what has always stopped me is that it seems (from the documentation) that for script alert rules, Xymon supports only one recipient. It my reading correct?
We use macros like
PAGER_GROUP = email1 at domain.com email2 at domain.com email3 at domain.com
And that works great for the MAIL rules.
How would a SCRIPT rule handle this? Would the script be called multiple times?
Thanks again,
Glauber
(sorry if my email shows up as an attachment - I'm still trying to figure out what is causing this)
Hi,
alerts.cfg invokes any script with the string specified after the script path as parameter.
From the man page:
SCRIPT /path/to/script recipientID Recipient that invokes a script. This takes two parameters: The script filename, and the recipient that gets passed to the script.
I see no reason why receipientID could not contain a list of recipient, although you'd probably have to put some logic into your script to split/parse them, something like this:
In your alerts.cfg: ########## SCRIPT /path/to/script.sh 'mail1 at domain.com;mail2 at domain.com' ##########
In the script: ########### #/bin/bash
IFS=";" recipients="$1"
for r in "$recipients"; do send-stuff-to "$r" done ##########
Good luck with escaping the Teams webhook URIs, though :)
Best regards, Fabian Wendlandt
-----Urspr?ngliche Nachricht----- Von: Ribeiro, Glauber <glauber.ribeiro at experian.com> Gesendet: Dienstag, 24. M?rz 2020 20:26 An: Fabian Wendlandt <fabian.wendlandt at innowerk-it.de>; 'Becker Christian' <christian.becker at rhein-zeitung.net> Cc: xymon at xymon.com Betreff: RE: email add-on other than html_mail.pl?
I didn't know about this script. Thanks. I was about to write something similar, but what has always stopped me is that it seems (from the documentation) that for script alert rules, Xymon supports only one recipient. It my reading correct?
We use macros like
PAGER_GROUP = email1 at domain.com email2 at domain.com email3 at domain.com
And that works great for the MAIL rules.
How would a SCRIPT rule handle this? Would the script be called multiple times?
Thanks again,
Glauber
(sorry if my email shows up as an attachment - I'm still trying to figure out what is causing this)
Scot Kreienkamp | Senior Systems Engineer | La-Z-Boy Corporate One La-Z-Boy Drive | Monroe, Michigan 48162 | * 734-384-6403 | | * 1-734-915-1444 | * Scot.Kreienkamp at la-z-boy.com www.la-z-boy.com<http://www.la-z-boy.com> | facebook.com/lazboy<http://facebook.com/lazboy> | twitter.com/lazboy<http://twitter.com/lazboy> | youtube.com/lazboy<http://youtube.com/lazboy> [cid:4C-lzbVertical_Tag_400px_d8b9412e-f3ea-46a1-99dc-a7c57261e11e.jpg] From: Xymon <xymon-bounces at xymon.com> On Behalf Of Becker Christian Sent: Tuesday, March 24, 2020 11:34 AM To: xymon at xymon.com Subject: [Xymon] email add-on other than html_mail.pl?
ATTENTION: This email was sent to La-Z-Boy from an external source. Be vigilant when opening attachments or clicking links. 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 [Scot Kreienkamp]
Here's a simple HTML email template I wrote in bash script a few years ago. You can customize it to your needs quite easily.
#!/bin/bash
SENDEMAIL="/usr/sbin/sendmail -f xymon at la-z-boy.com -t" EMBOUND=asdf1234
$SENDEMAIL << EOF To: ${RCPT} From: xymon at yourdomain.com Subject: ${SUBJECT} Content-Type: multipart/related; boundary=${EMBOUND}; type="Text/HTML" MIME-Version: 1.0 --${EMBOUND} Content-Type: text/html; charset=US-ASCII
<html> <body>
<pre> Pre-formatted text here </pre>
HTML here
</body> </html>
EOF
This message is intended only for the individual or entity to which it is addressed. It may contain privileged, confidential information which is exempt from disclosure under applicable laws. If you are not the intended recipient, you are strictly prohibited from disseminating or distributing this information (other than to the intended recipient) or copying this information. If you have received this communication in error, please notify us immediately by e-mail or by telephone at the above number. Thank you.
participants (4)
-
christian.becker@rhein-zeitung.net
-
fabian.wendlandt@innowerk-it.de
-
glauber.ribeiro@experian.com
-
Scot.Kreienkamp@la-z-boy.com