Fix multiple plugin loading in win_perf_counters#2800
Fix multiple plugin loading in win_perf_counters#2800danielnelson merged 6 commits intoinfluxdata:masterfrom
Conversation
b407c6c to
4c1ba8c
Compare
4c1ba8c to
d194412
Compare
|
Since an instance of Win_PerfCounters is created for each top level plugin, won't this cause every instance to gather stats for the union of all per counters? On other input plugins, we store the data for each plugin config in the main plugin struct to avoid cross talk. |
|
Ah that's a good point, I hadn't thought of that. I'll do some more work on this to remove the global map and cache all of the PDH handles as part of the main struct. Does that sound reasonable? |
|
I've pushed the latest changes - it feels much better now! The plugin no longer collects the same counters multiple times, and it doesn't rely on any global variables. |
|
One part of this plugin that I'm still unsure of is the code related to |
|
It looks to me that it is used by the unittests, not the @PierreF can you review? |
|
Looks good to me. The removal of unused Cleanup function made me think that there is probably a leak of resource (of PDH query handle). For example if we reload telegraf multiple time, it will re-open new query handle without closing old one. |
|
I opened #2843 for the handle leak. Is it even possible currently to reload plugins in Windows? Still should be fixed either by Switching to a ServiceInput or closing every Gather. |
Fixes #1137
The root of the problem for #1137 is that all items are maintained in a global map, but the map is only populated by one config file. Once one config file is parsed, then a flag is set and the plugin will not populate items from any other config.
To fix this, I've removed the flag that checks if a config file has been parsed. Instead, the check for duplicates is done within theAddItemfunction. An item is considered a duplicate if it has the samequery,objectName,counter, andinstance.To fix this, I've removed the global map and instead store items in the main plugin struct.
I've also cleaned up a couple other aspects of this plugin:
metricsvariable- Converted the globalgItemListfrommap[int]*itemtoitemList, which is an already defined type equivalent tomap[int]*itemRequired for all PRs: