Re: Container Uptime Discussion
Jim Warner <[email protected]> Thu, 8 Feb 2024 15:22:43 -0600
| Newsgroups | gmane.linux.procps.devel |
|---|---|
| Message-ID | <[email protected]> |
On 2/8/24 2:56 PM, Craig Small (csmall) wrote: > > So, let me get this straight. > Get both PID1 elapsed and uptime. > If PID1 has a shorter elapsed time, then use that's its docker and > friends. e.g. /proc/uptime is 100 seconds, PID1 etimes is 2 seconds = > uptime is 2 seconds > If PID1 has a longer elapsed time, then use that as its lxc. e.g. > /proc/uptime is 1 second, PID1 etimes is 2 seconds = uptime is 1 second. Hi Craig, First call the regular procps_uptime. That double will be either the host (bigger) or an adjusted container (smaller) running time. Then get both PIDS_TIME_START and PIDS_TIME_ELAPSED for PID1. If PIDS_TIME_START is greater than the uptime seconds it indicates an lxc container and /proc/uptime can be used. Otherwise, the existing path is taken. But watch out for a complication presumably on a host. The new call to procps_uptime might fail if /proc was mounted subset=pid. In that case the existing path should be taken. Regards, Jim