Skip to content

Commit

Permalink
Merge pull request #206 from ryran/issue203-dmidecode
Browse files Browse the repository at this point in the history
v0.7.10: fix for dmidecode-parsing issues #203 and #205
  • Loading branch information
ryran authored Sep 9, 2016
2 parents 0efa5ee + cab2d74 commit e8d6dee
Showing 1 changed file with 39 additions and 7 deletions.
46 changes: 39 additions & 7 deletions xsos
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
# xsos v0.7.9 last mod 2015/04/05
# xsos v0.7.10 last mod 2016/09/09
# Latest version at <http://github.com/ryran/xsos>
# RPM packages available at <http://people.redhat.com/rsawhill/rpms>
# Copyright 2012-2015 Ryan Sawhill Aroha <[email protected]>
# Copyright 2012-2016 Ryan Sawhill Aroha <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -612,12 +612,44 @@ DMIDECODE() {
echo -e "${c[H2]} Memory:${c[0]}"
gawk 'BEGIN { RS="\nHandle" } /Physical Memory Array|Memory Device/' <<<"$dmidecode_input" |
gawk -vH3="${c[H3]}" -vH2="${c[H2]}" -vH0="${c[0]}" -vH_IMP="${c[Imp]}" '
/Size:/ { NumDimmSlots ++; if ($2 ~ /^[0-9]/) { NumDimms ++; SumRam+=$2 } }
/Maximum Capacity:/ { MaxRam = $3" "$4 }
/Size:/ {
NumDimmSlots ++
if ($2 ~ /^[0-9]/) {
NumDimms ++
if ($3 ~ /^P/)
SumRam += $2 * 1024 * 1024 * 1024
else if ($3 ~ /^T/)
SumRam += $2 * 1024 * 1024
else if ($3 ~ /^G/)
SumRam += $2 * 1024
else if ($3 ~/^[kK]/)
SumRam += $2 / 1024
else if ($3 ~/^[bB]/)
SumRam += $2 / 1024 / 1024
else
SumRam += $2
}
}
/Maximum Capacity:/ {
if ($3 ~ /^[0-9]/) {
if ($4 ~ /^P/)
SumMaxRam += $3 * 1024 * 1024 * 1024
else if ($4 ~ /^T/)
SumMaxRam += $3 * 1024 * 1024
else if ($4 ~ /^G/)
SumMaxRam += $3 * 1024
else if ($4 ~/^[kK]/)
SumMaxRam += $3 / 1024
else if ($4 ~/^[bB]/)
SumMaxRam += $3 / 1024 / 1024
else
SumMaxRam += $3
}
}
END {
printf " %d MB (%.0f GB) total\n", SumRam, SumRam/1024
printf " %d of %d DIMMs populated (system max capacity %s)\n",
NumDimms, NumDimmSlots, MaxRam
printf " %sTotal:%s %d MiB (%.0f GiB)\n", H3, H0, SumRam, SumRam/1024
printf " %sDIMMs:%s %d of %d populated\n", H3, H0, NumDimms, NumDimmSlots
printf " %sMaxCapacity:%s %d MiB (%.0f GiB / %.2f TiB)\n", H3, H0, SumMaxRam, SumMaxRam/1024, SumMaxRam/1024/1024
}
'
echo -en $XSOS_HEADING_SEPARATOR
Expand Down

0 comments on commit e8d6dee

Please sign in to comment.