windows server 2019 hyper-v+zabbix3.4
阿新 • • 發佈:2021-06-18
原文:
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 followinghostparameters 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 Summary\Health 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:\zabbix\ps\zabbix-vm-perf.ps1"
UserParameter=hyperv.discoveryitem[*],powershell.exe -file "C:\zabbix\ps\zabbix-vm-perf.ps1" "$1" "$2"
UserParameter=hyperv.check[*],powershell.exe -file "C:\zabbix\ps\zabbix-vm-perf.ps1" "$1" "$2" "$3"
|