最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Zabbix 上Windows性能監(jiān)控的方法

 更新時間:2019年09月30日 10:42:15   作者:yoke88  
這篇文章主要介紹了Zabbix 上Windows性能監(jiān)控,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下

背景信息

最近在重新看一些關(guān)于windows 性能的書籍,對于我這樣一個原來使用SCOM監(jiān)控的懶人來說,Zabbix 上自帶的windows OS template 的模板實在是不夠用,因為之前SCOM監(jiān)控包(微軟出的,把所有工作都做了,我只需要按需啟用規(guī)則和告警即可)。

默認(rèn)的Zabbix 性能數(shù)據(jù)只有Avg Latency,平均的數(shù)據(jù)也不準(zhǔn),想看下磁盤的Latency以及IOPS要自己動手,看了下zabbix 中windows performance Counter 的語法,我略有退縮了。全是用數(shù)字表示的性能計數(shù)器的CounterCategory 以及 CounterName。

自帶磁盤相關(guān)的統(tǒng)計只有傳輸速度,以及平均延遲。

Zabbix 上Windows性能監(jiān)控

如果要監(jiān)控其他的性能計數(shù)器,它們的名稱是什么,作用是什么?能否有個清單可以快速搜索?

操刀解決

好在powershell 書寫比較順手,寫了下面一個函數(shù),整合了zabbix 的性能計數(shù)器的語法。

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
 }
}

怎么用呢?把上面函數(shù)直接加到個人的powershell 配置文件,也就是在powershell 控制臺notepad $profile ,把內(nèi)容粘貼進去,然后保存,然后設(shè)置set-executionpolicy remotesigned以讓自定義非簽名的腳本可以運行。

新起一個powershell ,直接敲Get-PerfCounterDesc -show, 可以對結(jié)果進行各種過濾。其中zabbixPerfCounter 列,就是生成的zabbix 上使用的key,其中的{#replaceThis} 請?zhí)鎿Q成計數(shù)器的實例名稱。比如_total.

然后我在zabbix 模板中加入了下面的計數(shù)器來顯示磁盤IOPS 以及Latency

item prototype

items

還需要對應(yīng)更改Grafana

總結(jié)

以上所述是小編給大家介紹的Zabbix 上Windows性能監(jiān)控的方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!

相關(guān)文章

最新評論

宝山区| 南乐县| 类乌齐县| 孟州市| 柞水县| 清水县| 山东| 贞丰县| 朔州市| 镇江市| 通榆县| 达孜县| 旺苍县| 那曲县| 炉霍县| 祥云县| 云安县| 简阳市| 拜城县| 密山市| 武宁县| 太原市| 拉萨市| 商丘市| 太白县| 界首市| 会同县| 安新县| 泰安市| 邓州市| 弥渡县| 岐山县| 杭州市| 阜阳市| 彰武县| 内乡县| 陆河县| 乌什县| 石门县| 蓝山县| 安庆市|