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

Make the "host FS" location configurable

Open andrewkroh opened this issue 6 years ago • 2 comments

There needs to be a way to pass in the host filesystem location as an option to allow collection from the host machine when operating inside of Docker. This is equivalent to how Metricbeat allows the -system.hostfs CLI option.

This must not be set as a global variable as it is in both gosigar and gopsutil.

I'm thinking to have an API like sysinfo.New(opts types.Option) and have an option that can be used like types.HostFS("/hostfs"). sysinfo.New would return an interface that has methods like Host(), Processes(), Process(), and Self().

And I think only the Linux provider would actually honor this option.

andrewkroh avatar Apr 16 '18 20:04 andrewkroh

This could also allow for testing from the outside because you could point sysinfo at some static directory to mock the proc filesystem. @fearful-symmetry

andrewkroh avatar Dec 17 '19 22:12 andrewkroh

The CSP team finds it useful as well, we run a go binary inside an elastic agent (container) and wish to collect the host's proc info.

uri-weisman avatar Jul 07 '22 08:07 uri-weisman