From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 8E63D62E4A for ; Mon, 8 Feb 2021 15:10:38 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8293723275 for ; Mon, 8 Feb 2021 15:10:38 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 0B67423268 for ; Mon, 8 Feb 2021 15:10:38 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id C398344FFF; Mon, 8 Feb 2021 15:10:37 +0100 (CET) Message-ID: <93d83dc6-acd2-e8d3-309b-69402b2b3252@proxmox.com> Date: Mon, 8 Feb 2021 15:10:36 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:86.0) Gecko/20100101 Thunderbird/86.0 Content-Language: en-US To: Proxmox VE development discussion , Alexandre Derumier References: <20210207133645.3254164-1-aderumier@odiso.com> From: Thomas Lamprecht In-Reply-To: <20210207133645.3254164-1-aderumier@odiso.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.061 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.001 Looks like a legit reply (A) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH V2 pve-common] add get_pressure_stat X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Feb 2021 14:10:38 -0000 On 07.02.21 14:36, Alexandre Derumier wrote: > Signed-off-by: Alexandre Derumier > --- > src/PVE/CGroup.pm | 42 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 42 insertions(+) > > diff --git a/src/PVE/CGroup.pm b/src/PVE/CGroup.pm > index 71d0846..cbd77cb 100644 > --- a/src/PVE/CGroup.pm > +++ b/src/PVE/CGroup.pm > @@ -365,6 +365,48 @@ sub get_memory_stat { > return $res; > } > > +sub get_pressure_stat { > + my ($self) = @_; > + > + my $res = { > + cpu => { > + some => { avg10 => 0, avg60 => 0, avg300 => 0 } > + }, > + memory => { > + some => { avg10 => 0, avg60 => 0, avg300 => 0 }, > + full => { avg10 => 0, avg60 => 0, avg300 => 0 } > + }, > + io => { > + some => { avg10 => 0, avg60 => 0, avg300 => 0 }, > + full => { avg10 => 0, avg60 => 0, avg300 => 0 } > + }, > + }; > + > + my ($path, $ver) = $self->get_path(undef, 1); > + if (!defined($path)) { > + # container or VM most likely isn't running > + return undef; or return $res? it has already the zero defaults we'd set in pve-container anyway? > + } elsif ($ver == 2) { > + > + foreach my $type (qw(cpu memory io)) { > + if (my $fh = IO::File->new ("$path/$type.pressure", "r")) { > + while (defined (my $line = <$fh>)) { > + if ($line =~ /^(some|full)\s+avg10\=(\d+\.\d+)\s+avg60\=(\d+\.\d+)\s+avg300\=(\d+\.\d+)\s+total\=(\d+)/) { > + $res->{$type}->{$1}->{avg10} = $2; > + $res->{$type}->{$1}->{avg60} = $3; > + $res->{$type}->{$1}->{avg300} = $4; > + } > + } > + $fh->close; > + } > + } > + } else { > + die "bad cgroup version: $ver\n"; So if the v1 controller does not support it this results in die's in the vmstatus sub in pve-container where this is used without eval? That would be not so ideal, as the v1 one is currently the default. Maybe just return undef or the defaults instead? (sorry, did not saw this when checking the v1) > + } > + > + return $res; > +} > + > # Change the memory limit for this container. > # > # Dies on error (including a not-running or currently-shutting-down guest). >