Advanced HTML Mail Alert Perl script
list Helge Jacobsen
Hi all, there is an old html_mail.pl script on https://wiki.xymonton.org/doku.php/alerts:html_mail1.2 . I like it, but I miss some features. So I take this script and make some updates and modifications: Different Mail Subject depending on Errorlevel Duration Time for any Message Flapping Status included in Subject and Mailtext Colorstatus depends on BBALPHAMSG for Recover Status. Nesessary if you using yellow for OKCOLOR Add Enable/Disable Mail Subject / Removing Backgroundcolor: not accessible in Outlook and makes mails in Thunderbird unreadable Fix for disable "until okay": Convert XYmon Recover Bodytext "for -1 minutes" to "until okay" maybe it is useful for someone here in the community but nobody knows it ? It is running on Xymon 4.3.26 and tested with Outlook 2010 and Thunderbird 38.6.0 And you found it here: https://wiki.xymonton.org/doku.php/alerts:html_mail2.0 regards Helge
list Andrey Chervonets
I have tested it on xymon 4.3.17 - working good, but some notes: It generated at mail body start the link like: See http://hostname/xymon-cgi/bb-hostsvc.sh?HOST=target_host&SERVICE=disk But there is no bb-hostsvc.sh on server. But instead we have svcstatus.sh . Whether it was changes to bb-hostsvc.sh in latest xymon versions? Or perl sript version on xymonton is just fork of addon for older versions ? Best regards, Andrey Chervonets SIA CoMinder http://www.cominder.eu/
list Andrey Chervonets
Another note: the link generated does not reflect real web-server URL. For example, we use: HTTPS instead of HTTP special port, instead of default one. It would be nice script could read UTL starter from some config file
▸
Best regards, Andrey Chervonets SIA CoMinder http://www.cominder.eu/ From: Andrey Chervonets/Cominder/LV To: xymon at xymon.com Date: 23.03.2016 19:20 Subject: Re: Advanced HTML Mail Alert Perl script I have tested it on xymon 4.3.17 - working good, but some notes: It generated at mail body start the link like: See http://hostname/xymon-cgi/bb-hostsvc.sh?HOST=target_host&SERVICE=disk But there is no bb-hostsvc.sh on server. But instead we have svcstatus.sh . Whether it was changes to bb-hostsvc.sh in latest xymon versions? Or perl sript version on xymonton is just fork of addon for older versions ? Best regards, Andrey Chervonets SIA CoMinder http://www.cominder.eu/
list Brandon Dale
Both those changes would be nice, I know in one of the older versions I ended up just changing the https and bb-hostvc reference in the script.
I also noticed:
1. Looks better if you add a new line character after the message and before the event duration bit at the bottom.
<PRE>$BBHTMLMSG\n\n$RECOEVENT Event Duration Time: $DOWNSECS Secs\n</PRE>\n</FONT>\n</BODY>";
2. I don't know perl at all so this might just be me not understanding how this should work, in the changes for 2.0 "..Colorstatus depends on BBALPHAMSG for Recover Status.." how does this work ? I tried it on a test machine against the svcs test where red is bad green is good and I got two emails with subjects like this:
Xymon [846968] testserver01.svcs CRITICAL (RED)
Xymon [] testserver01.svcs Recovered to (TESTSERVER01:SVCS)
I didn't quite understand the subject is the second email, is the idea that the colour has been removed so it doesn't confuse people if the OK colour is for example yellow?
3. Might not be something others want as It's pretty dependant on the setup, but in one of the older versions we made some changes to the subject line so it would say CRITICAL for red WRANING for yellow STOPPED REPORTING for purple etc as from memory it would use the word CRITICAL by default for most things which we didn't like. I think (not knowing perl syntax, and spending only about 5 minutes) got a similar thing working here
Changed my $SUBJECT="CRITICAL"; to $SUBJECT="Unkown Status";
Under sub parse_info added:
if($BBCOLORLEVEL eq "red"){$SUBJECT="CRITICAL"}
if($BBCOLORLEVEL eq "yellow"){$SUBJECT="WARNING"}
if($BBCOLORLEVEL eq "purple"){$SUBJECT="Stopped Reporting"}
Also just wanted to say thanks for uploading this Helge it's a really nice improvement especially for people using outlook.
Regards,
Brandon.
▸
From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Andrey Chervonets Sent: Thursday, 24 March 2016 4:26 AM To: Andrey Chervonets <user-e7fb5c02322c@xymon.invalid> Cc: xymon at xymon.com Subject: Re: [Xymon] Advanced HTML Mail Alert Perl script Another note: the link generated does not reflect real web-server URL. For example, we use: HTTPS instead of HTTP special port, instead of default one. It would be nice script could read UTL starter from some config file Best regards, Andrey Chervonets SIA CoMinder http://www.cominder.eu/ From: Andrey Chervonets/Cominder/LV To: xymon at xymon.com<mailto:xymon at xymon.com> Date: 23.03.2016 19:20 Subject: Re: Advanced HTML Mail Alert Perl script I have tested it on xymon 4.3.17 - working good, but some notes: It generated at mail body start the link like: See http://hostname/xymon-cgi/bb-hostsvc.sh?HOST=target_host&SERVICE=disk But there is no bb-hostsvc.sh on server. But instead we have svcstatus.sh . Whether it was changes to bb-hostsvc.sh in latest xymon versions? Or perl sript version on xymonton is just fork of addon for older versions ? Best regards, Andrey Chervonets SIA CoMinder http://www.cominder.eu/
list Helge Jacobsen
Hello Brandon, hello Andrey, thank you for the feedback, i will check it and try to patch the script again. ;-) But I need a little time, because a I am next week on vacation. @ Brandon: That's interest with the issue with the subject. My idea behind this little hack was to print out the color from the xymon message. We need this, because in our monitoring system it is okay when the alert goes from red to yellow. So and in the original script, I get a green message back :( And by the way, I also cant understood the second mail. Happy Easter regards Helge Nur tote Fische schwimmen im Strom ....
▸
From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Brandon Dale Sent: Wednesday, March 23, 2016 9:51 PM To: Andrey Chervonets Cc: xymon at xymon.com Subject: Re: [Xymon] Advanced HTML Mail Alert Perl script Both those changes would be nice, I know in one of the older versions I ended up just changing the https and bb-hostvc reference in the script. I also noticed: 1. Looks better if you add a new line character after the message and before the event duration bit at the bottom. <PRE>$BBHTMLMSG\n\n$RECOEVENT Event Duration Time: $DOWNSECS Secs\n</PRE>\n</FONT>\n</BODY>"; 2. I don't know perl at all so this might just be me not understanding how this should work, in the changes for 2.0 "..Colorstatus depends on BBALPHAMSG for Recover Status.." how does this work ? I tried it on a test machine against the svcs test where red is bad green is good and I got two emails with subjects like this: Xymon [846968] testserver01.svcs CRITICAL (RED) Xymon [] testserver01.svcs Recovered to (TESTSERVER01:SVCS) I didn't quite understand the subject is the second email, is the idea that the colour has been removed so it doesn't confuse people if the OK colour is for example yellow? 3. Might not be something others want as It's pretty dependant on the setup, but in one of the older versions we made some changes to the subject line so it would say CRITICAL for red WRANING for yellow STOPPED REPORTING for purple etc as from memory it would use the word CRITICAL by default for most things which we didn't like. I think (not knowing perl syntax, and spending only about 5 minutes) got a similar thing working here Changed my $SUBJECT="CRITICAL"; to $SUBJECT="Unkown Status"; Under sub parse_info added: if($BBCOLORLEVEL eq "red"){$SUBJECT="CRITICAL"} if($BBCOLORLEVEL eq "yellow"){$SUBJECT="WARNING"} if($BBCOLORLEVEL eq "purple"){$SUBJECT="Stopped Reporting"} Also just wanted to say thanks for uploading this Helge it's a really nice improvement especially for people using outlook. Regards, Brandon. From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Andrey Chervonets Sent: Thursday, 24 March 2016 4:26 AM To: Andrey Chervonets <user-e7fb5c02322c@xymon.invalid<mailto:user-e7fb5c02322c@xymon.invalid>> Cc: xymon at xymon.com<mailto:xymon at xymon.com> Subject: Re: [Xymon] Advanced HTML Mail Alert Perl script Another note: the link generated does not reflect real web-server URL. For example, we use: HTTPS instead of HTTP special port, instead of default one. It would be nice script could read UTL starter from some config file Best regards, Andrey Chervonets SIA CoMinder http://www.cominder.eu/ From: Andrey Chervonets/Cominder/LV To: xymon at xymon.com<mailto:xymon at xymon.com> Date: 23.03.2016 19:20 Subject: Re: Advanced HTML Mail Alert Perl script I have tested it on xymon 4.3.17 - working good, but some notes: It generated at mail body start the link like: See http://hostname/xymon-cgi/bb-hostsvc.sh?HOST=target_host&SERVICE=disk But there is no bb-hostsvc.sh on server. But instead we have svcstatus.sh . Whether it was changes to bb-hostsvc.sh in latest xymon versions? Or perl sript version on xymonton is just fork of addon for older versions ? Best regards, Andrey Chervonets SIA CoMinder http://www.cominder.eu/
list Helge Jacobsen
Hi Andrey, on your topic : But instead we have svcstatus.sh . Whether it was changes to bb-hostsvc.sh in latest xymon versions? Or perl sript version on xymonton is just fork of addon for older versions ? It is my fault, the bb-hostsvc.sh comes from the Perl script, and it's an old one ;-) I fix it in the next version :) Thank you for your mail. regards Helge
▸
From: Andrey Chervonets/Cominder/LV To: xymon at xymon.com<mailto:xymon at xymon.com> Date: 23.03.2016 19:20 Subject: Re: Advanced HTML Mail Alert Perl script I have tested it on xymon 4.3.17 - working good, but some notes: It generated at mail body start the link like: See http://hostname/xymon-cgi/bb-hostsvc.sh?HOST=target_host&SERVICE=disk But there is no bb-hostsvc.sh on server. But instead we have svcstatus.sh . Whether it was changes to bb-hostsvc.sh in latest xymon versions? Or perl sript version on xymonton is just fork of addon for older versions ? Best regards, Andrey Chervonets SIA CoMinder http://www.cominder.eu/