shirou / gopsutil

psutil for golang
Other
10.48k stars 1.58k forks source link

Suggestion: Expose Paging stats for windows #399

Open mmoura85 opened 7 years ago

mmoura85 commented 7 years ago

It would be useful to add an additional struct for the performance information on paging for Windows, similar to the swap struct.

I'am happy to submit a PR for this. Also there are 3 fields: HandleCount, ProcessCount, ThreadCount that could potentially sit with another struct.

Here is the documentation that I'am referring to.

shirou commented 7 years ago

gopsutil already use GlobalMemoryStatusEx to get memory and it includes paging info (https://github.com/shirou/gopsutil/blob/master/mem/mem_windows.go#L21). but yes, it is not implemented yet.

System wide HandleCount and ThreadCount is not provided yet to other platforms, I think adding new value should be considered. If you send PR with all of the platforms, at least Linux, darwin and FreeBSD, I can merge it easily.

mmoura85 commented 7 years ago

Ok, I will add HandleCount and ThreadCount to the VirtualMemoryStat struct and look into getting both those values for the other platforms, though I'm not familiar with some of them.

As for the paging data being returned from GlobalMemoryStatusEx, please note that according to the documentation that it may not always be the system wide value, as that function will return the lesser of either the system wide value or the current process.

Also I can get the page table size for windows and populate the pageTables field in the VirtualMemoryStat struct. I just want to confirm that if you prefer the standard for of measurement to be bytes? as the value returned as megabytes?