zabbix配置low level discovery

1、Zabbix 客户端配置

    Zabbix 客户端配置语句如下:

shell# egrep -v "(#|^$)" /etc/zabbix/zabbix_agentd.conf
LogFile=/var/log/zabbix/zabbix_agentd.log  
Server=127.0.0.1
Include=/etc/zabbix/zabbix_agentd.conf.d/ #子配置文件路径  
UnsafeUserParameters=1 #自定义的Key中可以包括特殊字符

2、编写自动发现脚本

    (1)Shell脚本

shell#cat /etc/zabbix/scripts/web_site_code_status  

#!/bin/bash  
# function:monitor web status from zabbix  
# License: GPL  
# mail:itnihao@qq.com  
# version:1.0 date:2012-12-09  
source /etc/bashrc >/dev/null 2>&1  
source /etc/profile >/dev/null 2>&1  
#/usr/bin/curl -o /dev/null -s -w %{http_code} http://$1/  
Web_SITE_discovery () {  
Web_SITE=($(cat /etc/zabbix/scripts/Web.txt|grep -v "^#"))  
printf '{\n'  
printf '\t"data":[\n'  
for((i=0;i<${#Web_SITE[@]};++i))  
{  
num=$(echo $((${#Web_SITE[@]}-1)))  
if [ "$i" != ${num} ];  
then  
printf "\t\t{ \n"  
printf "\t\t\t\"{#SITENAME}\":\"${Web_SITE[$i]}\"},\n"  
else  
printf "\t\t{ \n"  
printf "\t\t\t\"{#SITENAME}\":\"${Web_SITE[$num]}\"}]}\n"  
fi  
}  
}  
web_site_code () {  
/usr/bin/curl -o /dev/null -s -w %{http_code} http://$1  
}  
case "$1" in  
web_site_discovery)  
Web_SITE_discovery  
;;  
web_site_code)  
web_site_code $2  
;;  
*)  
echo "Usage:$0 {web_site_discovery|web_site_code [URL]}"  
;;  
esac
    (2)域名文件

shell# cat /etc/zabbix/scripts/Web.txt  

http://www.itnihao.com  
http://www.baidu.com  
http://www.weibo.com
    (3)测试脚本执行成功与否:

shell# sh web_site_code_status web_site_discovery  

{  
“data”:[  
{  
“{#SITENAME}”:”www.itnihao.com”},  
{  
“{#SITENAME}”:”www.baidu.com”},  
{  
“{#SITENAME}”:”www.weibo.com”}]}

3、自定义key配置文件

shell# cat /etc/zabbix/zabbix_agentd.conf.d/web_site_discovery.conf  
UserParameter=web.site.discovery,/etc/zabbix/scripts/web_site_code_status web_site_discovery  
UserParameter=web.site.code[*],/etc/zabbix/scripts/web_site_code_status web_site_code $1

4、测试语句

shell# zabbix_get -s 127.0.0.1 -k web.site.discovery  
{  
“data”:[  
{  
“{#SITENAME}”:”www.itnihao.com”},  
{  
“{#SITENAME}”:”www.baidu.com”},  
{  
“{#SITENAME}”:”www.weibo.com”}]}  
shell# zabbix_get -s 127.0.0.1 -k web.site.code[www.itnihao.com]  
200  
shell# zabbix_get -s 127.0.0.1 -k web.site.code[www.baidu.com]  
200  
shell# zabbix_get -s 127.0.0.1 -k web.site.code[www.weibo.com]  
200

5、对以上修改的文件列个清单,具体如下:

/etc/zabbix/zabbix_agentd.conf #Agent配置文件  
/etc/zabbix/scripts/web_site_code_status #权限755  
/etc/zabbix/scripts/Web.txt #网站URL存放文件  
/etc/zabbix/zabbix_agentd.conf.d/web_site_discovery.conf#子配置文件 

6、Web 页面添加

    (1)创建templates


    (2)创建Application


    (3)创建Discovery rules

    注意:宏(Macro)中的{#SITENAME}来自自动发现脚本中的变量{#SITENAME}


    (4)创建Item prototypes

    $1 代表我们检测出来的URL,web.site.code[{#SITENAME}] 中的变量会依次检测这几个URL


    (5)创建Trigger prototypes


    (6)设置多梯度告警检测

    设置不同周期的告警:2 分钟、10 分钟、15 分钟三种不同故障级别的告警。

    Last of(T)设置时间或者次数,Time shift设置时间偏移。如,last()表示最后一次,last(#3,120)表示2分钟内所有数据的第3次数据。



    (7)创建Graph prototypes



    (8)添加模板到主机


    (9)查看图形数据



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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值