.添加url监控脚本
[root@node1 usr]# vim /usr/local/zabbix_agents_3.2.0/scripts/web_site_code_status.sh
#!/bin/bash UrlFile="/usr/local/zabbix_agents_3.2.0/scripts/WEB.txt"
IFS=$'\n' web_site_discovery () {
WEB_SITE=($(cat $UrlFile|grep -v "^#"))
printf '{\n'
printf '\t"data":[\n'
num=${#WEB_SITE[@]}
for site in ${WEB_SITE[@]}
do
num=$(( $num - ))
url=$(echo $site|awk '{print $1}')
ip=$(echo $site|awk '{print $2}')
if [ $num -ne ] ; then
printf "\t\t{\"{#SITENAME}\":\""%s"\",\"{#PROXYIP}\":\""${ip}"\"},\n" ${url}
else
printf "\t\t{\"{#SITENAME}\":\""%s"\",\"{#PROXYIP}\":\""${ip}"\"}\n" ${url}
printf '\t]\n'
printf '}\n'
fi
done
} web_site_code () {
if [ "$2" == "" ]; then
curl -s -k --connect-timeout -m -o /dev/null -w %{http_code} "https://$1"
elif echo $ |grep ':' &>/dev/null ; then
curl -s -k --connect-timeout -m -o /dev/null -w %{http_code} "https://$1" -x $
else
curl -s -k --connect-timeout -m -o /dev/null -w %{http_code} "https://$1" -x $:
fi
} case "$1" in
web_site_discovery)
web_site_discovery
;;
web_site_code)
web_site_code $ $
;;
*)
echo "Usage:$0 {web_site_discovery|web_site_code [URL]}"
;;
esac [root@node1 usr]# chmod +x /usr/local/zabbix_agents_3.2.0/scripts/web_site_code_status.sh .在zabbix客户端加配置文件:
zabbix-agent中打开配置
Include=/usr/local/zabbix_agents_3.2.0/conf/zabbix_agentd/*.conf vim /usr/local/zabbix_agents_3.2.0/conf/zabbix_agentd/web_site_discovery.conf UserParameter=web.site.discovery,/usr/local/zabbix_agents_3.2.0/scripts/web_site_code_status.sh web_site_discovery
UserParameter=web.site.code[*],/usr/local/zabbix_agents_3.2.0/scripts/web_site_code_status.sh web_site_code $1 $2 [root@node1 usr]# cat /usr/local/zabbix_agents_3.2.0/scripts/WEB.txt
http://www.baidu.com
http://www.sina.com.cn
http://www.163.com 10.10.10.10
http://www.sohu.com 115.23.16.97:80
http://www.111.com # 客户端测试
[root@account_web03:~]# /usr/local/zabbix_agents_3.2.0/scripts/web_site_code_status.sh web_site_discovery
{
"data":[
{"{#SITENAME}":"www.wondershare.com","{#PROXYIP}":""},
{"{#SITENAME}":"www.wondershare.net","{#PROXYIP}":""},
{"{#SITENAME}":"www.wondershare.jp","{#PROXYIP}":""},
{"{#SITENAME}":"www.wondershare.de","{#PROXYIP}":""}, # 服务端测试 [root@node5 ~]# zabbix_get -s 10.11.0.210 -k 'web.site.discovery'
{
"data":[
{"{#SITENAME}":"http://www.baidu.com","{#PROXYIP}":""},
{"{#SITENAME}":"http://www.sina.com.cn","{#PROXYIP}":""},
{"{#SITENAME}":"http://www.163.com","{#PROXYIP}":"10.10.10.10"},
{"{#SITENAME}":"http://www.sohu.com","{#PROXYIP}":"115.23.16.97:80"},
{"{#SITENAME}":"http://www.111.com","{#PROXYIP}":""}
]
} 被监控端 zabbix_Agentd.conf 的配置调整: ServerActive=*.*.*.* #zabbix_server的ip
Hostname=agent_host_name #重要:主机名
RefreshActiveChecks=1800 #被监控端到服务器获取监控项的周期
BufferSize=200 #被监控端存储监控信息的空间大小
Timeout=10 #超时时间
比较重要的参数是ServerActive和Hostname,ServerActive是指定Agentd收集的数据往哪里发送,Hostname是必须要和Server端添加主机时的主机名一样,这样Server端接收到数据才能找到对应关系。 3.服务端配置,导入自动发现的模板
4.也可以自定义item,具体如下:
触发器另外的写法,5次触发:
{urls_monitor_rsync:web.site.code[{#SITENAME},].count(#5,200,"eq")}=0 and {urls_monitor_rsync:web.site.code[{#SITENAME},].count(#5,301,"eq")}=0

自动发现模板

<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>3.4</version>
<date>--14T01::17Z</date>
<groups>
<group>
<name>Templates</name>
</group>
</groups>
<templates>
<template>
<template>Template Web Monitor_active</template>
<name>Template Web Monitor_active</name>
<description/>
<groups>
<group>
<name>Templates</name>
</group>
</groups>
<applications>
<application>
<name>web_monitor</name>
</application>
</applications>
<items/>
<discovery_rules>
<discovery_rule>
<name>web.site.discovery</name>
<type></type>
<snmp_community/>
<snmp_oid/>
<key>web.site.discovery</key>
<delay></delay>
<status></status>
<allowed_hosts/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel></snmpv3_securitylevel>
<snmpv3_authprotocol></snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol></snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype></authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<filter>
<evaltype></evaltype>
<formula/>
<conditions/>
</filter>
<lifetime>30d</lifetime>
<description/>
<item_prototypes>
<item_prototype>
<name>monitor_site $ $ response code</name>
<type></type>
<snmp_community/>
<snmp_oid/>
<key>web.site.code[{#SITENAME},{#PROXYIP}]</key>
<delay></delay>
<history>7d</history>
<trends>365d</trends>
<status></status>
<value_type></value_type>
<allowed_hosts/>
<units/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel></snmpv3_securitylevel>
<snmpv3_authprotocol></snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol></snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype></authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link></inventory_link>
<applications>
<application>
<name>web_monitor</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing/>
<jmx_endpoint/>
<application_prototypes/>
<master_item_prototype/>
</item_prototype>
</item_prototypes>
<trigger_prototypes>
<trigger_prototype>
<expression>{Template Web Monitor_active:web.site.code[{#SITENAME},{#PROXYIP}].last()}&lt;&gt; and {Template Web Monitor_active:web.site.code[{#SITENAME},{#PROXYIP}].last()}&lt;&gt;</expression>
<recovery_mode></recovery_mode>
<recovery_expression/>
<name>web_monitor {#SITENAME} {#PROXYIP}</name>
<correlation_mode></correlation_mode>
<correlation_tag/>
<url/>
<status></status>
<priority></priority>
<description/>
<type></type>
<manual_close></manual_close>
<dependencies/>
<tags/>
</trigger_prototype>
</trigger_prototypes>
<graph_prototypes/>
<host_prototypes/>
<jmx_endpoint/>
</discovery_rule>
</discovery_rules>
<httptests/>
<macros/>
<templates/>
<screens/>
</template>
</templates>
</zabbix_export>

zabbix批量监控urls的状态码的更多相关文章

  1. 云监控自定义HTTP状态码说明

    您在使用站点监控时,返回的6XX状态码均为云监控自定义HTTP状态码,具体含义如下表所示: 状态码      含义     备注  610  HTTP连接超时      监测点探测您的网站时出现连接超 ...

  2. zabbix监控nginx日志状态码

    监控需求 监控Nginx常见的状态码并对其进行监控,对常见的错误状态码创建相对应的触发器以下按照分钟对数据进行抓取 Zabbix_Agentd创建监控脚本 1)创建脚本之前核对Nginx日志格式我这里 ...

  3. zabbix批量监控域名下nginx的访问50x状态码数量

    背景: 购物车相关的站点某些页面经常出现502,如果超过一些阈值则需要报警给管理员知道 .自动发现脚本的编写 # vim /usr/local/zabbix_agents_3.2.0/scripts/ ...

  4. zabbix3.2自动发现批量监控redis端口状态

    使用nmap提示被防火墙阻挡,实际没有启用防火墙 [root@eus_chinasoft_haproxy:/usr/local/aegis]# nmap 172.20.103.202 -p 7000 ...

  5. zabbix监控nginx连接状态(转)

    zabbix监控nginx zabbix可以监控nginx的状态,关于一个服务的状态可以查看服务本身的状态(版本号.是否开启),还应该关注服务能力(例如以nginx的负载效果:连接数.请求数和句柄数) ...

  6. zabbix自动发现 url 以及对http返回状态码监控实现 告警

    2019-06-04 18:39:12 目的:批量监控业务URL的返回状态码,通过zabbix监控判断业务好坏. 1.zabbix安装 请查看此永久链接:https://www.cnblogs.com ...

  7. shell批量监控网站状态码

    shell批量监控网站状态码脚本,使用curl很慢.等我学完其他方式,在来更新. #!/bin/bash #GuoYabin yuming=`/bin/cat yuming.txt` for i in ...

  8. ZABBIX监控mysql主从状态

    模板如下 <zabbix_export> <version>3.4</version> <date>2018-11-30T08:28:28Z</d ...

  9. Zabbix监控Low level discovery实时监控网站URL状态

    今天我们来聊一聊Low level discovery这个功能,我们为什么要用到loe level discovery这个功能呢? 很多时候,在使用zabbix监控一些东西,需要对类似于Itens进行 ...

随机推荐

  1. Tips and Tricks for Debugging in chrome

    Tips and Tricks for Debugging in chrome Pretty print On sources panel ,clicking on the {} on the bot ...

  2. 关于js事件执行顺序

    关于js事件执行顺序小技巧 js事件执行顺序是js中一个老生常谈的一个话题, 聊这个话题之前我们先谈谈怎么给页面元素绑定我们需要的事件 1.给页面元素绑定事件 a)直接在元素上面加上需要绑定的事件,如 ...

  3. Java高并发秒杀API之web层

    第1章 设计Restful接口 1.1前端交互流程设计 1.2 学习Restful接口设计 什么是Restful?它就是一种优雅的URI表述方式,用来设计我们资源的访问URL.通过这个URL的设计,我 ...

  4. ZOJ - 3261 Connections in Galaxy War(并查集删边)

    https://cn.vjudge.net/problem/ZOJ-3261 题意 银河系各大星球之间有不同的能量值, 并且他们之间互相有通道连接起来,可以用来传递信息,这样一旦有星球被怪兽攻击,便可 ...

  5. 添加Glide图片加载框架依赖

    1.添加依赖implementation 'com.github.bumptech.glide:glide:4.7.1' 2.放置一个ImageView.3.加载,ivGif是ImageView实例 ...

  6. 学习 vue 源码 -- 响应式原理

    概述 由于刚开始学习 vue 源码,而且水平有限,有理解或表述的不对的地方,还请不吝指教. vue 主要通过 Watcher.Dep 和 Observer 三个类来实现响应式视图.另外还有一个 sch ...

  7. RNN

    在DNN中,当前输出层的值只和当前输入值有关系.如果当前输出值不仅依赖当前输入值,也依赖于前面时刻的输入值,那么DNN就不适用了.因此也就有了RNN. 一.RNN结构 这是最简单的RNN.其中Xt是t ...

  8. asp.net mvc5 多语言应用

    需求:有些网站需要多语言显示,比如简体中文,繁体中文,英文. 1.创建一个mvc项目: 2.创建App_GlobalResources 创建了中文.英文两个语言的资源文件,中文是程序的默认语言,所以我 ...

  9. Vue.component注意事项

    Vue.component前不要加 new,否则报错: Uncaught TypeError: Cannot read property '_base' of undefined

  10. Java Web之JSTL标准标签库总结

    [文档整理系列] Java Web之JSTL标准标签库总结