<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none"><!--P{margin-top:0;margin-bottom:0;} @font-face
        {font-family:"Cambria Math"}
@font-face
        {font-family:Calibri}
@font-face
        {font-family:Tahoma}
@font-face
        {font-family:Consolas}
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif"}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline}
pre
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New"}
span.HTMLPreformattedChar
        {font-family:Consolas}
span.EmailStyle19
        {font-family:"Calibri","sans-serif";
        color:#1F497D}
.MsoChpDefault
        {}
@page WordSection1
        {margin:1.0in 1.0in 1.0in 1.0in}
div.WordSection1
        {}--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>I've had a lot of problems with these alert rules - often it is trial and error to determine what combination of parameters works. At times I had to just write a separate rule for the exceptional condition, even though this adds to complexity of alerts.cfg.
</p>
<p><br>
</p>
<p>I wrote this (rough & ready) script to speed testing - I find it helpful to test small adjustments to rules and as a final check/audit to make sure everything is actually alerting when you think it should. Of course you'll need to adjust the times to suit
 your schedule...<br>
</p>
<p><br>
</p>
<p>if [ -z "$1" ]<br>
then<br>
        echo testalerts.sh hostname-in-hosts-cfg  test  colour<br>
        exit 1<br>
else<br>
        host=$1<br>
fi<br>
if [ -z "$2" ]<br>
then<br>
        test=""<br>
else<br>
        test=$2<br>
fi<br>
if [ -z "$3" ]<br>
then<br>
        COLOUR="red"<br>
else<br>
        COLOUR=$3<br>
fi<br>
<br>
# before hours = 1435005600<br>
# work time = 1435042049<br>
# after hours early = 1435053556<br>
# after hours late = 1435063556<br>
# weekend daytime = 1434770000<br>
# weekend night = 1434799000<br>
<br>
for t in 1435005600 1435042049 1435053556 1435063556 1434770000 1434799000<br>
do<br>
        when=`perl -e "print scalar localtime $t;"`<br>
        echo "<br>
<br>
<br>
Testing $host for $test for duration=1 minute at $when<br>
"<br>
        # --config=xxxxx  to test non-production alerts.cfg<br>
        xymond_alert --test $host $test --color=$COLOUR --duration=1 --time=$t | egrep " alert |\*\*\*"<br>
        echo "<br>
<br>
<br>
Testing $host for $test for duration=15 minutes at $when<br>
"<br>
        xymond_alert --test $host $test --color=$COLOUR --duration=15 --time=$t | egrep " alert |\*\*\*"<br>
done<br>
</p>
<p><br>
</p>
<div style="color: rgb(33, 33, 33);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Xymon <xymon-bounces@xymon.com> on behalf of Root, Paul T <Paul.Root@CenturyLink.com><br>
<b>Sent:</b> Friday, 17 February 2017 4:33 AM<br>
<b>To:</b> 'Erik'; xymon@xymon.com<br>
<b>Subject:</b> Re: [Xymon] Limiting repeated messages</font>
<div> </div>
</div>
<div>
<div class="WordSection1">
<p class="MsoNormal"><font size="2" face="Calibri" color="#1f497d"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D">That’s what I started with, and that doesn’t work.  Script doesn’t acknowledge the DURATION or REPEAT keywords.
</span></font></p>
<p class="MsoNormal"><font size="2" face="Calibri" color="#1f497d"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D"> </span></font></p>
<div style="border:none; border-top:solid #B5C4DF 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><font size="2" face="Tahoma"><span style="font-size:10.0pt; font-family:"Tahoma","sans-serif"; font-weight:bold">From:</span></font></b><font size="2" face="Tahoma"><span style="font-size:10.0pt; font-family:"Tahoma","sans-serif""> Xymon
 [mailto:xymon-bounces@xymon.com] <b><span style="font-weight:bold">On Behalf Of </span>
</b>Erik<br>
<b><span style="font-weight:bold">Sent:</span></b> Friday, February 10, 2017 7:26 AM<br>
<b><span style="font-weight:bold">To:</span></b> xymon@xymon.com<br>
<b><span style="font-weight:bold">Subject:</span></b> Re: [Xymon] Limiting repeated messages</span></font></p>
</div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt"> </span></font></p>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt">Using what you'd provided, here's what I'd put in your alerts.cfg</span></font></p>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt"> </span></font></p>
</div>
<div>
<pre style="white-space:pre-wrap"><font size="2" face="Courier New" color="black"><span style="font-size:10.0pt; color:black">HOST=NMSRep SERVICE=LogMasterErr,NMSRepScheduler,NMSRepTask,RepDisc_Issues COLOR=red,yellow,purple RECOVERED</span></font></pre>
<pre><font size="2" face="Courier New" color="black"><span style="font-size:10.0pt; color:black">    SCRIPT /usr/local/scripts/<a href="http://html_mail.pl">html_mail.pl</a> $NG-NMSRep-DEV DURATION>7d DURATION<14d REPEAT=1d</span></font></pre>
<pre style="white-space:pre-wrap"><font size="2" face="Arial" color="black"><span style="font-size:10.0pt; font-family:"Arial","sans-serif"; color:black">I moved the duration rules down to the "SCRIPT" line.  I also added a 2nd duration rule to demonstrate you could time box this.  The script will fire once per day for 7 days, after 7 days.</span></font><font color="black"><span style="color:black"></span></font></pre>
</div>
</div>
</div>
<center>This communication is the property of CenturyLink and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately
 notify the sender by reply e-mail and destroy all copies of the communication and any attachments.</center>
</div>
</div>
</body>
</html>