Tested-by: Bernhard Bitsch 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 > --- > 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 ""; > - 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(){ > - 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 < > > @@ -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 > ; > }elsif($_ =~ m/^Swap:\s+(\d+)\s+(\d+)\s+(\d+)$/){ > @@ -106,17 +106,13 @@ END > print < > > - > END > ; > - }elsif($ram and $_ =~ m/^-\/\+ buffers\/cache:\s+(\d+)\s+(\d+)$/ ){ > - ($used,$free) = ($1,$2); > - ($percent = ($used/$ram)*100) =~ s/^(\d+)(\.\d+)?$/$1%/; > - print ""; > } > print < - > - > + > + > + > > - > - > - > + > + > + > + > + >
 
$Lang::tr{'ram'}$size KB
$Lang::tr{'swap'}$size KB
$Lang::tr{'excluding buffers and cache'}$used KB$free KB$size KiB$used KiB$free KiB > END > ; > @@ -129,12 +125,13 @@ END > ; > } > } > - close FREE; > + close($cmd_fh); > print < -

$Lang::tr{'shared'}$shared KB
$Lang::tr{'buffers'}$buffers KB
$Lang::tr{'cached'}$cached KB

$Lang::tr{'shared'}$shared KiB
$Lang::tr{'buffers'}$buffers KiB
$Lang::tr{'cached'}$cached KiB
$Lang::tr{'available'}$available KiB
> 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', >