This commit is contained in:
128
proxDoc.sh
128
proxDoc.sh
@@ -189,41 +189,105 @@ get_motherboard_info() {
|
||||
|
||||
get_memory_details() {
|
||||
echo -e "\n${GREEN}=== Memory DIMM Information ===${NC}"
|
||||
dmidecode -t memory | awk '
|
||||
/Memory Device/,/^$/ {
|
||||
if (/Size:/ && !/No Module Installed/) {
|
||||
size=$2" "$3
|
||||
}
|
||||
if (/Type:/ && !/Unknown/ && !/Error/) {
|
||||
type=$2
|
||||
}
|
||||
if (/Speed:/ && !/Unknown/ && $2 != "Unknown") {
|
||||
speed=$2" "$3
|
||||
}
|
||||
if (/Manufacturer:/ && !/Unknown/ && $2 != "Unknown") {
|
||||
mfr=$2
|
||||
}
|
||||
if (/Part Number:/ && !/Unknown/) {
|
||||
part=$3
|
||||
}
|
||||
if (/Locator:/ && !/Bank/) {
|
||||
loc=$2
|
||||
if (size && size !~ /No/) {
|
||||
printf "%-12s %-10s %-8s %-12s %-20s\n", loc, size, type, speed, mfr
|
||||
size=""; type=""; speed=""; mfr=""; part=""
|
||||
}
|
||||
}
|
||||
}
|
||||
'
|
||||
|
||||
# Use a more robust parsing approach
|
||||
local locator size type speed manufacturer
|
||||
local in_device=false
|
||||
|
||||
# Print header
|
||||
printf "%-12s %-12s %-10s %-12s %-20s\n" "Slot" "Size" "Type" "Speed" "Manufacturer"
|
||||
printf "%-12s %-12s %-10s %-12s %-20s\n" "----" "----" "----" "-----" "------------"
|
||||
|
||||
while IFS= read -r line; do
|
||||
# Detect start of a memory device section
|
||||
if [[ "$line" =~ ^Memory[[:space:]]Device ]]; then
|
||||
# If we have data from previous device, print it
|
||||
if [[ -n "$locator" && -n "$size" && ! "$size" =~ (No|Not|Installed) ]]; then
|
||||
printf "%-12s %-12s %-10s %-12s %-20s\n" \
|
||||
"${locator:-N/A}" \
|
||||
"${size:-N/A}" \
|
||||
"${type:-N/A}" \
|
||||
"${speed:-N/A}" \
|
||||
"${manufacturer:-N/A}"
|
||||
fi
|
||||
|
||||
# Reset variables for new device
|
||||
locator=""
|
||||
size=""
|
||||
type=""
|
||||
speed=""
|
||||
manufacturer=""
|
||||
in_device=true
|
||||
continue
|
||||
fi
|
||||
|
||||
# Skip if not in a device section
|
||||
[[ "$in_device" != true ]] && continue
|
||||
|
||||
# Parse fields (case-insensitive, flexible whitespace)
|
||||
if [[ "$line" =~ ^[[:space:]]*Locator:[[:space:]]*(.+)$ ]] && [[ ! "$line" =~ Bank ]]; then
|
||||
locator="${BASH_REMATCH[1]}"
|
||||
locator="${locator// /_}" # Replace spaces with underscores
|
||||
elif [[ "$line" =~ ^[[:space:]]*Size:[[:space:]]*(.+)$ ]]; then
|
||||
size="${BASH_REMATCH[1]}"
|
||||
elif [[ "$line" =~ ^[[:space:]]*Type:[[:space:]]*(.+)$ ]]; then
|
||||
type="${BASH_REMATCH[1]}"
|
||||
# Skip if it's an error or unknown type
|
||||
[[ "$type" =~ (Unknown|Error|Correction) ]] && type=""
|
||||
elif [[ "$line" =~ ^[[:space:]]*Speed:[[:space:]]*(.+)$ ]]; then
|
||||
speed="${BASH_REMATCH[1]}"
|
||||
[[ "$speed" =~ Unknown ]] && speed=""
|
||||
elif [[ "$line" =~ ^[[:space:]]*Manufacturer:[[:space:]]*(.+)$ ]]; then
|
||||
manufacturer="${BASH_REMATCH[1]}"
|
||||
[[ "$manufacturer" =~ (Unknown|NO DIMM) ]] && manufacturer=""
|
||||
fi
|
||||
|
||||
# Empty line marks end of device section
|
||||
if [[ -z "$line" ]]; then
|
||||
in_device=false
|
||||
fi
|
||||
|
||||
done < <(dmidecode -t memory 2>/dev/null)
|
||||
|
||||
# Print last device if it has data
|
||||
if [[ -n "$locator" && -n "$size" && ! "$size" =~ (No|Not|Installed) ]]; then
|
||||
printf "%-12s %-12s %-10s %-12s %-20s\n" \
|
||||
"${locator:-N/A}" \
|
||||
"${size:-N/A}" \
|
||||
"${type:-N/A}" \
|
||||
"${speed:-N/A}" \
|
||||
"${manufacturer:-N/A}"
|
||||
fi
|
||||
|
||||
# Memory summary
|
||||
echo -e "\n${GREEN}Memory Summary:${NC}"
|
||||
# Count actual DIMM slots by looking for Locator entries with slot-like names (DIMM, BANK, ChannelA, etc.)
|
||||
# Filter out Bank Locator lines and count unique slot names
|
||||
local total_slots=$(dmidecode -t memory | grep -E "^\s+Locator:" | grep -v "Bank Locator" | wc -l)
|
||||
# Count populated slots - those with actual size values (not "No Module Installed" or "Not Installed")
|
||||
local populated=$(dmidecode -t memory | grep -E "^\s+Size:" | grep -v -E "No Module|Not Installed" | wc -l)
|
||||
|
||||
# Count slots more reliably
|
||||
local total_slots=0
|
||||
local populated=0
|
||||
|
||||
while IFS= read -r line; do
|
||||
if [[ "$line" =~ ^[[:space:]]*Locator: ]] && [[ ! "$line" =~ Bank ]]; then
|
||||
((total_slots++))
|
||||
fi
|
||||
done < <(dmidecode -t memory 2>/dev/null)
|
||||
|
||||
while IFS= read -r line; do
|
||||
if [[ "$line" =~ ^[[:space:]]*Size:[[:space:]]*(.+)$ ]]; then
|
||||
local size_val="${BASH_REMATCH[1]}"
|
||||
if [[ ! "$size_val" =~ (No|Not|Installed) ]]; then
|
||||
((populated++))
|
||||
fi
|
||||
fi
|
||||
done < <(dmidecode -t memory 2>/dev/null)
|
||||
|
||||
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}')"
|
||||
|
||||
# Get max capacity
|
||||
local max_capacity
|
||||
max_capacity=$(dmidecode -t memory 2>/dev/null | grep -i "Maximum Capacity" | head -1 | sed 's/.*: //')
|
||||
echo -e " Max Capacity: ${max_capacity:-Unknown}"
|
||||
}
|
||||
|
||||
get_nic_details() {
|
||||
|
||||
Reference in New Issue
Block a user