Commit 10591607 authored by Dietmar Maurer's avatar Dietmar Maurer

fix openvz vmstatus list

parent 1e968bde
...@@ -64,7 +64,7 @@ my $last_proc_vestat = {}; ...@@ -64,7 +64,7 @@ my $last_proc_vestat = {};
sub vmstatus { sub vmstatus {
my ($opt_vmid) = @_; my ($opt_vmid) = @_;
my $list = config_list(); my $list = $opt_vmid ? { $opt_vmid => { type => 'openvz' }} : config_list();
foreach my $vmid (keys %$list) { foreach my $vmid (keys %$list) {
next if $opt_vmid && ($vmid ne $opt_vmid); next if $opt_vmid && ($vmid ne $opt_vmid);
...@@ -102,6 +102,8 @@ sub vmstatus { ...@@ -102,6 +102,8 @@ sub vmstatus {
} else { } else {
$d->{ip} = '-'; $d->{ip} = '-';
} }
} else {
delete $list->{$vmid};
} }
} }
...@@ -121,7 +123,8 @@ sub vmstatus { ...@@ -121,7 +123,8 @@ sub vmstatus {
$vmid = $2 if defined($2); $vmid = $2 if defined($2);
next if !$vmid; next if !$vmid;
my ($name, $held, $maxheld, $bar, $lim, $failcnt) = ($3, $4, $5, $6, $7, $8); my ($name, $held, $maxheld, $bar, $lim, $failcnt) = ($3, $4, $5, $6, $7, $8);
if (my $d = $list->{$vmid}) { my $d = $list->{$vmid};
if ($d && defined($d->{status})) {
if ($name eq 'physpages') { if ($name eq 'physpages') {
$d->{mem} += int($held * 4096); $d->{mem} += int($held * 4096);
} elsif ($name eq 'swappages') { } elsif ($name eq 'swappages') {
...@@ -138,7 +141,9 @@ sub vmstatus { ...@@ -138,7 +141,9 @@ sub vmstatus {
if (my $fh = IO::File->new ("/proc/vz/vzquota", "r")) { if (my $fh = IO::File->new ("/proc/vz/vzquota", "r")) {
while (defined (my $line = <$fh>)) { while (defined (my $line = <$fh>)) {
if ($line =~ m|^(\d+):\s+/var/lib/vz/private/\d+$|) { if ($line =~ m|^(\d+):\s+/var/lib/vz/private/\d+$|) {
if (my $d = $list->{$1}) { my $vmid = $1;
my $d = $list->{$vmid};
if ($d && defined($d->{status})) {
$line = <$fh>; $line = <$fh>;
if ($line =~ m|^\s*1k-blocks\s+(\d+)\s+(\d+)\s|) { if ($line =~ m|^\s*1k-blocks\s+(\d+)\s+(\d+)\s|) {
$d->{disk} = int ($1 * 1024); $d->{disk} = int ($1 * 1024);
...@@ -169,7 +174,7 @@ sub vmstatus { ...@@ -169,7 +174,7 @@ sub vmstatus {
my $uptime = int ($ut / $hz); my $uptime = int ($ut / $hz);
my $d = $list->{$vmid}; my $d = $list->{$vmid};
next if !$d; next if !($d && defined($d->{status}));
$d->{status} = 'running'; $d->{status} = 'running';
$d->{uptime} = $uptime; $d->{uptime} = $uptime;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment