Applied and tested.
Am 08.06.2021 um 08:37 schrieb Leo-Andres Hofmann:
procps 3.3.10 introduced a new output format for the "free" command. This patch adapts the new format.
Fixes: #12628
Signed-off-by: Leo-Andres Hofmann hofmann@leo-andres.de
html/cgi-bin/memory.cgi | 35 ++++++++++++++++------------------- langs/de/cgi-bin/de.pl | 1 + langs/en/cgi-bin/en.pl | 1 + 3 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/html/cgi-bin/memory.cgi b/html/cgi-bin/memory.cgi index 204365294..89fa7d14a 100644 --- a/html/cgi-bin/memory.cgi +++ b/html/cgi-bin/memory.cgi @@ -64,7 +64,6 @@ if ( $querry[0] =~ "memory"){
&Header::openbox('100%', 'center', $Lang::tr{'memory'}); print "<table width='95%' cellspacing='5'>";
- my $ram=0; my $size=0; my $used=0; my $free=0;
@@ -72,10 +71,12 @@ if ( $querry[0] =~ "memory"){ my $shared=0; my $buffers=0; my $cached=0;
- my $available=0;
- open(FREE,'/usr/bin/free |');
- while(<FREE>){
if ($_ =~ m/^\s+total\s+used\s+free\s+shared\s+buffers\s+cached$/ ){
- # output format: kibibytes, wide mode (buffers and cache in two columns)
- open(my $cmd_fh, "-|", '/usr/bin/free -k -w') or die $!;
- while(<$cmd_fh>){
if ($_ =~ m/^\s+total\s+used\s+free\s+shared\s+buffers\s+cache\s+available$/ ){ print <<END
<tr> <td align='center'> </td>
@@ -87,13 +88,12 @@ if ( $querry[0] =~ "memory"){ END ; }else{
if ($_ =~ m/^Mem:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$/){
($ram,$size,$used,$free,$shared,$buffers,$cached) = ($1,$1,$2,$3,$4,$5,$6);
if ($_ =~ m/^Mem:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$/){
($size,$used,$free,$shared,$buffers,$cached,$available) = ($1,$2,$3,$4,$5,$6,$7); ($percent = ($used/$size)*100) =~ s/^(\d+)(\.\d+)?$/$1%/; print <<END
<tr> <td class='boldbase'><b>$Lang::tr{'ram'}</b></td>
-<td align='center'>$size KB</td> END ; }elsif($_ =~ m/^Swap:\s+(\d+)\s+(\d+)\s+(\d+)$/){ @@ -106,17 +106,13 @@ END print <<END
<tr> <td class='boldbase'><b>$Lang::tr{'swap'}</b></td> -<td align='center'>$size KB</td> END ; - }elsif($ram and $_ =~ m/^-\/\+ buffers\/cache:\s+(\d+)\s+(\d+)$/ ){ - ($used,$free) = ($1,$2); - ($percent = ($used/$ram)*100) =~ s/^(\d+)(\.\d+)?$/$1%/; - print "<tr><td colspan='2' class='boldbase'><b>$Lang::tr{'excluding buffers and cache'}</b></td>"; } print <<END -<td align='center'>$used KB</td> -<td align='center'>$free KB</td> +<td align='center'>$size KiB</td> +<td align='center'>$used KiB</td> +<td align='center'>$free KiB</td> <td> END ; @@ -129,12 +125,13 @@ END ; } } - close FREE; + close($cmd_fh); print <<END -<tr><td class='boldbase' colspan='2'><br /></td></tr> -<tr><td class='boldbase'><b>$Lang::tr{'shared'}</b></td><td align='center'>$shared KB</td></tr> -<tr><td class='boldbase'><b>$Lang::tr{'buffers'}</b></td><td align='center'>$buffers KB</td></tr> -<tr><td class='boldbase'><b>$Lang::tr{'cached'}</b></td><td align='center'>$cached KB</td></tr> +<tr><td colspan='6'><br /></td></tr> +<tr><td class='boldbase'><b>$Lang::tr{'shared'}</b></td><td align='center'>$shared KiB</td></tr> +<tr><td class='boldbase'><b>$Lang::tr{'buffers'}</b></td><td align='center'>$buffers KiB</td></tr> +<tr><td class='boldbase'><b>$Lang::tr{'cached'}</b></td><td align='center'>$cached KiB</td></tr> +<tr><td class='boldbase'><b>$Lang::tr{'available'}</b></td><td align='center'>$available KiB</td></tr> </table> END ; diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl index 0bc579cd2..058ec7b07 100644 --- a/langs/de/cgi-bin/de.pl +++ b/langs/de/cgi-bin/de.pl @@ -507,6 +507,7 @@ 'cache management' => 'Cache-Verwaltung', 'cache size' => 'Cache-Größe (MB):', 'cached' => 'zwischengespeichert', +'available' => 'verfügbar', 'cached memory' => 'Zwischenspeicher ', 'cached swap' => 'Zwischenspeicher (Swap)', 'calamaris available reports' => 'Verfügbare Berichte', diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index 1c69b3798..942c67f20 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -522,6 +522,7 @@ 'cache management' => 'Cache management', 'cache size' => 'Cache size (MB):', 'cached' => 'cached', +'available' => 'available', 'cached memory' => 'Cached Memory ', 'cached swap' => 'Cached Swap', 'calamaris available reports' => 'Available reports',