Fix memory slot count bug in get_memory_details
The previous grep-based counting was including Size: lines from Physical Memory Array sections, causing incorrect counts (e.g., 5/4 instead of 4/4). Now uses awk to only count Size: lines within Memory Device sections. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -209,8 +209,12 @@ get_memory_details() {
|
||||
}
|
||||
'
|
||||
echo -e "\n${GREEN}Memory Summary:${NC}"
|
||||
echo -e " Total Slots: $(dmidecode -t memory | grep -c "Memory Device")"
|
||||
echo -e " Populated: $(dmidecode -t memory | grep "Size:" | grep -cv "No Module")"
|
||||
# Count total memory device slots (excluding Physical Memory Array entries)
|
||||
local total_slots=$(dmidecode -t memory | awk '/^Memory Device$/,/^$/ {if (/Size:/) count++} END {print count}')
|
||||
# Count populated slots (Size: lines with actual values, not "No Module Installed")
|
||||
local populated=$(dmidecode -t memory | awk '/^Memory Device$/,/^$/ {if (/Size:/ && !/No Module/) count++} END {print count}')
|
||||
echo -e " Total Slots: $total_slots"
|
||||
echo -e " Populated: $populated"
|
||||
echo -e " Max Capacity: $(dmidecode -t memory | grep "Maximum Capacity" | head -1 | awk '{print $3" "$4}')"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user