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] per CPU times returns percentage instead of times #600

Closed
requilence opened this issue Nov 1, 2018 · 2 comments
Closed

[Windows] per CPU times returns percentage instead of times #600

requilence opened this issue Nov 1, 2018 · 2 comments

Comments

@requilence
Copy link

On Windows, when using cpu.Times(true) it returns a percentage for each metric instead of time.
https://github.com/shirou/gopsutil/blob/master/cpu/cpu_windows.go#L155

It is very unclear because you totally expect that Times return CPU times inside TimesStat struct

@Lomanic
Copy link
Collaborator

Lomanic commented Nov 5, 2018

Looks like it was already reported in #420 (comment), PR welcomed.

@Lomanic
Copy link
Collaborator

Lomanic commented Dec 9, 2018

Fixed by #611.

@Lomanic Lomanic closed this as completed Dec 9, 2018
nikita-vanyasin added a commit to cloudradar-monitoring/cagent that referenced this issue Feb 20, 2019
because the shirou/gopsutil#600 was fixed in the new gopsutil version
nikita-vanyasin added a commit to cloudradar-monitoring/cagent that referenced this issue Feb 28, 2019
because the shirou/gopsutil#600 was fixed in the new gopsutil version
troian pushed a commit to cloudradar-monitoring/cagent that referenced this issue Feb 28, 2019
* Remove unused dependencies

* Update gopsutil library to v2.19.01

* Simplify and refactor cpu utilization calculation

because the shirou/gopsutil#600 was fixed in the new gopsutil version

* Update cpu Times retrieval and processing for Windows (eliminating slow WMI queries)

Now it uses winapi call to NtQuerySystemInformation.
Added module for wrapping the work with winapi

* Improve listing of top consuming processes for windows

- Use winapi call, where PID is available
- Remove unused functions
- Fix counting of skipped processes for linux top implementation

* Change the way 'Load' value is calculated for processes listed by 'top'

Now the max values is 100%, where 100% is a full load of all available cores.

* Remove 'Load' field from JSON result for the list of 'top' processes

Also, the 'command' field will be reported only if it's not empty. (ex. for Windows it's not available)

* Rename JSON 'Load' fields for the listing of 'top' processes

* Skip process with PID=0 (System Idle) when listing 'top' processes for Windows

* Fix cpu utilisation analysis for the processes with same name

now the PID of the process is available at all systems, so we can use it for comparison

* Added configuration values regarding CPU Utilisation Analysys to result JSON

Also renamed the field for consistency

* Add CPU Utilisation config values to result JSON only if analysis is active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants