Fix DIMM parsing, memory slot count, and service status bugs

- Fix BASH_REMATCH being wiped by second =~ in Bank Locator exclusion
  check, causing DIMM table to always show empty. Use glob == *pattern*
  instead of =~ for the exclusion so BASH_REMATCH is preserved.
- Remove incorrect bank_locators subtraction from total_slots count
  (grep pattern already excluded Bank Locator lines, so subtracting
  them again produced 0 total slots).
- Fix check_services showing stray "not-found" line after "inactive"
  status by replacing `|| echo "not-found"` with empty-string check.
- Add bc to README requirements list (script checks for it).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-06 18:50:28 -05:00
parent 76f7aaa64c
commit daafb6c4fb
2 changed files with 6 additions and 7 deletions

View File

@@ -331,7 +331,7 @@ get_memory_details() {
# Parse fields - be very specific to avoid matching wrong lines
# Locator (but not Bank Locator)
if [[ "$line" =~ ^[[:space:]]*Locator:[[:space:]]*(.+)$ ]] && [[ ! "$line" =~ Bank[[:space:]]*Locator ]]; then
if [[ "$line" =~ ^[[:space:]]*Locator:[[:space:]]*(.+)$ ]] && [[ ! "$line" == *Bank*Locator* ]]; then
locator="${BASH_REMATCH[1]}"
locator="${locator// /_}"
# Size
@@ -380,12 +380,9 @@ get_memory_details() {
echo -e "\n${GREEN}Memory Summary:${NC}"
# Count slots and populated using simpler grep approach
# Pattern ^[[:space:]]*Locator: already excludes "Bank Locator:" lines
local total_slots populated
total_slots=$(dmidecode -t memory 2>/dev/null | grep -c "^[[:space:]]*Locator:" | head -1)
# Subtract Bank Locator lines
local bank_locators
bank_locators=$(dmidecode -t memory 2>/dev/null | grep -c "Bank Locator:")
total_slots=$((total_slots - bank_locators))
total_slots=$(dmidecode -t memory 2>/dev/null | grep -c "^[[:space:]]*Locator:")
populated=$(dmidecode -t memory 2>/dev/null | grep "^[[:space:]]*Size:" | grep -cv "No Module\|Not Installed")
@@ -670,7 +667,8 @@ check_services() {
local services=("pvedaemon" "pveproxy" "pvecluster" "pve-cluster" "corosync")
for service in "${services[@]}"; do
local status
status=$(systemctl is-active "$service" 2>/dev/null || echo "not-found")
status=$(systemctl is-active "$service" 2>/dev/null)
[[ -z "$status" ]] && status="not-found"
echo -e "${GREEN}$service:${NC} $status"
done
}