<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Hi,</p>
<p>running your script with "sh /home/xymon/RedAlert.sh" doesn't
quite do what Xymon does - you should run it without the "sh"
first.</p>
<p>I suspect your script has DOS/Windows line-endings; this is a
classical issue and it can be really annoying. The problem is that
the first line of the script reads</p>
<p> #/bin/sh<CR></p>
<p>The "<CR>" is an invisible carriage-return. Try editing the
script with "vi -b RedAlert.sh" and you should see the <CR>
characters.<br>
</p>
<br>
Regards,<br>
Henrik<br>
<br>
<div class="moz-cite-prefix">Den 08-09-2016 kl. 15:58 skrev 谈工作:<br>
</div>
<blockquote
cite="mid:CANbTsTq0gvhK3ZTK8B1BjtwxJO12EjL7d2j=11ur=qhDKmRLYA@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>Hi there</div>
<div><br>
</div>
<div>I have been working on custom alert script for days, but it
just doesn't work.</div>
<div><br>
</div>
<div>Here is my config in alerts.cfg(based on the man page):</div>
<div><br>
</div>
<div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>HOST=*
SERVICE=cpu,disk,memory,files COLOR=red,yellow</div>
<div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>
#MAIL <a moz-do-not-send="true"
href="mailto:me@mydomain.com">me@mydomain.com</a> RECOVERED
#This one works fine.</div>
<div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>
SCRIPT /home/xymon/RedAlert.sh <a moz-do-not-send="true"
href="mailto:me@mydomain.com">me@mydomain.com</a> FORMAT=sms</div>
<div><br>
</div>
<div>And here is my script(based on <a moz-do-not-send="true"
href="http://lists.xymon.com/pipermail/xymon/2011-May/031660.html">http://lists.xymon.com/pipermail/xymon/2011-May/031660.html</a>):</div>
<div><br>
</div>
<div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>#!/usr/bin/sh</div>
<div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>CALL_LEVEL="存在异常"</div>
<div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>ASK_LEVEL="请您关注。"</div>
<div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>RCPT=$1</div>
<div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>[
"$BBCOLORLEVEL" = "RED" ] && ASK_LEVEL="情况严重,请立即处理。"</div>
<div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>[
"$BBCOLORLEVEL" = "RED" ] && CALL_LEVEL="严重告警"</div>
<div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>echo
"告警主机$BBHOSTNAME ,IP地址为$MACHIP,告警项目:$BBSVCNAME,$ASK_LEVEL
持续时长:$DOWNSECS。</div>
<div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>相关日志详情:</div>
<div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>$BBALPHAMSG"
| mail -s "$MACHIP 的 $BBSVCNAME $CALL_LEVEL【Xymon监控】" $RCPT</div>
<div><br>
</div>
<div>The alert.log keep logging:</div>
<div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>Could
not launch paging script /home/xymon/RedAlert.sh: No such file
or directory</div>
<div><br>
</div>
<div>I have checked the file permission (-rwxrwxr-x), and when I
run:</div>
<div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>sh
/home/xymon/RedAlert.sh <a moz-do-not-send="true"
href="mailto:me@mydomain.com">me@mydomain.com</a></div>
<div>with user xymon, I receive what i want immediately.</div>
<div><br>
</div>
<div>Would someone please help me out of this?</div>
<div>Thanks a lot.</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Xymon mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Xymon@xymon.com">Xymon@xymon.com</a>
<a class="moz-txt-link-freetext" href="http://lists.xymon.com/mailman/listinfo/xymon">http://lists.xymon.com/mailman/listinfo/xymon</a>
</pre>
</blockquote>
<br>
</body>
</html>