Linux Nagios check_http和 check Checker的用法

                           Linux Nagios check_http和 check Checker的用法

1、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
 
 
2、firefox 浏览器右下角监控提示 Nagios Checker
下载:[url]https://addons.mozilla.org/en-US/firefox/addon/3607[/url]
使用方法很简单,下载后添加到firefox插件里,再在右下脚添加被监控机,用户名和密码就可以看到一些信息了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值