我用nagios-check_http check Checker
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://liuyu.blog.51cto.com/183345/64064 |
这几天按照yahoon兄的大作完成了nagios的配置。并成功监控linux+win服务器的各种服务。 在这里把遇到的问题整理了下。 1、 mail : sendmail 一个小工具实现邮件发送。主页:http://caspian.dotconf.net/menu/Software/SendEmail/ 安装后测试,如果能发送邮件,那说明正常,只需要配置一下下。 具体的我就不说了。看yahoon的大作去吧。http://yahoon.blog.51cto.com/13184/49722 在这里我的mail有smtp pop3双向认证,并照样收发正常 2、check 的使用,在安装后nagios plugins 后会产生N多check开头的文件。 就这是这些脚本的使用 那么对于apache如果只是监控端口80 并不能说明apache就正常,比如动态或者虚拟主机。其中一个网页down了但也不会报警。 于是就应该对check_tcp!80 进行修改 其修改commends.cfg 添加: define command{ command_name check_http command_line $USER1$/check_http -H $HOSTADDRESS$ -u $ARG1$ -w $ARG2$ -c $ARG3$ } 修改services.cfg define service{ host_name aabbcc service_description check-http check_command check_http!3 # 3 timeout --超时值 max_check_attempts 5 normal_check_interval 3 retry_check_interval 2 check_period 24x7 notification_interval 10 notification_period 24x7 notification_options w,u,c,r contact_groups sagroup } 这样就OK 了。如果你要改一些选项的,在nagios/libexec 目录 ./check_http --help 根据参数改就好了。 在这里如果使用check_http!3 nagios返回的是code值HTTP OK HTTP/1.1 200 OK - 66598 bytes in 0.013 seconds 200 刚为正常 如果你进行测试修改一下,就会报其它的错。 check_tcp!80 只返回ping 值 另一个脚本check_mem 使用方法一样。我只贴出脚本内容了。保存的时候记得chmod +x # Script to check real memory usage # L.Gill 02/05/06 - V.1.0 # ------------------------------------------ # ######## Script Modifications ########## # ------------------------------------------ # Who When What # --- ---- ---- # LGill 17/05/06 "$percent" lt 1% fix - sed edits dc result beggining with "." # # #!/bin/bash USAGE="`basename $0` [-w|--warning]<percent free> [-c|--critical]<percent free>" THRESHOLD_USAGE="WARNING threshold must be greater than CRITICAL: `basename $0` $*" calc=/tmp/memcalc percent_free=/tmp/mempercent critical="" warning="" STATE_OK=0 STATE_WARNING=1 STATE_CRITICAL=2 STATE_UNKNOWN=3 # print usage if [[ $# -lt 4 ]] then echo "" echo "Wrong Syntax: `basename $0` $*" echo "" echo "Usage: $USAGE" echo "" exit 0 fi # read input while [[ $# -gt 0 ]] do case "$1" in -w|--warning) shift warning=$1 ;; -c|--critical) shift critical=$1 ;; esac shift done # verify input if [[ $warning -eq $critical || $warning -lt $critical ]] then echo "" echo "$THRESHOLD_USAGE" echo "" echo "Usage: $USAGE" echo "" exit 0 fi # Total memory available total=`free -m | head -2 |tail -1 |gawk '{print $2}'` # Total memory used used=`free -m | head -2 |tail -1 |gawk '{print $3}'` # Calc total minus used free=`free -m | head -2 |tail -1 |gawk '{print $2-$3}'` # normal values #echo "$total"MB total #echo "$used"MB used #echo "$free"MB free # make it into % percent free = ((free mem / total mem) * 100) echo "5" > $calc # decimal accuracy echo "k" >> $calc # commit echo "100" >> $calc # multiply echo "$free" >> $calc # division integer echo "$total" >> $calc # division integer echo "/" >> $calc # division sign echo "*" >> $calc # multiplication sign echo "p" >> $calc # print percent=`/usr/bin/dc $calc|/bin/sed 's/^\./0./'|/usr/bin/tr "." " "|/usr/bin/gawk {'print $1'}` #percent1=`/usr/bin/dc $calc` #echo "$percent1" if [[ "$percent" -le $critical ]] then echo "CRITICAL - $free MB ($percent%) Free Memory" exit 2 fi if [[ "$percent" -le $warning ]] then echo "WARNING - $free MB ($percent%) Free Memory" exit 1 fi if [[ "$percent" -gt $warning ]] then echo "OK - $free MB ($percent%) Free Memory" exit 0 fi 3、firefox 浏览器右下角监控提示 Nagios Checker 下载:https://addons.mozilla.org/en-US/firefox/addon/3607 使用方法很简单,下载后添加到firefox插件里,再在右下脚添加被监控机,用户名和密码就可以看到一些信息了。 这样你就不用开着nagios 看,可以边浏览网页边注意它的提醒。 给大家来张效果图: 注:本一些资料参照http://www.itnms.net/discuz 及石头兄的文章 本文出自 “seven” 博客,请务必保留此出处http://liuyu.blog.51cto.com/183345/64064 本文出自 51CTO.COM技术博客 |



守住每一天
博客统计信息
热门文章
最新评论
友情链接


