-
Notifications
You must be signed in to change notification settings - Fork 93
FreeBSD support #40
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
FreeBSD support #40
Conversation
* Add HostInfo support for FreeBSD Initial implementation of HostInfo for FreeBSD platforms. * Use os.SameFile to compare cwds On some platforms (e.g. FreeBSD) user home directories are symlinks and os.Getcwd will return the symlink path. On FreeBSD CWD for processes that's not the running process will not give the symlink but the resolved path causing the test to fail at this point. Fix is to use the os.SameFile call to resolve both Os.Getcwd and CWD. * Add basic support for ProcessInfo on FreeBSD. Implement Process(), Self() and Processes() to the bare minimum. That is passing all basic tests. * Add support for OpenHandleEnumerator and OpenHandleCounter. * Add support for Environment * Review fixes. - Fix issue on FreeBSD 12. - Minor cosmetic issues. * Clean up build process. - Remove cgo build directives from things not needing it. - Add linker flags into .go files.
| Sl int16 | ||
| _ int16 // cgo doesn't generate the same alignment as C does | ||
| Sw int16 | ||
| Vm int32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
struct field Vm should be VM
| const kernCptimeMIB = "kern.cp_time" | ||
| const kernClockrateMIB = "kern.clockrate" | ||
|
|
||
| func Cptime() (map[string]uint64, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported function Cptime should have comment or be unexported
| } | ||
| defer C.procstat_close(procstat) | ||
|
|
||
| var count C.uint = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should drop = 0 from declaration of var count; it is the zero value
| const osreleaseMIB = "kern.osrelease" | ||
| const osrevisionMIB = "kern.osrevision" | ||
|
|
||
| func OperatingSystem() (*types.OSInfo, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported function OperatingSystem should have comment or be unexported
| return numfreebuffers, nil | ||
| } | ||
|
|
||
| func KvmGetSwapInfo() (kvmSwap, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported function KvmGetSwapInfo should have comment or be unexported
| const devNull = "/dev/null" | ||
| const kvmOpen = "kvm_open" | ||
|
|
||
| func PageSize() (uint32, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported function PageSize should have comment or be unexported
|
|
||
| const kernelHostUUIDMIB = "kern.hostuuid" | ||
|
|
||
| func MachineID() (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported function MachineID should have comment or be unexported
|
|
||
| const kernelReleaseMIB = "kern.osrelease" | ||
|
|
||
| func KernelVersion() (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported function KernelVersion should have comment or be unexported
|
|
||
| const kernBoottimeMIB = "kern.boottime" | ||
|
|
||
| func BootTime() (time.Time, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported function BootTime should have comment or be unexported
|
|
||
| const hardwareMIB = "hw.machine" | ||
|
|
||
| func Architecture() (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported function Architecture should have comment or be unexported
|
I've encounter the the problem on FreeBSD |
|
@mko-io This pull request is very old, I haven't updated it in a while. If you still need FreeBSD support for sysinfo I'd be happy to review it. |
|
@dbolcsfoldi would be nice, as this would make metricbeats on freebsd usable |
|
@dbolcsfoldi - I'm interested in having freebsd support included in this module. I might even be able to spare some cycles if help is needed, though I have limited Go experience. I'm not sure if anybody on this thread is an Elastic employee, but input would be helpful! |
|
Closing this as we have #126 which incorporates this with some updates. Thanks @dbolcsfoldi . |
Add FreeBSD provider. When I was attempting to use this package on FreeBSD I noticed the provider was completely missing, so I implemented a provider for FreeBSD.
Note that for the system_test.go that test's the current working directory I modified the test code to compare the inodes using os.SameFile instead of straight file comparison. The reason is that os.Getcwd() will return any path to CWD (either symlink or real path) but for any process except the calling pid (i.e. calling C.getcwd()) will return the real path and not the symlink.
I've tested it on FreeBSD 11.2 and 12.0 using 'go test', let me know if you need anything else to be run and please feel free to leave any review comments/reject the pull request etc.