MichaIng / DietPi

Lightweight justice for your single-board computer!
https://dietpi.com/
GNU General Public License v2.0
4.85k stars 495 forks source link

Dietpi-banner displays garbled RAM usage #7147

Closed Krik658 closed 3 months ago

Krik658 commented 3 months ago

Duplicate of #7107 Didn't see that before :(

Creating a bug report/issue

Required Information

Additional Information (if applicable)

Steps to reproduce

Login via ssh. Read memory info.

Expected behaviour

It should always show 15.75 GB (w/o video memory in my case)

Actual behaviour

The conversion of numbers leads to garbled output.

Extra details

 ─────────────────────────────────────────────────────
 DietPi v9.5.1 : Update available
 ─────────────────────────────────────────────────────
 - Device model : Native PC (x86_64)
 - Uptime : up 23 minutes
 - CPU temp : 57 °C / 134 °F : Running warm, but safe
 - RAM usage : 13402 of 1702 MiB (787%)
 - Disk usage (RootFS) : 3,2G of 917G (1%)
 ─────────────────────────────────────────────────────

 dietpi-update   : Run now to update DietPi from v9.5.1 to v9.6.1

The error is in https://github.com/MichaIng/DietPi/blob/master/dietpi/func/dietpi-banner, line 259. I think the values are too big to be displayed correctly.

Original: free -b | mawk 'NR==2 {CONVFMT="%.0f"; print $3/1024^2" of "$2/1024^2" MiB ("$3/$2*100"%)"}' Output: 13355 of 1747 MiB (765%)

Possible solutions

Human readable format, converts to Mi or Gi depending on values but there's no space between value and unit Code: free -h | mawk 'NR==2 {CONVFMT="%.0f"; print $3" of "$2" ("$3/$2*100"%)"}' Output: 1,7Gi of 15Gi (11%)

Or force MiB, looks pretty enough Code: free -m | mawk 'NR==2 {CONVFMT="%.0f"; print $3" MiB of "$2" MiB ("$3/$2*100"%)"}' Output: 1725 MiB of 15770 MiB (11%)

I assume the -h and -m parameters are available on the arm version of free but I don't know that for sure.

MichaIng commented 3 months ago

@Krik658 What does this show?

free -b
LC_ALL=C.UTF-8 free -b
Krik658 commented 3 months ago

I'm sorry. This issue is a duplicate of #7107 and that was already fixed in the new version. I didn't see that before. :(

I also have the German locale which is the cause of the issue.