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 user-b75305ea6ec0@xymon.invalid <mailto:user-b75305ea6ec0@xymon.invalid> RECOVERED #This one works fine.
SCRIPT /home/xymon/RedAlert.sh user-b75305ea6ec0@xymon.invalid <mailto:user-b75305ea6ec0@xymon.invalid> 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 user-b75305ea6ec0@xymon.invalid <mailto:user-b75305ea6ec0@xymon.invalid>
with user xymon, I receive what i want immediately.
Would someone please help me out of this?
Thanks a lot.