Exchange 性能计数器介绍详见 https://docs.microsoft.com/en-us/exchange/exchange-2013-performance-counters-exchange-2013-help。
实现方式:使用userparameter 参数通过powershell脚本将数据库推送至zabbix server,自动创建监控项。
- zabbix agent配置userprarmeter参数,指向运行的脚本。
PS C:\Users\administrator> type C:\zabbix\zabbix_agentd.d\UserParameter.conf
UserParameter=db.counter,c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe -file c:\zabbix\scripts\perf-db.ps1
perf-db.ps1脚本内容:
Add-PSSnapin Microsoft.Exchange*
$name = hostname
$DBs=Get-MailboxDatabase | ? {$_.server -eq "$name"} |% {$_.Name}
$VAR1="{"
$VAR2='"data": ['
$VAR3='"{#DB_NAME}":'
$VAR4="]"
$VAR5="}"
$VAR6="},"
Write-Output $VAR1
Write-Output " $VAR2"
ForEach($i in $DBs)
{
Write-Output " $VAR1"
Write-Output " $VAR3 `"$i`""
if ($i -eq $DBs[-1])
{
Write-Output " $VAR5"
}
else
{
Write-Output " $VAR6"
}
}
Write-Output " $VAR4"
Write-Output $VAR5
脚本的输出结果需要满足json格式要求:
脚本执行结果(只展示一部分):
{
"data": [
{
"{#DB_NAME}": "Staff03"
},
{
"{#DB_NAME}": "Staff02"
},
{
"{#DB_NAME}": "Manager"
},
{
"{#DB_NAME}": "Staff01"
},
{
"{#DB_NAME}": "Staff04"
},
{
"{#DB_NAME}": "Staff05"
},
{
"{#DB_NAME}": "Staff06"
},
{
"{#DB_NAME}": "Staff07"
},
{
"{#DB_NAME}": "NBU-Test"
}
]
}
目的是:通过zabbix discover 自动创建对应的数据库item.
- Zabbix web端创建模板,并创建discover 规则。
LLD 详见: https://www.zabbix.com/documentation/4.2/manual/discovery/low_level_discovery
- 创建数据库性能对应的key,通过宏调用db.
zabbix性能监控介绍详见: https://www.zabbix.com/documentation/current/manual/config/items/perfcounters
- 创建graph
将主机关联到该模板即可。
- 看效果: