zoukankan      html  css  js  c++  java
  • Zabbix 上Windows性能监控

      背景信息

      最近在重新看一些关于windows 性能的书籍,对于我这样一个原来使用SCOM监控的懒人来说,Zabbix 上自带的windows OS template 的模板实在是不够用,因为之前SCOM监控包(微软出的,把所有工作都做了,我只需要按需启用规则和告警即可)。

      默认的Zabbix 性能数据只有Avg Latency,平均的数据也不准,想看下磁盘的Latency以及IOPS要自己动手,看了下zabbix 中windows performance Counter 的语法,我略有退缩了。全是用数字表示的性能计数器的CounterCategory 以及 CounterName。

      自带磁盘相关的统计只有传输速度,以及平均延迟。

      

    Zabbix 上Windows性能监控

      如果要监控其他的性能计数器,它们的名称是什么,作用是什么?能否有个清单可以快速搜索?

      操刀解决

      好在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:SOFTWAREMicrosoftWindows NTCurrentVersionPerflib09"

      $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 上Windows性能监控

      然后我在zabbix 模板中加入了下面的计数器来显示磁盘IOPS 以及Latency  郑州男科医院:http://www.ytsgnk.com/郑州看男科医院哪家好:http://www.ytsgnk.com/郑州男科医院排名:http://www.ytsgnk.com/

      item prototype

      

    Zabbix 上Windows性能监控

      items

      

    Zabbix 上Windows性能监控

      还需要对应更改Grafana

  • 相关阅读:
    Smart TV Alliance SDK2.0简介
    为字符串数组排序。每个字符串可能包含数字,字母,汉字
    为数组添加自定义函数,可完成执行[1,2,3,4,5].twoself() 输出新数组[1,2,3,4,5,1,2,3,4,5]
    vueJS 解决VSCode 中 报错"You may use special comments to disable some warnings. Use // eslint-disable-next-line to ignore the next line. Use /* eslint-disable */ to ignore all warnings in a file."
    table-一列细分为多列(合并单元格)
    利用闲暇时间帮朋友做一个小页面
    保护url时效性和安全性的一种解决方案
    highcharts-3d.js实现饼状图
    eclipse 遇到的问题及解决思路
    git初步使用
  • 原文地址:https://www.cnblogs.com/sushine1/p/11603802.html
Copyright © 2011-2022 走看看