elastic / elastic-agent-system-metrics

Apache License 2.0
0 stars 22 forks source link

Fix GetSelf() logic when running with alternate hostfs #149

Closed fearful-symmetry closed 2 months ago

fearful-symmetry commented 2 months ago

Closes https://github.com/elastic/elastic-agent-system-metrics/issues/147

What does this PR do?

This fixes an issue where Stats.GetSelf() would fail when run inside a container while using a hostfs path, as the PID returned by os.Getpid() would not be valid outside the container runtime.

This changes the logic, so if we have a hostfs set, GetSelf will fetch the pid from /hostf/proc/self.

Why is it important?

This is a bug.

Checklist