[pve-devel] [PATCH pve-container] fix hardcoded CT uptime in vmstatus
Thomas Lamprecht
t.lamprecht at proxmox.com
Wed Sep 30 14:20:16 CEST 2015
Implement the container uptime by susbtracting the ctime from the
container pid file from the actual time.
This mirrors the behaviour of lxcfs, see get_pid1_time() in lxcfs.c.
This hass some limitations, like frozen or live migrated containers
falsify the real uptime. But as it shows everytime the uptime like
a uptime command in the container would this is forgivable, for now.
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
src/PVE/LXC.pm | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 99496f9..ccd8c27 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -805,7 +805,9 @@ sub vmstatus {
my $d = $list->{$vmid};
next if $d->{status} ne 'running';
- $d->{uptime} = 100; # fixme:
+ my $pid = find_lxc_pid($vmid);
+ my $ctime = (stat("/proc/$pid"))[10]; # 10 = ctime
+ $d->{uptime} = time - $ctime; # the method lxcfs uses
$d->{mem} = read_cgroup_value('memory', $vmid, 'memory.usage_in_bytes');
$d->{swap} = read_cgroup_value('memory', $vmid, 'memory.memsw.usage_in_bytes') - $d->{mem};
--
2.1.4
More information about the pve-devel
mailing list