Commit 1e3c9d91 authored by Dietmar Maurer's avatar Dietmar Maurer

avoid warnings about uninitialized values in pvestatd

parent a0528314
......@@ -85,9 +85,15 @@ sub vmstatus {
$d->{nproc} = 0;
$d->{uptime} = 0;
$d->{pctcpu} = 0;
$d->{cpu} = 0;
$d->{relcpu} = 0;
$d->{netout} = 0;
$d->{netin} = 0;
$d->{diskread} = 0;
$d->{diskwrite} = 0;
if (my $ip = $conf->{ip_address}->{value}) {
$ip =~ s/,;/ /g;
$d->{ip} = (split(/\s+/, $ip))[0];
......@@ -168,23 +174,23 @@ sub vmstatus {
if (!defined ($last_proc_vestat->{$vmid}) ||
($last_proc_vestat->{$vmid}->{sum} > $sum)) {
$last_proc_vestat->{$vmid} = { used => 0, sum => 0, pctcpu => 0, relcpu => 0};
$last_proc_vestat->{$vmid} = { used => 0, sum => 0, cpu => 0, relcpu => 0};
}
my $diff = $sum - $last_proc_vestat->{$vmid}->{sum};
if ($diff > 1000) { # don't update too often
my $useddiff = $used - $last_proc_vestat->{$vmid}->{used};
my $pctcpu = int ($useddiff*100/$diff);
my $cpu = int ($useddiff*100/$diff);
$last_proc_vestat->{$vmid}->{sum} = $sum;
$last_proc_vestat->{$vmid}->{used} = $used;
$last_proc_vestat->{$vmid}->{pctcpu} = $d->{pctcpu} = $pctcpu;
$last_proc_vestat->{$vmid}->{cpu} = $d->{cpu} = $cpu;
my $relcpu = $pctcpu;
my $relcpu = $cpu;
$last_proc_vestat->{$vmid}->{relcpu} = $d->{relcpu} = $relcpu;
} else {
$d->{pctcpu} = $last_proc_vestat->{$vmid}->{pctcpu};
$d->{cpu} = $last_proc_vestat->{$vmid}->{cpu};
$d->{relcpu} = $last_proc_vestat->{$vmid}->{relcpu};
}
}
......
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