-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Support for using procstat without pgrep #3558
Comments
The go-ps API is very limited, so I don't think it would be suitable. Also, gopsutil can do all of this and is already a dependency so I would be more likely to try to create a pgrep replacement using it, but we need to pay close attention to performance. Currently in Windows you should use the |
How would I get memory and cpu stats for a process on windows? |
I can go through gopsutil for this as well if you think that would be cleaner |
Previously when using gopsutil for this I have found it to be a little on the slow side. This was over a year ago so things may have changed. I have contributed code to gopsutil in the past. I can implement this however you would like but I have a working version using go-ps |
Another issue with go-ps is that it is using cgo, but we currently cross-compile for Darwin and Windows. I wouldn't be very surprised if gopsutil's method is slower in Windows though. You can get memory and cpu stats in Windows with win_perf_counters, check this example: https://github.com/influxdata/telegraf/tree/master/plugins/inputs/win_perf_counters#process |
Whats the problem with CGO? It's relatively easy to still cross compile with CGO. I do it on a bunch of projects. Gopsutil works with or without cgo. They have a common pattern of _no_cgo files and _cgo files. Would you be happy with it if I just leverage gopsutil and benchmark it? Thanks for working with me on this! |
The main issue is we need to setup the builds to do this, also at this time we want to make sure not to introduce any build requirements that will make compilation more difficult for Telegraf users, so no shared objects or such. I'll also mention that we are somewhat sensitive to increasing the binary size unless there is a clear benefit.
Yes, lets take a look. Even if it's slower maybe we could use it on Windows only, which might be required anyway since I suspect many users rely on quirks of pgrep and we don't want to break backwards compatibility. |
I am working my way through an implementation. So far I have it working but for things like pattern matches it's really slow. gs-go version returns in 0.01 seconds and the gopsutil version takes 6 seconds to... |
I have a PR to gopsutil that adds support for querying by cmdline and Name of a process. This allows us to get this to work on windows in a way that performs. |
Proposal:
I would like to submit a PR to change proc stats to use go-ps instead of pgrep. This would allow pattern matching to work in a cross platform way. I am willing to do the work for this but I wanted to make sure that the change would be accepted.
Current behavior:
proc stats can not do pattern matching on windows
Desired behavior:
proc stats can do pattern matching on windows
Use case: [Why is this important (helps with prioritizing requests)]
This will allow me to leverage telegraf instead of rolling my own solutions to monitor java processes in windows.
The text was updated successfully, but these errors were encountered: