header.pl: only get memory consumption when service is running

Message ID 20240910213232.1695033-1-robin.roevens@disroot.org
State Staged
Commit d335cc9592afa74f219bbf564b01c612ea336e77
Headers
Series header.pl: only get memory consumption when service is running |

Commit Message

Robin Roevens Sept. 10, 2024, 9:32 p.m. UTC
  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(-)
  

Patch

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 <<EOF;
 				<tr>
 					<th scope="row">
@@ -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);