It is currently November 21st, 2018, 3:06 pm

PerfMonPDH Performance Data Plugin

Share your custom plugins and applications to enhance Rainmeter.
buckb
Posts: 34
Joined: February 12th, 2018, 12:47 am

PerfMonPDH Performance Data Plugin

buckb » August 3rd, 2018, 12:16 am

Overview

Since the PerfMon plugin has been deprecated, I needed to move my skins to a new source of performance data. Although UsageMonitor has great new features and much of what I need, I decided to try my hand at a plugin of my own. I have called my plugin PerfMonPDH. It has been written from the ground up using the Windows Performance Data Helper interface to retrieve performance data.

PerfMonPDH borrows features from the original PerfMon plugin and from the new UsageMonitor plugin. It is organized using the parent/child model. Parent measures query and process peformance data, while child measures are used to retrieve the data that the parent has generated.

Anything that could be done with the original PerfMon plugin can be done with PerfMonPDH, although changes must be made to your skin to use PerfMonPDH's parent/child structure and different option names. Many of UsageMonitor's features are supported, but not all:
  • PerfMonPDH does not support UsageMonitor's Alias, Rollup and Percent options
  • PerfMonPDH does not support UsageMonitor's Total and Average indexes
  • PerfMonPDH does not support UsageMonitor's PIDToName option
  • PerfMonPDH is not multithreaded
I have tested the plugin on US English Windows 7 (64-bit) and US English Windows 10 Home and Pro (64-bit), and with Rainmeter 4.2.0 (32-bit & 64-bit).

PerfMonPDH's performance is somewhere between that of the original PerfMon and UsageMonitor. PerfMonPDH does not have the sophisticated counter aggregation and sharing that UsageMonitor has, nor is PerfMonPDH multithreaded like UsageMonitor. PerfMonPDH has been architected, however, to be multithreaded should the need arise.

In light of UsageMonitor's feature set, I have no idea if PerfMonPDH is of interest to anyone but me. For my purposes, PerfMonPDH is complete, although I continue to tinker around the edges. I am mostly settled on the parent and child types and options, but I might still make changes.

If you choose to give PerfMonPDH a go, I welcome your comments and suggestions. If there is sufficient interest, and after a round or two of bug fixes (there are *always* bugs!), I'll post the source.


Installation

Unzip the SystemMonitor skin into your skins directory.
Copy the appropriate version (32-bit or 64-bit) of PerfMonPDH.dll to your Rainmeter Plugins directory.


Documentation

There is a "readme.txt" in the zip file's Plugins directory.


Example skins

I've written a set of example skins, called SystemMonitor, to exercise the plugin. The "System.ini" variant demonstrates use of the plugin's PerfMon-style measures, while the other variants demonstrate the plugin's UsageMonitor-style measures. The skins share a common control interface:
  • Click on a column heading to sort by that column
  • Click on "Rollup: On/Off" to enable or disable rollup
  • Click on "Filter: On/Off" to enable or disable Blacklist and Whitelist filtering
  • Click on "Sort: up/down:" to switch between SortOrder=Ascending and SortOrder=Descending
  • Hover over the label "Filter:" to see the Blacklist and Whitelist
  • Position the mouse cursor anywhere in the statistics display area and use the mouse wheel to scroll the list
  • Position the mouse cursor anywhere in the statistics display area and click the middle mouse button to reset the list to the beginning
  • Click on the skin's title to cycle to the next variant

Localization

PerfMonPDH uses English, non-localized Object and Counter names. Skins used on non-English installations of Windows should work correctly, but they must still use the English Object and Counter names. This functionality HAS NOT BEEN VERIFIED, but is based on my reading of the Microsoft documentation for the PDH interface. Given the grief localization caused UsageMonitor's developer(s), I'm a bit dubious of Microsoft's claims regarding the PDH interface.

capture1.jpg
capture2.jpg
capture3.jpg

--buckb

Version History

1.0.0.0 Initial release
1.0.0.1 Suppressed unneeded debugging log entries & fixed up/down arrow character encoding
2.0.0.0 Added support for rollup, changes to option names require skin updates
2.0.0.1 Included source code with release (VisualStudio 2015)
2.0.1.3 Added LogicalDisk rollup, new child measures, changed option "DisplayName"
You do not have the required permissions to view the files attached to this post.
Last edited by buckb on September 4th, 2018, 6:39 pm, edited 5 times in total.
User avatar
SilverAzide
Posts: 494
Joined: March 23rd, 2015, 5:26 pm

Re: PerfMonPDH Performance Data Plugin

SilverAzide » August 3rd, 2018, 11:59 am

Wow, this is an impressive piece of work! :thumbup:
Just curious... what was your motivation for creating this with respect to what UsageMonitor does? Is there some use-case that UsageMonitor does not address?
DeviantArt Gadgets More...
rxtd
Posts: 63
Joined: April 30th, 2017, 11:51 am

Re: PerfMonPDH Performance Data Plugin

rxtd » August 3rd, 2018, 1:28 pm

SilverAzide wrote:Is there some use-case that UsageMonitor does not address?
I haven't explored PerfMonPDH's abilities yet but at least UsageMonitor can't list all instances of a category without sorting / with sorting by instance name / sorted by anything aside main counter. Or maybe I just don't know how to do it.
And looks like PerfMonPDH can do such a thing with flying colours.
And probably this plugin has something to do with this post: UsageMonitor Discussions

buckb, huge thanks! :thumbup:
I've been looking for a method to monitor my disks in rainmeter for some time, and you have just solved my problems!
buckb
Posts: 34
Joined: February 12th, 2018, 12:47 am

Re: PerfMonPDH Performance Data Plugin

buckb » August 3rd, 2018, 7:43 pm

SilverAzide wrote:Wow, this is an impressive piece of work! :thumbup:
Just curious... what was your motivation for creating this with respect to what UsageMonitor does? Is there some use-case that UsageMonitor does not address?
Thanks, SilverAzide. rxtd is right about my motivation for writing PerfMonPDH. To elaborate:
  • I prefer to monitor my disks using PhysicalDisk counters. PhysicalDisk instances look like "0 C: D:", "1 E:", "2 F:", etc. However, on one of my systems, the disk number part can change from boot to boot. So sometimes I get "1 E:" and "2 F:', and other times I get "2 E:" and "1 F:". Being able to partially match an instance name (for example, having "E:" match to "1 E:") makes my skin much simpler.
  • Sometimes I'd like to get a list of all current instances, even if some instances may have counter values that are currently zero. A variation of this is having the ability to distinguish between an instance that is non-existent, and an instance whose current counter values are zero.
  • I wanted to make it easier to get a set of counter values for a given instance. For example, "get processor utilization, working set, and read/write bytes for the top process as sorted by processor utilization". I chose the parent/child structure to make it clear that all of the requested counter values are from the same snapshot of performance data.
I'd say these are the features that drove PerfMonPDH's development. I tossed in a few others (sorting options, result string options) along the way.

Initially I thought I'd just make a plugin that returned all instances for a given set of counters, encoded as one long string (maybe XML formatted?). A skin could then use Lua to pick apart the data, and filter and sort as needed. As you can see, I decided to just do the work in the plugin. I might still add a "Type=GetAllInstances" measure, or something like that.


--buckb
User avatar
SilverAzide
Posts: 494
Joined: March 23rd, 2015, 5:26 pm

Re: PerfMonPDH Performance Data Plugin

SilverAzide » August 3rd, 2018, 10:04 pm

buckb wrote:Sometimes I'd like to get a list of all current instances, even if some instances may have counter values that are currently zero. A variation of this is having the ability to distinguish between an instance that is non-existent, and an instance whose current counter values are zero.
Oh, yes! I noticed your plugin seems to be the only one I've tried recently that will return as many "top processes" as I want, regardless of the value. Neither the old PerfMon nor the new UsageMonitor return items where the value is zero (or < 0.01 actually).
DeviantArt Gadgets More...
rxtd
Posts: 63
Joined: April 30th, 2017, 11:51 am

Re: PerfMonPDH Performance Data Plugin

rxtd » August 4th, 2018, 2:12 am

Well, I have some suggestions.
First, about your example skins.
You saved .ini files in 1-byte encoding, and you are apparently using Windows with different default charset, so some symbols are not as intended:
2018-08-04_08-04-13.png
2018-08-04_08-04-32.png
You can use UTF-16 LE to prevent this.

Also I noticed some errors in bangs (open quotes missing):
2018-08-04_08-06-38+.png
Rainmeter seems to understand these bangs though.
Second: it would be very convenient to have a rollup feature, especially since I have a couple of hundreds of tabs in chromium-like browser, but when I think about implementing method of it I can't come up with solution.
Rollup makes sense for non-shared resources such as processor time or private memory but shared resources like working set is a problem. And unique values like PID just can't be rolled up.
I don't understand how UsageMonitor's rollup works but it apparently sums PIDs so maybe it just sums all values that probably leads to incorrect memory consumption monitoring.
Maybe it can be separate mode for rollup with specifying what to do with each counter. Something like this:

Code: Select all

CounterList=ID Process | % Processor Time | Working Set | IO Data Bytes/sec
Rollup=Max | Sum | Average | Min
But it still doesn't make much sense for shared and unique values.
Maybe there is Windows API function that can count real resource consumption of a set of processes? Then it would be possible to create a special "processes with rollup" mode which sums non-shared counters and queries system for memory and other shared resources.

What do you think about all of it?
You do not have the required permissions to view the files attached to this post.
Last edited by rxtd on August 6th, 2018, 3:25 pm, edited 1 time in total.
buckb
Posts: 34
Joined: February 12th, 2018, 12:47 am

Re: PerfMonPDH Performance Data Plugin

buckb » August 4th, 2018, 4:00 am

rxtd wrote:Well, I have some suggestions.
Thank you for the fixes, rxtd. I hadn't paid any attention to the encoding of the skin files (bad me). I'll change the files to UTF-16 LE. In the meantime, the symbols you pointed out are supposed to be up and down arrows. The encodings are "xE1" and "xE2". I'll be adding the missing quote marks as well.

As to implementing a rollup function, I ran across the same issues you discussed in your post. As you mentioned, "shared and unique values" don't lend themselves to rollup. Also, in addition to the {Min, Max, Sum, Average} options you suggested, should there be syntax to indicate different handling for the Raw and Formatted versions of the counters?

I tend to think that if a rollup capability is added, it should be up to the skin developer to make sense of shared and unique values, and to understand the limitations imposed by the range of underlying counter data available.

I've tried to keep PerfMonPDH (mostly) counter agnostic, meaning the plugin shouldn't have to know that the skin is requesting "Process" or "LogicalDisk" or "Network Interface" counters. Out of necessity, the plugin already stretches this definition by manipulating instance names for "Process", "Thread", and "GPU" objects. I think more detailed process analysis using additional Windows APIs would be better served by a dedicated plugin.

--buckb
buckb
Posts: 34
Joined: February 12th, 2018, 12:47 am

Re: PerfMonPDH Performance Data Plugin

buckb » August 4th, 2018, 9:16 pm

Updated plugin to version 1.0.0.1
Please see first post for version history.

--buckb
rxtd
Posts: 63
Joined: April 30th, 2017, 11:51 am

Re: PerfMonPDH Performance Data Plugin

rxtd » August 5th, 2018, 3:43 pm

Thank you for detailed answer, buckb.
I found one little mistake that hurt my eyes a little bit. In the readme file in line 370 "If you known" should probably be "If you know". Sorry if I'm wrong, English is not my native language.
Speaking of readme. Your plugin has really good documentation. I had some questions about it's usage and possibilities and I found all answers within single readme file. FAQ before example skin was especially useful :thumbup:

As of the rollup feature—I think it is pretty useful even in "sum all counters" form so would you implement it in just "sum all" form or {sum,min,max,avg} form it would be nice. I don't think that all skin creators will be using it wisely but it's better to have an ability than not to have.
I agree that dedicated plugin for more specialized data processing is better.
One crazy idea had just came to mind: UsageMonitor's "rollup" is a simplified SQL's "group by". And for me it looks like functions {sum,min,max,avg,count} applied to each queried counter would be reasonably full implementation of "group by" for any need. Probably there should also be ability to query a counter several times—to apply different functions to it.
I don't know if there is anything, aside instance names, that could use grouping, but if there is then it will be useful to have an ability to group by any counter. And maybe by several counters, in series.
Raw and formatted values can be treated by adding suffix to aggregation function name. For example, Sum and SumRaw, or SumRaw and SumFormatted.

I don't know if it would be overkill on not to implement SQL-like "group by". And what will be performance impact.
All in all, it's your plugin, and you are the one who would need to spend time to implement it, so it's your decision :confused:

By the way, here is another suggestion: can you add option to disable "syncing of raw and formatted counters"? That is: I want to get raw values on first update.
Delaying data makes sense for skins that use mixed values like the ones that you provided as an example but it is not needed if I only use raw values.

Oh, and one more thing.
I tested your this plugin with the example skin pack on Windows 8.1 with Russian as main language, and it works without any problem.
buckb
Posts: 34
Joined: February 12th, 2018, 12:47 am

Re: PerfMonPDH Performance Data Plugin

buckb » August 6th, 2018, 2:44 am

rxtd wrote: I found one little mistake that hurt my eyes a little bit. In the readme file in line 370 "If you known" should probably be "If you know". Sorry if I'm wrong, English is not my native language.
Corrections are always welcome, even (especially?) for typos. And your English is quite good!
rxtd wrote: One crazy idea had just came to mind: UsageMonitor's "rollup" is a simplified SQL's "group by".
I don't see much use for "group by" other than by instance name. Perhaps there are some server-oriented counters that could benefit from such a grouping, but I haven't looked at those. For me, such a feature would be outside the scope of this plugin without an example of an interesting use case.
rxtd wrote: By the way, here is another suggestion: can you add option to disable "syncing of raw and formatted counters"?
I assume you want to disable the syncing of raw and formatted counters so that your skin can more quickly begin to display valid data? When I first started coding the plugin, I did make raw counters available at the first update. However, I later decided to enforce syncing so that skins would see a more consistent view of performance data. Are you referring to the Type=GetRawCounter child measure only, or do you want to get first-update data from Type=GetRawCounterSorted as well?



I am thinking about how best to implement rollup and should have some news on that front later in the week.

--buckb