Zabbix 上Windows性能监控
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Zabbix 上Windows性能监控,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2940字,纯文字阅读大概需要5分钟。
内容图文
![Zabbix 上Windows性能监控](/upload/InfoBanner/zyjiaocheng/952/66292ff2243744098476402983619aea.jpg)
最近在重新看一些关于windows 性能的书籍,对于我这样一个原来使用SCOM监控的懒人来说,Zabbix 上自带的windows OS template 的模板实在是不够用,因为之前SCOM监控包(微软出的,把所有工作都做了,我只需要按需启用规则和告警即可)。
默认的Zabbix 性能数据只有Avg Latency,平均的数据也不准,想看下磁盘的Latency以及IOPS要自己动手,看了下zabbix 中windows performance Counter 的语法,我略有退缩了。全是用数字表示的性能计数器的CounterCategory 以及 CounterName。
自带磁盘相关的统计只有传输速度,以及平均延迟。
如果要监控其他的性能计数器,它们的名称是什么,作用是什么?能否有个清单可以快速搜索?
操刀解决
好在powershell 书写比较顺手,写了下面一个函数,整合了zabbix 的性能计数器的语法。
function Get-PerfCounterDesc{
[cmdletbinding()]
param(
[switch]$show
)
$Categories = [System.Diagnostics.PerformanceCounterCategory]::GetCategories()
$SingleInstanceCategories = $Categories | Where-Object {$_.CategoryType -eq "SingleInstance"}
$MultiInstanceCategories = $Categories| Where-Object {$_.CategoryType -eq "MultiInstance"}
$SingleInstanceCounters = $SingleInstanceCategories | ForEach-Object {
(new-object System.Diagnostics.PerformanceCounterCategory($_.CategoryName)).GetCounters()
}
$MultiInstanceCounters = $MultiInstanceCategories | ForEach-Object {
$category=new-object System.Diagnostics.PerformanceCounterCategory($_.CategoryName)
if($category.InstanceExists('_Total')){
$category.GetCounters('_Total')
}elseif($category.InstanceExists('Total')){
$category.GetCounters('Total')
}else{
$instanceNames=$category.GetInstanceNames()
if($instanceNames.count -gt 0){
$category.GetCounters($instanceNames[0])
}
}
}
$AllCounters = $MultiInstanceCounters + $SingleInstanceCounters
$key="HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009"
$counters=Get-ItemPropertyValue -Path $key -Name "counter"
$Dict=@{}
for ($i=0;$i -lt $counters.count;$i=$i+2){
if($counters[$i+1] -and -not $Dict.ContainsKey($counters[$i+1])){
$Dict.add($counters[$i+1],$counters[$i])
}
}
Write-Debug $dict.keys.count
$result=$AllCounters | Sort-Object Categoryname,Countername|
Select-Object CategoryName,
Countername,
@{n="zabbixPerfCounter";e={'perf_counter["\{0}({{#ReplaceThis}})\{1}"]' -f $dict[$_.CategoryName],$dict[$_.Countername]}},
@{n="categoryNum";e={$Dict[$_.CategoryName]}},
@{n="CounterNum";e={$Dict[$_.Countername]}},
CategoryHelp,
CounterHelp
if($show){
$result|Out-GridView
}else{
$result
}
}
怎么用呢?把上面函数直接加到个人的powershell 配置文件,也就是在powershell 控制台notepad $profile ,把内容粘贴进去,然后保存,然后设置set-executionpolicy remotesigned以让自定义非签名的脚本可以运行。
新起一个powershell ,直接敲Get-PerfCounterDesc -show, 可以对结果进行各种过滤。其中zabbixPerfCounter 列,就是生成的zabbix 上使用的key,其中的{#replaceThis} 请替换成计数器的实例名称。比如_total.
然后我在zabbix 模板中加入了下面的计数器来显示磁盘IOPS 以及Latency
item prototype
还需要对应更改Grafana 郑州男科医院:http://mobile.tongji120.com/郑州男科医院哪家好:http://mobile.tongji120.com/郑州同济做包皮手术多少钱:http://mobile.tongji120.com/
内容总结
以上是互联网集市为您收集整理的Zabbix 上Windows性能监控全部内容,希望文章能够帮你解决Zabbix 上Windows性能监控所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。