mirror of
https://github.com/007revad/Synology_HDD_db.git
synced 2026-04-25 13:45:59 +03:00
[GH-ISSUE #106] Routine of RAM size evaluation not sufficient and might cause issues #542
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/Synology_HDD_db#542
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @luddinho on GitHub (Jun 30, 2023).
Original GitHub issue: https://github.com/007revad/Synology_HDD_db/issues/106
Environment
script version: v3.0.56
OS: DSM 7.2
Device: 1817+
RAM: 2x 8GB
Problem description
The evaluation of RAM size might cause issues because the condition of the grep command for
dmidecodeis not clear enough.Example:
On my system the command
dmidecode -t memory | grep "[Ss]ize"will return the following content.Now you can imagine what will happen with the variables $ramsize and $bytes when evaluating with awk.
The result is:
At the end of the loop we will have fortunately the correct numeric value for the variable $ramtotal. But the unit for $bytes is inconsitent.
Proposed solution
My proposal is to make the grep command with an extended regular expression much more precise that will return only the size with numeric values and additionally with a valid unit either MB or GB as postfix at the end of the line.
I haven´t checked other systems yet, but it could also lead to an error in the calculation of $ramtotal size.
Please have a look and check if the improvement can be implemented.
@007revad commented on GitHub (Jun 30, 2023):
Nicely formatted issue, and nice solution. Thank you.
@luddinho commented on GitHub (Jun 30, 2023):
From a code review so far, it looks pretty good. I think this is fine now.
Thanks for the fix.