From 4cc6799ff3d2d83b379539882c7fb780ca166a90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Mengu=C3=A9?= Date: Wed, 8 Jun 2016 01:20:06 +0200 Subject: [PATCH] Plugin::LoadAvg: normalize with CPU count Divide loadavg by nproc. GitHub #21. --- lib/AngelPS1/Plugin/LoadAvg.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/AngelPS1/Plugin/LoadAvg.pm b/lib/AngelPS1/Plugin/LoadAvg.pm index 0a36012..b9a2743 100644 --- a/lib/AngelPS1/Plugin/LoadAvg.pm +++ b/lib/AngelPS1/Plugin/LoadAvg.pm @@ -27,10 +27,13 @@ sub LoadAvgPercent AngelPS1::_str_allowed($SYMBOL_LOADAVG) or return; my $loadavg_func = $loadavg_gen->(); + my $nproc = AngelPS1::System->nproc(); return sub { my $loadavg = $loadavg_func->(); - return if !defined($loadavg) || $loadavg < $LOAD_THRESHOLD; + return if !defined($loadavg); + $loadavg /= $nproc; + return if $loadavg < $LOAD_THRESHOLD; ( ( $loadavg < 0.80