go-sysinfo icon indicating copy to clipboard operation
go-sysinfo copied to clipboard

LoadAverage() Where is this used?

Open prologic opened this issue 3 years ago • 12 comments

I'm looking at using your library to provide cross-platform (Linux, BSD and Darwin) System Information, but going through the docs and codebase I don't see where .LoadAverage() is ever used or the interface.

Is this just missing?

prologic avatar Jul 03 '22 05:07 prologic

This looks like an oversight. LoadAverage should have been implemented for both linux and darwin providers as they both support this metric.

andrewkroh avatar Jul 06 '22 15:07 andrewkroh

When will this be implemented? I could use it in my project. Thanks!

amuttsch avatar Sep 09 '22 19:09 amuttsch

I guess someone needs to put up a PR 👌

prologic avatar Sep 09 '22 20:09 prologic

So I would like to give it a try!

@andrewkroh any info about the status? Saw the reference in your other repository about merging both projects into a single one so maybe this is a bit pointless to work on?

ariasmn avatar Oct 08 '22 11:10 ariasmn

There no one slated to work on that merging of features from elastic-agent-system-metrics currently. So I recommend opening a PR to expedite this. Thanks.

andrewkroh avatar Oct 09 '22 14:10 andrewkroh

@andrewkroh Before opening a PR (since I haven't implemented it in the darwin provider), would you like to take a look at the implementation in the linux provider? Here is the commit.

Also, any advice on how to do it for the darwin provider besides spinning up a VM? I guess that there should be a better way to do it, but you tell me.

Thanks for the time!

ariasmn avatar Oct 18 '22 11:10 ariasmn

Code looks good to me 👌 I can help test the Darwin version? 🤔

prologic avatar Oct 18 '22 11:10 prologic

@prologic My main problem is on how to code it without testing while doing so :sweat:

Should I just make the PR with the Linux changes and wait for someone else to open one for the darwin provider? Let's see what Andrew tells us!

ariasmn avatar Oct 18 '22 14:10 ariasmn

What about you mock the expected data sources you expect to use/open/read on Darwin? 😅

prologic avatar Oct 18 '22 15:10 prologic

What about you mock the expected data sources you expect to use/open/read on Darwin? sweat_smile

I can, but as far as I know, Darwin does not have the /proc/loadavg file, and needs to use sysctl vm.loadavg instead. I think the output is way different from Linux, so I can't mock something that I don't know how it should be mocked.

Anyway, I'm setting up a VM so I will get to work on it ASAP, no worries.

ariasmn avatar Oct 18 '22 15:10 ariasmn

But you can define an interface that is common and implement the interface right?

prologic avatar Oct 18 '22 15:10 prologic

@andrewkroh I just created a PR for this.

@prologic You can test it now! As you can see, it was a bit more complicated, and some things needed to be tested in the system itself instead of mocking things up.

Please, let me know if any work is needed or if anything is not worked as expected.

ariasmn avatar Oct 19 '22 17:10 ariasmn