How to monitor Windows performance on Zabbix

How to monitor Windows performance on Zabbix

Background Information

I've been rereading some books about Windows performance recently. For a lazy person like me who used to use SCOM monitoring, the Windows OS template that comes with Zabbix is ​​really not enough, because the previous SCOM monitoring package (published by Microsoft, did all the work, and I only needed to enable rules and alarms as needed).

The default Zabbix performance data only has Avg Latency, and the average data is not accurate. If you want to see the latency and IOPS of the disk, you have to do it yourself. After looking at the syntax of windows performance counter in zabbix, I backed off a little. The CounterCategory and CounterName of all numeric performance counters.

The only statistics related to the built-in disk are the transfer speed and average latency.

Windows Performance Monitoring on Zabbix

If there are other performance counters to monitor, what are their names and what do they do? Is there a list that can be searched quickly?

Solve it

Fortunately, PowerShell is easy to write, so I wrote the following function, which integrates the syntax of Zabbix's performance counters.

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

How to use it? Add the above function directly to your personal PowerShell profile, that is, in the PowerShell console notepad $profile , paste the content in, save it, and then set set-executionpolicy remotesigned to allow custom unsigned scripts to run.

Start a new PowerShell and type Get-PerfCounterDesc -show directly. You can filter the results in various ways. The zabbixPerfCounter column is the key used on the generated zabbix. Please replace {#replaceThis} with the instance name of the counter. For example, _total.

Then I added the following counters in the zabbix template to display the disk IOPS and Latency

item prototype

items

You also need to change Grafana accordingly

Summarize

The above is the method of Windows performance monitoring on Zabbix introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Install and configure Zabbix Agentd on Windows
  • Example sharing of server performance monitoring using Windows performance counters

<<:  Best way to replace the key in json object

>>:  Analysis of the Poor Performance Caused by Large Offset of LIMIT in MySQL Query

Recommend

Detailed explanation of how to exit Docker container without closing it

After entering the Docker container, if you exit ...

MySQL string splitting example (string extraction without separator)

String extraction without delimiters Question Req...

The simplest form implementation of Flexbox layout

Flexible layout (Flexbox) is becoming increasingl...

Native js to realize bouncing ball

On a whim, I wrote a case study of a small ball b...

Summary of changes in the use of axios in vue3 study notes

Table of contents 1. Basic use of axio 2. How to ...

Detailed explanation of the process of building an MQTT server using Docker

1. Pull the image docker pull registry.cn-hangzho...

JavaScript parseInt() and Number() difference case study

Learning objectives: The two functions parseInt()...

Detailed examples of Linux disk device and LVM management commands

Preface In the Linux operating system, device fil...

A mobile adaptive web page effect solves the problem of small display page

For work needs, I need to make a mobile phone adap...

Extract specific file paths in folders based on Linux commands

Recently, there is a need to automatically search...

MySQL 4 methods to import data

1. Import mysql command The mysql command import ...

Faint: "Use web2.0 to create standard-compliant pages"

Today someone talked to me about a website develo...