最近公司有一个.NET的电商网站,后端使用了IIS,作为运维监控这些IIS的一些性能指标就很有必要了。
首先创建脚本:
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
echo {
echo "data":[
for /F "tokens=* delims= " %%i IN ('typeperf -qx^|find "Web Service"^|find "Current Connections"') DO (
set j=%%i
for /F "tokens=1 delims=\" %%k in ("%%i") DO (
echo {
echo "{#WEB_SERVICE}": "%%k"
echo },
)
)
echo {
echo "{#WEB_SERVICE}": "none"
echo }
echo ]
echo }
然后在agent端自定义监控项
UserParameter=iis.site.discovery,C:\iis.bat
重启agent服务
在代理服务器上测试是否可以获取到站点名称
[root@zabbix-proxy ~]# /application/zabbix-3.0.3/bin/zabbix_get -s 10.168.204.60 -k iis.site.discovery
{
"data":[
{
"{#WEB_SERVICE}": "Web Service(_Total)"
},
{
"{#WEB_SERVICE}": "Web Service(Mall-CN)"
},
{
"{#WEB_SERVICE}": "Web Service(backend4-8060)"
},
{
"{#WEB_SERVICE}": "Web Service(Mall-H5)"
},
{
"{#WEB_SERVICE}": "Web Service(img-guilinmall)"
},
{
"{#WEB_SERVICE}": "Web Service(Mall-Edeal)"
},
{
"{#WEB_SERVICE}": "Web Service(Mall-EdealApi)"
},
{
"{#WEB_SERVICE}": "Web Service(Mall-De)"
},
{
"{#WEB_SERVICE}": "Web Service(backend-8050)"
},
{
"{#WEB_SERVICE}": "Web Service(www.guilinfarm.com)"
},
{
"{#WEB_SERVICE}": "Web Service(backend-8000)"
},
{
"{#WEB_SERVICE}": "Web Service(Mall-EdealControl)"
},
{
"{#WEB_SERVICE}": "Web Service(UserCenter)"
},
{
"{#WEB_SERVICE}": "Web Service(imgsite)"
},
{
"{#WEB_SERVICE}": "Web Service(AppletAPI)"
},
{
"{#WEB_SERVICE}": "Web Service(CleanCache)"
},
{
"{#WEB_SERVICE}": "Web Service(backend2-8020)"
},
{
"{#WEB_SERVICE}": "Web Service(backend3-8030)"
},
{
"{#WEB_SERVICE}": "Web Service(www.guilinclub.com)"
},
{
"{#WEB_SERVICE}": "Web Service(Mall-En)"
},
{
"{#WEB_SERVICE}": "Web Service(Print)"
},
{
"{#WEB_SERVICE}": "Web Service(www.Ӯƌθ.com)"
},
{
"{#WEB_SERVICE}": "Web Service(guilinmeat)"
},
{
"{#WEB_SERVICE}": "Web Service(PingLun)"
},
{
"{#WEB_SERVICE}": "Web Service(guilinLife-Pc)"
},
{
"{#WEB_SERVICE}": "Web Service(backend-5-8031)"
},
{
"{#WEB_SERVICE}": "Web Service(guilinlife-H5)"
},
{
"{#WEB_SERVICE}": "Web Service(backend-5-8032)"
},
{
"{#WEB_SERVICE}": "Web Service(Mall-Fr)"
},
{
"{#WEB_SERVICE}": "Web Service(backend-5-8032)"
},
{
"{#WEB_SERVICE}": "Web Service(Mall-Fr)"
},
{
"{#WEB_SERVICE}": "Web Service(Mall-Fr#1)"
},
{
"{#WEB_SERVICE}": "Web Service(Mall-Fr#2)"
},
{
"{#WEB_SERVICE}": "Web Service(guilinMall)"
},
{
"{#WEB_SERVICE}": "Web Service(backend-5-8032)"
},
{
"{#WEB_SERVICE}": "Web Service(Mall-Fr)"
},
{
"{#WEB_SERVICE}": "Web Service(Mall-Fr#1)"
},
{
"{#WEB_SERVICE}": "none"
}
]
}
配置过滤正则表达式,不取"{#WEB_SERVICE}": "none"
这一条数据
然后可以在zabbix界面中去定义自动发现模板
监控图表数据