systeminformation icon indicating copy to clipboard operation
systeminformation copied to clipboard

Set alternative `/proc` location

Open nflaig opened this issue 2 years ago • 2 comments

The go library gopsutil allows to set a custom /proc location via HOST_PROC environment variable. This is useful if the application is running inside a container to get proper system process info.

Other host metric collectors running inside docker also support this, e.g. prometheus node exporter where the locations can then be mounted from the host to the container

volumes:
   - /proc:/host/proc:ro
   - /sys:/host/sys:ro
   - /:/rootfs:ro

Wondering if there is a similar feature in this library, I was browsing a bit through the source code but did not find how I can customize this.

nflaig avatar Feb 16 '23 13:02 nflaig

@nflaig currently there is no such option but I will try to add this ...

sebhildebrandt avatar Feb 20 '23 07:02 sebhildebrandt

To add a bit more context, there are a few functions which do not report the desired data if the process is running inside container (docker)

  • disksIO() always returns 0 for rIO and wIO
  • networkStats() will return a local network instead of external one, this might not be solvable even with mount points but need to investigate
  • fsSize() might not show all relevant file systems, this highly depends on the setup I think, so far for the setups I tested, even without the mount point the data looks good
  • other functions such as cpu() and mem() look mostly correct although, cpu() seems to return the count of logical CPU cores for physicalCores which is not correct as this is equal to the value of cores

nflaig avatar Feb 20 '23 10:02 nflaig