Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] add additional calculator types. New calculators needed to #3378

Merged
merged 1 commit into from
Jun 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions checks/libs/wmi/counter_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,53 @@ def calculate_perf_counter_counter(previous, current, property_name):
return

return (n1 - n0) / ((d1 - d0) / f)

@calculator(805438464)
def calculate_perf_average_timer(previous, current, property_name):
"""
PERF_AVERAGE_TIMER

https://msdn.microsoft.com/en-us/library/ms804010.aspx
Description This counter type measures the time it takes, on average, to
complete a process or operation. Counters of this type display a ratio of
the total elapsed time of the sample interval to the number of processes
or operations completed during that time. This counter type measures time
in ticks of the system clock. The F variable represents the number of
ticks per second. The value of F is factored into the equation so that
the result can be displayed in seconds.

Generic type Average
Formula ((N1 - N0) / F) / (D1 - D0), where the numerator (N) represents the number of ticks counted during the last sample interval, F represents the frequency of the ticks, and the denominator (D) represents the number of operations completed during the last sample interval.
Average ((Nx - N0) / F) / (Dx - D0)
Example PhysicalDisk\ Avg. Disk sec/Transfer
"""
n0 = previous[property_name]
n1 = current[property_name]
d0 = previous["Timestamp_Sys100NS"]
d1 = current["Timestamp_Sys100NS"]
f = current["Frequency_Sys100NS"]

if n0 is None or n1 is None:
return

return ((n1 - n0) / f) / (d1 - d0)

@calculator(5571840)
def calculate_perf_counter_100ns_queuelen_type(previous, current, property_name):
"""
PERF_COUNTER_100NS_QUEUELEN_TYPE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the docs on msdn are slowly being retired, but here's what I found on PERF_COUNTER_100NS_QUEUELEN_TYPE: https://msdn.microsoft.com/en-us/library/aa392905(v=vs.85).aspx

Could you include the short description in the comment here?

Average length of a queue to a resource over time in 100 nanosecond units.


Average length of a queue to a resource over time in 100 nanosecond units.

https://msdn.microsoft.com/en-us/library/aa392905(v=vs.85).aspx

Formula (n1 - n0) / (d1 - d0)
"""
n0 = previous[property_name]
n1 = current[property_name]
d0 = previous["Timestamp_Sys100NS"]
d1 = current["Timestamp_Sys100NS"]
if n0 is None or n1 is None:
return

return (n1 - n0) / (d1 - d0)