Low Level Discovery发现实现实时监控
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Low Level Discovery发现实现实时监控相关的知识,希望对你有一定的参考价值。
环境:Centos 6.6
Zabbix自动发现WEB站点:
[[email protected] ~]# tail -3 /etc/zabbix/zabbix_agentd.conf UserParameter=web.site_discovery,/etc/zabbix/scripts/discovery_web_site.sh web_site_discovery UserParameter=web.site_code[*],/etc/zabbix/scripts/discovery_web_site.sh web_site_code $1 UserParameter=memory.free,free -m|grep Mem |awk ‘{print $4}‘ [[email protected] ~]# [[email protected] ~]# cat /etc/zabbix/scripts/WEB.txt www.baidu.com www.qq.com www.51cto.com [[email protected] ~]# [[email protected] ~]# zabbix_get -s 192.168.31.160 -k web.site_discovery
[[email protected] ~]# zabbix_get -s 192.168.31.160 -k web.site_code[www.baidu.com] 200 [[email protected] ~]#
创建web_monitor的模版,Configuration---Templates:
Configuration---Templates(web_status_code_monitor)---discovery---create discovery rule:
Configuration---Templates(web_status_code_monitor)---discovery(1)---Item prototypes (0)---create item prototype:
Configuration---Templates(web_status_code_monitor)---discovery(1)---Trigger prototypes (0)---Create Trigger prototype:
Configuration---Templates(web_status_code_monitor)---discovery(1)---Graph prototypes (0)---Create Graph prototype:
Configuration---Host---Zabbix server---Templates---Add:
Configuration---Host---“Zabbix Server”---Discovery(1):
脚本返回的值必须是json格式的
[[email protected] ~]# cat /etc/zabbix/scripts/discovery_web_site.sh #######cat /etc/zabbix/scripts/web_site_code_status######## #!/bin/bash #function:monitor tcp connect status from zabbix #license:GPL #version:1.0 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_dir="/etc/zabbix/scripts" WEB_SITE_discovery () { WEB_SITE=($(cat "$Web_dir"/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 [[email protected] ~]#
本文出自 “鹏城-酱油瓶” 博客,谢绝转载!
以上是关于Low Level Discovery发现实现实时监控的主要内容,如果未能解决你的问题,请参考以下文章
Zabbix监控qemuKVM进程-low_level_discovery
zabbix自定义自动发现服务(low-level-discovery)监控系统服务
演示 zabbix LLD(Low-Level Discovery) 如何使用
Orabbix 监控oracle表空间 Low Level Discovery