【8】、Low Level Discovery发现实现实时监控
2016-05-19 10:08
543 查看
环境:Centos 6.6
Zabbix自动发现WEB站点:
创建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格式的
本文出自 “鹏城-酱油瓶” 博客,谢绝转载!
Zabbix自动发现WEB站点:
[root@Centos ~]# 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}' [root@Centos ~]# [root@Centos ~]# cat /etc/zabbix/scripts/WEB.txt www.baidu.com www.qq.com www.51cto.com [root@Centos ~]# [root@Centos ~]# zabbix_get -s 192.168.31.160 -k web.site_discovery
[root@Centos ~]# zabbix_get -s 192.168.31.160 -k web.site_code[www.baidu.com] 200 [root@Centos ~]#
创建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格式的
[root@Centos ~]# 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 [root@Centos ~]#
本文出自 “鹏城-酱油瓶” 博客,谢绝转载!
相关文章推荐
- 小轩在Linux中趟过的坑
- iOS中监视外部网站的播放事件
- Hadoop2.6.0运行mapreduce之推断(speculative)执行(下)
- [置顶] Linux 系统的常用命令之 rm ,rm -rf , rm -f 以及rm 命令的其他参数命令
- 《Ansible自动化运维:技术与最佳实践》图书已上架,欢迎大家阅读
- Windows下编译自己的opencv3.1库
- Phpcms V9手机门户设置教程:怎么用PC V9做手机网站
- Topographic Laser Ranging and Scanning Principles and Processing翻译
- Linux gdb调试入门
- nethogs 命令的安装使用
- Linux内存管理之mmap详解
- 每个程序员都应该知道的8个Linux命令
- CentOS下如何从vi编辑器插入模式退出到命令模式
- java.lang.IllegalArgumentException: Document base D:\apache-tomcat-6.0.45\webapps\项目不存在错误
- Nginx 启动脚本/重启脚本
- linux gz 解压缩
- 点评五款用于 Linux 编程的内存调试器
- 点评五款用于 Linux 编程的内存调试器
- git:Linux搭建服务器,windows客户端
- linux命令--定时删除linux下面的某目录下的日志文件