原文:
https://dacat.cc/500.html
附件下载地址:
https://files.cnblogs.com/files/itfat/Zabbix-HyperV-Templates-master.rar
Zabbix Agent Templates for Hyper-V monitoring
Description:
Hyper-V 来宾和主机模版
- Template Windows Hyper-V Guest
Discovers VM guest performance counters and creates Zabbix items for each of them. The following parameters are discovered and monitored:- Hyper-V Virtual Storage Device (ops/s and Bytes/s)
- Hyper-V Virtual Network Adapter (Bytes/s)
- Hyper-V Hypervisor Virtual Processor(Total Run Time, %)
- Template Windows HyperV Host
The following host parameters are monitored:- Hyper-V Hypervisor Logical Processor(_Total)\% Guest Run Time
- Hyper-V Hypervisor Logical Processor(_Total)\% Hypervisor Run Time
- Hyper-V Hypervisor Logical Processor(_Total)\% Idle Time
- Hyper-V Hypervisor Root Virtual Processor(_Total)\% Guest Run Time
- Hyper-V Hypervisor Root Virtual Processor(_Total)\% Hypervisor Run Time
- Hyper-V Hypervisor Root Virtual Processor(_Total)\% Remote Run Time
- Hyper-V Hypervisor Root Virtual Processor(_Total)\% Total Run Time
- Hyper-V Hypervisor Virtual Processor(_Total)\% Guest Run Time
- Hyper-V Hypervisor Virtual Processor(_Total)\% Hypervisor Run Time
- Hyper-V Hypervisor Virtual Processor(_Total)\% Remote Run Time
- Hyper-V Hypervisor Virtual Processor(_Total)\% Total Run Time
- Hyper-V Virtual Switch(*)Bytes
- Hyper-V Virtual Machine Health SummaryHealth Critical
模版来自:https://github.com/ameiji/Zabbix-HyperV-Templates
这个zabbix模版已经好久没有更新了,我将这版拿来直接用,发现在ZABBIX客户端会有类似以下报错
1
2
3
4
5
|
9408:20170110:113415.612 active check "perf_counter[Hyper-V Hypervisor Root Virtual Processor(_Total)\% Remote Run Time]" is not supported: Invalid performance counter format. 9408:20170110:113416.627 active check "perf_counter[Hyper-V Hypervisor Virtual Processor(_Total)\% Guest Run Time]" is not supported: Invalid performance counter format. 9408:20170110:113416.627 active check "perf_counter[Hyper-V Hypervisor Virtual Processor(_Total)\% Hypervisor Run Time]" is not supported: Invalid performance counter format. 9408:20170110:113416.627 active check "perf_counter[Hyper-V Hypervisor Virtual Processor(_Total)\% Remote Run Time]" is not supported: Invalid performance counter format. 9408:20170110:113416.627 active check "perf_counter[Hyper-V Hypervisor Virtual Processor(_Total)\% Total Run Time]" is not supported: Invalid performance counter format. |
于是将该模版的Powershell进行了一些修改,其实这版模版没有问题,只是我的操作系统是中文的,如果你的操作系统是英文,估计可以直接拿 来用:例如
1
|
(Get-Counter -Counter 'Hyper-V Hypervisor Virtual Processor(*)总运行时间百分比' ) |
原版中默认是英文:
1
|
(Get-Counter -Counter 'Hyper-V Hypervisor Virtual Processor(*)\% Total Run Time' ) |
再来看看操作系统中的计数:
看到这里,难怪会报错,如果你的服务器操作系统是Windows Server 2012 r2 可以下载附件直接使用
附件:Zabbix-HyperV-Templates-master
使用方法:
下载解压后,上传模版文件Template_Windows_HyperV_VM_Guest.xml再上传Template_Windows_HyperV_Host.xml
将zabbix-vm-perf.ps1放到你的zabbix代理的目录,并在zabbix_agentd.win.conf中添加如下代码:
1
2
3
4
5
|
UserParameter=hyperv.discovery,powershell.exe -file "C:zabbixpszabbix-vm-perf.ps1" UserParameter=hyperv.discoveryitem[*],powershell.exe -file "C:zabbixpszabbix-vm-perf.ps1" "$1" "$2" UserParameter=hyperv.check[*],powershell.exe -file "C:zabbixpszabbix-vm-perf.ps1" "$1" "$2" "$3" |