ConSol-Monitoring / snclient

SNClient+ - Cross platform monitoring agent
MIT License
48 stars 9 forks source link

Problems with wmi-checks #71

Closed airathere closed 5 months ago

airathere commented 8 months ago

Hi Sven,

first of all: this is a really great and awesome project and i am thankful for your effort to have an alternative now for nsclient++!

I have tested in the last days with snclient 0.13 a little bit and recognized two problems: perfdata are not available in every case (already mentioned here) and check-wmi with performance counters are not the same as used in the old days.

Can you pls take a look at it?

Expected Behavior

snClient returns pdh data done by check-wmi equivalent to checks on NSClient++

Current Behavior

snClient does return OK instead

Context (Environment)

snClient Version: 0.13 Windows 11 Pro

Detailed Description

wmi: select PercentIdleTime from Win32_PerfFormattedData_HvStats_HyperVHypervisorLogicalProcessor where Name="_Total" -> e.g. results in "94" which gives us the idle time

nsclient: check_pdh -a 'counter=\Hyper-V Hypervisor Logical Processor(_Total)\% PercentIdleTime' 'warn=value>25' 'crit=value>15' 'perf-config=*' show-all -> e.g. results in "94" which gives us the idle time

snclient: check_wmi -a perf-config="*(unit:%)" "query=select PercentIdleTime from Win32_PerfFormattedData_HvStats_HyperVHypervisorLogicalProcessor where Name='Total'" "warn=value<25" "crit=value<15" show-all -> results in "OK:_"

Thank you very much, Joachim

sni commented 8 months ago

Have you tried using PercentIdleTime instead of value in the thresholds? You also might want to adjust the top-syntax template. There are no good defaults for that in check_wmi, because the check is so generic.

mlueckert commented 6 months ago

I run into similar issues. We are using nsclient check_pdh to collect some special performance metrics on Windows systems. These metrics are not available in the integrated windows_exporter of snclient. As a replacement check_wmi would do the job for us but currently it does not provide performance data in the check results.

Do you think check_pdh will find its way in to snclient? Or will it be an option to add performance output to check_wmi?

Here is an example of a query where I would like to have performance data. But in general it would be great to have the option for all check_wmi queries.

curl -X GET \ 'https://hostname:8443/query/check_wmi?warn=AvgDiskQueueLength%20%3E&query=SELECT%20AvgDiskQueueLength%20FROM%20Win32_PerfRawData_PerfDisk_LogicalDisk%20WHERE%20Name&detail-syntax=%24(status)%20-%20AvgDiskQueueLength%20is%20%24(AvgDiskQueueLength)&crit=AvgDiskQueueLength%20%3E' \ --header 'password: GeheimesPasswort'

image

btw thresholds are working for me in this example with snclient 0.18

Thank you for your great work... Marc

mlueckert commented 6 months ago

It also looks like that empty-state and empty-syntax are not implemented for check_wmi in v0.18.

Any chance to get it implemented? image

Thank you.. Marc

mlueckert commented 6 months ago

@sni Thank you for adding the perfdata and warn/crit support in 6bc26e21df1edb3bd668bc6a451e3fd618b26930. The idea of having a macro to remove unwanted characters from the perflabel sounds great.

We are currently using check_pdh in nsclient to query windows performance counters. The metrics of check_pdh have \:/ and all other sort of characters in it and we are struggling over them when trying to create queries in Grafana. We end in a quoting/escaping hell.

sni commented 5 months ago

@mlueckert:

With that you should be able to do something like check_wmi ... perf-syntax='%(key:ascii)' which removes anything except a-zA-Z0-9.

Let me know if that works for you.

mlueckert commented 5 months ago

Hi Sven

The :ascii macro looks quite good and is a quick way to clean the perflabel.

Output without :ascii has : and blanks in the perflabel

test check_wmi "query=SELECT Name,AvgDiskQueueLength FROM Win32_PerfRawData_PerfDisk_LogicalDisk WHERE Name='C:'"

Exit Code: OK (0)
Plugin Output:
C:, 135779285976

Performance Metrics:
  - 'C: AvgDiskQueueLength'=135779285976

With :asci perflabel looks clean but sometimes very generic

test check_wmi "query=SELECT Name,AvgDiskQueueLength FROM Win32_PerfRawData_PerfDisk_LogicalDisk WHERE Name='C:'" "perf-syntax=%(key:ascii)"

Exit Code: OK (0)
Plugin Output:
C:, 135764493205

Performance Metrics:
  - 'CAvgDiskQueueLength'=135764493205

What I really like is the new s/regex/replace/ macro where I have more flexibility.

test check_wmi "query=SELECT Name,AvgDiskQueueLength FROM Win32_PerfRawData_PerfDisk_LogicalDisk WHERE Name='C:'" "perf-syntax=%(key | s/\W/_/)"

Exit Code: OK (0)
Plugin Output:
C:, 135802791463

Performance Metrics:
  - 'C__AvgDiskQueueLength'=135802791463

Thank you very much.. Marc

sni commented 5 months ago

@mlueckert btw, empty-syntax/state has been added with 6bc26e21df1edb3bd668bc6a451e3fd618b26930