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

JavaScript implements page scrolling animation

Table of contents Create a layout Add CSS styles ...

Linux IO multiplexing epoll network programming

Preface This chapter uses basic Linux functions a...

Understand the principle of page replacement algorithm through code examples

Page replacement algorithm: The essence is to mak...

Detailed explanation of MySQL Explain

In daily work, we sometimes run slow queries to r...

Simple implementation of Mysql add, delete, modify and query statements

Simple implementation of Mysql add, delete, modif...

CSS naming conventions (rules) worth collecting Commonly used CSS naming rules

CSS naming conventions (rules) Commonly used CSS ...

my.cnf (my.ini) important parameter optimization configuration instructions

MyISAM storage engine The MyISAM storage engine i...

Linux operation and maintenance basic swap partition and lvm management tutorial

Table of contents 1. Swap partition SWAP 1.1 Crea...

VMware installation of Ubuntu 20.04 operating system tutorial diagram

Memo: Just experience it. Record: NO.209 This exa...

JavaScript flow control (branching)

Table of contents 1. Process Control 2. Sequentia...

Best Practices for Implementing Simple Jira Projects with React+TS

A set of projects for training react+ts Although ...