httping测对端应用情况

1、被监控端agentd安装httping-2.4-1.el6.x86_64.rpm


2、在zabbix的agentd端配置文件添加如下:

$ vim /etc/zabbix/zabbix_agentd.conf

UserParameter=httping.status[*],/etc/zabbix/scripts/httping.sh $1 $2 $3 $4


3、编写httping.sh脚本 /etc/zabbix/scripts/httping.sh

#!/bin/bash
metric=$1
host=$2
port=$3
proto=$4
tmp_file=/tmp/httping/${host}_${metric}_httping_status.txt
if [ $proto == "https" ];then
/bin/httping -c3 -t5 -l $proto://$host:$port > $tmp_file
	case $metric in
	    status)
		output=$(cat $tmp_file |grep connected |wc -l )
		if [ $output -eq 3 ];then
		 output=1
		echo $output
		else
		     output=0
		echo $output
		fi
		;;
		failed)
			output=$(cat $tmp_file |grep failed|awk '{print $5}'|awk -F'%' '{print $1}' )
			if [ "$output" == "" ];then
             echo 100
          else
             echo $output
          fi
			;;
		min)
          output=$( cat $tmp_file|grep min|awk '{print $4}'|awk -F/ '{print $1}' )
          if [ "$output" == "" ];then
             echo 0
          else
             echo $output
          fi
        ;;
		avg)
			output=$(cat $tmp_file|grep avg|awk '{print $4}'|awk -F/ '{print $2}')
          if [ "$output" == "" ];then
             echo 0
          else
             echo $output
          fi
			;;
		max)
				output=$(cat $tmp_file|grep max|awk '{print $4}'|awk -F/ '{print $3}')
          if [ "$output" == "" ];then
            echo 0
          else
             echo $output
          fi
			;;
		*)
        echo -e "\e[033mUsage: sh  $0 [status|failed|min|avg|max]\e[0m"
       esac
elif [ $proto == "http" ];then
	/bin/httping -c3 -t5  $proto://$host:$port > $tmp_file
	case $metric in
		    status)
		output=$(cat $tmp_file |grep connected |wc -l )
		if [ $output -eq 3 ];then
		   output=1
		echo $output
		else
		 output=0
		 echo   $output
		fi
		;;
		failed)
			output=$(cat $tmp_file |grep failed|awk '{print $5}'|awk -F'%' '{print $1}' )
			if [ "$output" == "" ];then
             echo 100
          else
             echo $output
          fi
			;;
		min)
          output=$( cat $tmp_file|grep min|awk '{print $4}'|awk -F/ '{print $1}' )
          if [ "$output" == "" ];then
             echo 0
          else
             echo $output
          fi
        ;;
		avg)
			output=$(cat $tmp_file|grep avg|awk '{print $4}'|awk -F/ '{print $2}')
          if [ "$output" == "" ];then
             echo 0
          else
             echo $output
          fi
			;;
		max)
				output=$(cat $tmp_file|grep max|awk '{print $4}'|awk -F/ '{print $3}')
          if [ "$output" == "" ];then
             echo 0
          else
             echo $output
          fi
			;;
		*)
        echo -e "\e[033mUsage: sh  $0 [status|failed|min|avg|max]\e[0m"
       esac
else
	echo "error parm " $proto >/tmp/httping/error.log
 fi


4、在web端做相就的配置



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值