From patchwork Tue Sep 10 21:32:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 8105 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature RSA-PSS (4096 bits)) (Client CN "mail01.haj.ipfire.org", Issuer "R10" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4X3H3y1fqvz3wdh for ; Tue, 10 Sep 2024 21:32:46 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "E6" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4X3H3w3hV3zr2; Tue, 10 Sep 2024 21:32:44 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4X3H3w1bWXz34Gv; Tue, 10 Sep 2024 21:32:44 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature RSA-PSS (4096 bits)) (Client CN "mail01.haj.ipfire.org", Issuer "R10" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4X3H3t3T25z33GZ for ; Tue, 10 Sep 2024 21:32:42 +0000 (UTC) Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4X3H3s517yzPV for ; Tue, 10 Sep 2024 21:32:41 +0000 (UTC) Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b="A/Uk9vty"; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org; dmarc=pass (policy=reject) header.from=disroot.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1726003961; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:dkim-signature; bh=rl8zFBU+DYAKquJlmsbpVZF8lGDUuSAookwQmPLTFug=; b=UAiHpmLk4hO1qzE8IaD60HCs+qnh9b3Kte6hhGZDXXLrq6eZv/7ndPa/kBiqOuCsj0Nnun aI3JpeEwiOn9RqxXVwDBGu0+Mq4OUTRY+ZiIrmeS7nBI6SEIsaW+9J+KuaPHebpQ6kvkbK qGKG4bOEglXo4tcFtx8Y4OZDLN9a5uxDmlLe9P0PhImfn+roBIxluKPJMRi83TqUJhqDOi gy9byAaEFghL8fulfLfEvgs0yN5nqQN8zteyJ3JnbiX43WaIXmYCaqii1vhEgIvPm4DJpt 3sD7ygwzJvPttXh36w0jCTzfukw0HJFhymir97Ocvs4GySgGLftqlvx6IvOIfA== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b="A/Uk9vty"; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org; dmarc=pass (policy=reject) header.from=disroot.org ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1726003961; a=rsa-sha256; cv=none; b=lin8V34TCqf7LwvylVHMUEE86Jli/q0xzSUAZwPrkr63IEZw3b4YA21L0056ogVgs+GdUL 7YjZIjvFASDbJp2+OWHu6SvXgbdjo2Yfcf4fIVRJQ+KWi5k4bHahv/Hllpq91hj9ODbPVb cv6tFJeszD84T/4iVKqsHq3MaHlmt1PFLTn0r1sioMIDf+k1iPsqzkGDxRs5pyPrXCV5Lt gunqdnu8t/s06l2G78blJQLhO3cn1bg0eMBWriD/mswIBqtpmTckw5enF0OhUTCx/me+SN ZXsX+jVRze1nYxaMzw4mOwL++Yhn5GBpu1pDVxrij5y+a1MnYHnD7gzCW+s39g== Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 661EA410FC for ; Tue, 10 Sep 2024 23:32:41 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KteAXJoX4T9c for ; Tue, 10 Sep 2024 23:32:40 +0200 (CEST) From: Robin Roevens DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1726003960; bh=ER9iHrDjR9BwNW8f5ZYW8JEe5gWSS+wuFTt2v57hFL8=; h=From:To:Cc:Subject:Date; b=A/Uk9vtyR1GFfyOBH3oo5keFdovZtubdicokWovjTDZkkQ1IOjM6ffiCMmxQ+oer4 sp7kOUk5bERdahEssom1zTOlDfKtHkfiZgT3QtWqrYcYDn2stwOn4Q5UOPtisdIrSh 4dbTMaZiJUg+2yx77oeYiKvN5ZEhinT5do8ws4jelGYjeQ4IoOGjVu2lQnLtpXE2eW NqH/vVUBI1Y6mA+D+R+DbIbwUTSJ3r8b2ftBc+onpfSkDSTokbovu6AMhV8pl47BOl kBd+LLq6PBV1EwRs9ZRw2V+hr1GmBPYPrImAQhLPQrvh5AJXteUfvJPWIrm6qYO8i+ NRP8Nhlb4ksgw== To: development@lists.ipfire.org Subject: [PATCH] header.pl: only get memory consumption when service is running Date: Tue, 10 Sep 2024 23:32:32 +0200 Message-ID: <20240910213232.1695033-1-robin.roevens@disroot.org> MIME-Version: 1.0 X-Rspamd-Action: no action X-Rspamd-Server: mail01.haj.ipfire.org X-Rspamd-Queue-Id: 4X3H3s517yzPV X-Spamd-Result: default: False [-5.56 / 11.00]; BAYES_HAM(-2.95)[99.77%]; R_DKIM_ALLOW(-1.65)[disroot.org:s=mail]; SPF_REPUTATION_SPAM(1.39)[0.46280838026849]; IP_REPUTATION_HAM(-1.11)[asn: 50673(-0.32), country: NL(0.00), ip: 178.21.23.139(-0.80)]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-1.00)[-1.000]; DKIM_REPUTATION(-0.92)[-0.92213427645124]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,reject]; R_MISSING_CHARSET(0.50)[]; R_SPF_ALLOW(-0.20)[+a:c]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; ASN(0.00)[asn:50673, ipnet:178.21.23.0/24, country:NL]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RECEIVED_HELO_LOCALHOST(0.00)[]; RCVD_TLS_LAST(0.00)[]; MISSING_XM_UA(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[disroot.org:+]; PREVIOUSLY_DELIVERED(0.00)[development@lists.ipfire.org]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; FROM_HAS_DN(0.00)[] Message-ID-Hash: 34QK2GZXWYSEGD7AKALCEXJNFURTKW7G X-Message-ID-Hash: 34QK2GZXWYSEGD7AKALCEXJNFURTKW7G X-MailFrom: robin.roevens@disroot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: It probably doesn't matter much as the get_memory_consumption function just returns 0 when no pids are found. But it shouldn't even try as the mem var is never used when the service is not running. --- config/cfgroot/header.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/cfgroot/header.pl b/config/cfgroot/header.pl index a90a6f481..3778c4e59 100644 --- a/config/cfgroot/header.pl +++ b/config/cfgroot/header.pl @@ -950,9 +950,6 @@ EOF @pids = &General::find_pids("${process}"); } - # Get memory consumption - my $mem = &General::get_memory_consumption(@pids); - print < @@ -962,6 +959,9 @@ EOF # Running? if (scalar @pids) { + # Get memory consumption + my $mem = &General::get_memory_consumption(@pids); + # Format memory $mem = &General::formatBytes($mem);