stat on /proc/<pid> is reset when caches are dropped (e.g. from pveperf) so get the uptime like lxcfs it does, via /proc/<pid>/stat
Signed-off-by: Dominik Csapak <[email protected]> --- src/PVE/LXC.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index a107ec2..12310ef 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -127,6 +127,7 @@ sub vmstatus { my $cdtime = gettimeofday; my $uptime = (PVE::ProcFSTools::read_proc_uptime(1))[0]; + my $clock_ticks = POSIX::sysconf(&POSIX::_SC_CLK_TCK); my $unprivileged = {}; @@ -189,8 +190,8 @@ sub vmstatus { next if !$pid; # skip stopped CTs - my $ctime = (stat("/proc/$pid"))[10]; # 10 = ctime - $d->{uptime} = time - $ctime; # the method lxcfs uses + my $proc_pid_stat = PVE::ProcFSTools::read_proc_pid_stat($pid); + $d->{uptime} = int(($uptime - $proc_pid_stat->{starttime}) / $clock_ticks); # the method lxcfs uses my $unpriv = $unprivileged->{$vmid}; -- 2.11.0 _______________________________________________ pve-devel mailing list [email protected] https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
