[Xymon] Custom alert mail with script

Henrik Størner henrik at hswn.dk
Thu Sep 8 16:38:10 CEST 2016


Hi,

running your script with "sh /home/xymon/RedAlert.sh" doesn't quite do 
what Xymon does - you should run it without the "sh" first.

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

     #/bin/sh<CR>

The "<CR>" is an invisible carriage-return. Try editing the script with 
"vi -b RedAlert.sh" and you should see the <CR> characters.


Regards,
Henrik

Den 08-09-2016 kl. 15:58 skrev 谈工作:
> Hi there
>
> I have been working on custom alert script for days, but it just 
> doesn't work.
>
> Here is my config in alerts.cfg(based on the man page):
>
> HOST=*  SERVICE=cpu,disk,memory,files COLOR=red,yellow
>      #MAIL me at mydomain.com <mailto:me at mydomain.com> RECOVERED #This 
> one works fine.
>      SCRIPT /home/xymon/RedAlert.sh me at mydomain.com 
> <mailto:me at mydomain.com> FORMAT=sms
>
> And here is my script(based on 
> http://lists.xymon.com/pipermail/xymon/2011-May/031660.html):
>
> #!/usr/bin/sh
> CALL_LEVEL="存在异常"
> ASK_LEVEL="请您关注。"
> RCPT=$1
> [ "$BBCOLORLEVEL" = "RED" ] && ASK_LEVEL="情况严重,请立即处理。"
> [ "$BBCOLORLEVEL" = "RED" ] && CALL_LEVEL="严重告警"
> echo "告警主机$BBHOSTNAME 
> ,IP地址为$MACHIP,告警项目:$BBSVCNAME,$ASK_LEVEL 持续时长:$DOWNSECS。
> 相关日志详情:
> $BBALPHAMSG" | mail -s "$MACHIP 的 $BBSVCNAME $CALL_LEVEL【Xymon监控】" 
> $RCPT
>
> The alert.log keep logging:
> Could not launch paging script /home/xymon/RedAlert.sh: No such file 
> or directory
>
> I have checked the file permission (-rwxrwxr-x), and when I run:
> sh /home/xymon/RedAlert.sh me at mydomain.com <mailto:me at mydomain.com>
> with user xymon, I receive what i want  immediately.
>
> Would someone please help me out of this?
> Thanks a lot.
>
>
> _______________________________________________
> Xymon mailing list
> Xymon at xymon.com
> http://lists.xymon.com/mailman/listinfo/xymon

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20160908/0035609e/attachment.html>


More information about the Xymon mailing list