go-sysinfo
go-sysinfo copied to clipboard
Feat/load average implementation
This should close #120
As I said on the issue, I had some problems for the darwin implementation, since I had to do it from a VM. I tested it without CGO (CGO_ENABLED=0) and still worked.
The way the load is parsed seems a bit tricky, although it's the standard way of doing so for BSD systems using Golang. I tried parsing the values the same way you did on others SysctlRaw without any luck (I'd appreciate an explanation if you know the reason, I'm still pretty new to Golang)
If anything needs some changes, please let me know!
Linux host: Fedora 36 Workstation, Kernel 5.19.15-201 Darwin host: macOS Catalina, Version 10.15.7
💚 CLA has been signed
:green_heart: Build Succeeded
the below badges are clickable and redirect to their specific view in the CI or DOCS
![]()
![]()
![]()
![]()
![]()
Expand to view the summary
Build stats
-
Start Time: 2022-10-27T22:49:25.775+0000
-
Duration: 9 min 43 sec
Test stats :test_tube:
| Test | Results |
|---|---|
| Failed | 0 |
| Passed | 206 |
| Skipped | 4 |
| Total | 210 |
I also put up a PR #41 that adds a little CLI that makes it a bit easier to test and demonstrate the package.
Hey @ariasmn I tested this on my Mac and everything you've done here is working great ok_hand -- Except for one minor patch/change you forgot to add sweat_smile
commit 93d5e2259916ce787119d86ca91669125fbf6490 Author: James Mills <[email protected]> Date: Thu Oct 20 08:43:26 2022 +1000 Fix missing embedding of LoadAverage interface in Host interface diff --git a/types/host.go b/types/host.go index d2911ee..2ffee7b 100644 --- a/types/host.go +++ b/types/host.go @@ -24,6 +24,7 @@ import "time" // implementation is unable to collect all of the necessary data. type Host interface { CPUTimer + LoadAverage Info() HostInfo Memory() (*HostMemoryInfo, error) }
Woops, you are right! Glad that everything is working for you. Let's wait for the review from the people at Elastic so I can fix everything in one go.
Thanks for your time!
No worries 🤗
@ariasmn Can you see to the above? 🙏 I'd really like to see this PR merged 👌
@prologic @andrewkroh Done!
Let me know if anything still needs some work.
/test
Didn't even think about Windows now that I see the tests failing to be honest.
@andrewkroh If I'm not mistaken, the only thing that I should do is just implement the LoadAverage function on the host_windows.go? Something like:
func (h *host) LoadAverage() (*types.LoadAverageInfo, error) {
return nil, fmt.Errorf("LoadAverage is not available for this platform %w", types.ErrNotImplemented)
}
I just added a commit to the PR, adding the missing functions on Windows and AIX hosts.
Also, I updated the README as well to note the new LoadAverage interface support.
Let me know if anything is still left (sorry that the PR is bouncing back and forth this much, completely my fault!)
/test
/test
/test
@andrewkroh What's the status of this? Just asking to know if there's anything left I should do on my side.