mirror of
https://github.com/smxi/inxi.git
synced 2025-01-19 00:47:47 +00:00
New version, new tarball. Attempting to handle bad extra data for max module size, sometimes
it is too big, and sometimes too small. Changed data gathering to use arrays, then print/process the arrays once they are assembled. Now it will get rid of any max module size if it's greater than the calculated capacity, and it will generate an estimated capacity/max module size if they are clearly wrong because actual module sizes are greater than listed max size, or capacity is less than greatest module sizes times number of devices. Not perfect, but it never is, this covers more cases now correctly than before.
This commit is contained in:
parent
403bc46f6d
commit
d2b254fac1
146
inxi
146
inxi
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
########################################################################
|
||||
#### Script Name: inxi
|
||||
#### Version: 2.1.94
|
||||
#### Version: 2.1.95
|
||||
#### Date: 2014-08-13
|
||||
#### Patch Number: 00
|
||||
########################################################################
|
||||
|
@ -3881,7 +3881,6 @@ get_cpu_speed_hack()
|
|||
echo $speed
|
||||
}
|
||||
|
||||
|
||||
get_cpu_data_bsd()
|
||||
{
|
||||
eval $LOGFS
|
||||
|
@ -4890,8 +4889,7 @@ get_dmidecode_data()
|
|||
eval $LOGFS
|
||||
|
||||
local dmiData=""
|
||||
local dmidecodePath=''
|
||||
|
||||
|
||||
if [[ $B_DMIDECODE_SET != 'true' ]];then
|
||||
dmidecodePath=$( type -p dmidecode 2>/dev/null )
|
||||
if [[ -z $dmidecodePath ]];then
|
||||
|
@ -4937,7 +4935,7 @@ get_dmidecode_data()
|
|||
# To Be Filled By O.E.M.
|
||||
# strip out starting white space so that the following stuff will clear properly
|
||||
sub(/^[[:space:]]+/, "", twoData)
|
||||
sub(/^Base Board .*|^Chassis .*|.*O\.E\.M\..*|.*OEM.*|^Not .*|^System .*|.*unknow.*|.*N\/A.*|none|^To be filled.*|^0x[0]+$/, "", twoData)
|
||||
sub(/^Base Board .*|^Chassis .*|.*O\.E\.M\..*|.*OEM.*|^Not .*|^System .*|.*unknow.*|.*N\/A.*|none|^To be filled.*|^0x[0]+$|\[Empty\]|<Bad Index>/, "", twoData)
|
||||
sub(/.*(AssetTagNum|Manufacturer| Or Motherboard|PartNum.*|SerNum).*/, "", twoData)
|
||||
gsub(/bios|acpi/, "", twoData)
|
||||
sub(/http:\/\/www.abit.com.tw\//, "Abit", twoData)
|
||||
|
@ -8140,18 +8138,42 @@ get_ram_data()
|
|||
handle=""
|
||||
location=""
|
||||
locator=""
|
||||
maxCapacity=""
|
||||
maxModuleSize=""
|
||||
aDerivedModuleSize[0]=0
|
||||
aMaxCapacity[0]=0
|
||||
aMaxModuleSize[0]=0
|
||||
moduleVoltage=""
|
||||
numberOfDevices=""
|
||||
primaryType=""
|
||||
totalWidth=""
|
||||
use=""
|
||||
i=0
|
||||
k=0
|
||||
}
|
||||
function calculateSize(data,size) {
|
||||
if ( data ~ /^[0-9]+[[:space:]]*[GMTP]B/) {
|
||||
if ( data ~ /GB/ ) {
|
||||
data=gensub(/([0-9]+)[[:space:]]*GB/,"\\1",1,data) * 1024
|
||||
}
|
||||
else if ( data ~ /MB/ ) {
|
||||
data=gensub(/([0-9]+)[[:space:]]*MB/,"\\1",1,data)
|
||||
}
|
||||
else if ( data ~ /TB/ ) {
|
||||
data=gensub(/([0-9]+)[[:space:]]*TB/,"\\1",1,data) * 1024 * 1000
|
||||
}
|
||||
else if ( data ~ /PB/ ) {
|
||||
data=gensub(/([0-9]+)[[:space:]]*TB/,"\\1",1,data) * 1024 * 1000 * 1000
|
||||
}
|
||||
if (data ~ /^[0-9][0-9]+$/ && data > size ) {
|
||||
size=data
|
||||
}
|
||||
}
|
||||
return size
|
||||
}
|
||||
/^Handle .* DMI type 5(,|[[:space:]])/ {
|
||||
while ( getline && !/^$/ ) {
|
||||
if ( $1 == "Maximum Memory Module Size" ) {
|
||||
maxModuleSize=$2
|
||||
aMaxModuleSize[k]=calculateSize($2,aMaxModuleSize[k])
|
||||
# print "mms:" aMaxModuleSize[k] ":" $2
|
||||
}
|
||||
if ( $1 == "Memory Module Voltage" ) {
|
||||
moduleVoltage=$2
|
||||
|
@ -8164,7 +8186,8 @@ get_ram_data()
|
|||
while ( getline && !/^$/ ) {
|
||||
# print $0
|
||||
if ( $1 == "Maximum Capacity") {
|
||||
maxCapacity=$2
|
||||
aMaxCapacity[k]=calculateSize($2,aMaxCapacity[k])
|
||||
#print "mc:" aMaxCapacity[k] ":" $2
|
||||
}
|
||||
# note: these 3 have cleaned data in get_dmidecode_data, so replace stuff manually
|
||||
if ( $1 == "Location") {
|
||||
|
@ -8190,17 +8213,30 @@ get_ram_data()
|
|||
numberOfDevices=$2
|
||||
}
|
||||
}
|
||||
print primaryType "," arrayHandle "," location "," maxCapacity "," numberOfDevices "," use "," errorCorrection "," maxModuleSize "," moduleVoltage
|
||||
a_memory[i,0]=primaryType
|
||||
a_memory[i,1]=arrayHandle
|
||||
a_memory[i,2]=location
|
||||
a_memory[i,3]=aMaxCapacity[k]
|
||||
a_memory[i,4]=numberOfDevices
|
||||
a_memory[i,5]=use
|
||||
a_memory[i,6]=errorCorrection
|
||||
a_memory[i,7]=aMaxModuleSize[k]
|
||||
a_memory[i,8]=moduleVoltage
|
||||
|
||||
# print primaryType "," arrayHandle "," location "," maxCapacity "," numberOfDevices "," use "," errorCorrection "," maxModuleSize "," moduleVoltage
|
||||
# reset
|
||||
primaryType=""
|
||||
arrayHandle=""
|
||||
location=""
|
||||
maxCapacity=""
|
||||
numberOfDevices=""
|
||||
use=""
|
||||
errorCorrection=""
|
||||
maxModuleSize=""
|
||||
moduleVoltage=""
|
||||
i++
|
||||
k++
|
||||
aMaxCapacity[k]=0
|
||||
aMaxModuleSize[k]=0
|
||||
aDerivedModuleSize[k]=0
|
||||
}
|
||||
/^Handle .* DMI type 17/ {
|
||||
primaryType="memory-device"
|
||||
|
@ -8215,13 +8251,16 @@ get_ram_data()
|
|||
totalWidth=$2
|
||||
}
|
||||
if ( $1 == "Size") {
|
||||
# do not try to guess from installed modules, only use this to correct type 5 data
|
||||
aDerivedModuleSize[k-1]=calculateSize($2,aDerivedModuleSize[k-1])
|
||||
#print aDerivedModuleSize[k-1] " dm:"k":mm " aMaxModuleSize[k-1]
|
||||
deviceSize=$2
|
||||
}
|
||||
if ( $1 == "Locator") {
|
||||
# sub(/.*_/,"",$2)
|
||||
#sub(/RAM slot #|^DIMM/, "Slot",$2)
|
||||
sub(/RAM slot #/, "Slot",$2)
|
||||
sub(/^<BAD INDEX>|\.\.$/,"",$2)
|
||||
|
||||
#locator=toupper($2)
|
||||
locator=$2
|
||||
}
|
||||
|
@ -8280,7 +8319,23 @@ get_ram_data()
|
|||
dataWidth=totalWidth
|
||||
totalWidth=tempWidth
|
||||
}
|
||||
print primaryType "," arrayHandle "," deviceSize "," bankLocator "," locator "," formFactor "," deviceType "," deviceTypeDetail "," deviceSpeed "," configuredClockSpeed "," dataWidth "," totalWidth "," deviceManufacturer "," devicePartNumber "," deviceSerialNumber "," mainLocator
|
||||
# print primaryType "," arrayHandle "," deviceSize "," bankLocator "," locator "," formFactor "," deviceType "," deviceTypeDetail "," deviceSpeed "," configuredClockSpeed "," dataWidth "," totalWidth "," deviceManufacturer "," devicePartNumber "," deviceSerialNumber "," mainLocator
|
||||
a_memory[i,0]=primaryType
|
||||
a_memory[i,1]=arrayHandle
|
||||
a_memory[i,2]=deviceSize
|
||||
a_memory[i,3]=bankLocator
|
||||
a_memory[i,4]=locator
|
||||
a_memory[i,5]=formFactor
|
||||
a_memory[i,6]=deviceType
|
||||
a_memory[i,7]=deviceTypeDetail
|
||||
a_memory[i,8]=deviceSpeed
|
||||
a_memory[i,9]=configuredClockSpeed
|
||||
a_memory[i,10]=dataWidth
|
||||
a_memory[i,11]=totalWidth
|
||||
a_memory[i,12]=deviceManufacturer
|
||||
a_memory[i,13]=devicePartNumber
|
||||
a_memory[i,14]=deviceSerialNumber
|
||||
a_memory[i,15]=mainLocator
|
||||
|
||||
primaryType=""
|
||||
arrayHandle=""
|
||||
|
@ -8299,8 +8354,69 @@ get_ram_data()
|
|||
deviceManufacturer=""
|
||||
devicePartNumber=""
|
||||
deviceSerialNumber=""
|
||||
i++
|
||||
}
|
||||
END {
|
||||
# print primaryType "," arrayHandle "," location "," maxCapacity "," numberOfDevices "," use "," errorCorrection "," maxModuleSize "," moduleVoltage
|
||||
|
||||
} ' <<< "$DMIDECODE_DATA" ) )
|
||||
# print primaryType "," arrayHandle "," deviceSize "," bankLocator "," locator "," formFactor "," deviceType "," deviceTypeDetail "," deviceSpeed "," configuredClockSpeed "," dataWidth "," totalWidth "," deviceManufacturer "," devicePartNumber "," deviceSerialNumber "," mainLocator
|
||||
m=0
|
||||
for ( j=0;j<i;j++ ) {
|
||||
estCap=""
|
||||
estModuleSize=""
|
||||
unit=""
|
||||
if (a_memory[j,0] == "memory-array" ) {
|
||||
if ( a_memory[j,3] == 0 ) {
|
||||
a_memory[j,3] = ""
|
||||
}
|
||||
# print "mms:" aMaxModuleSize[m] ":dms:" aDerivedModuleSize[m]
|
||||
if (aMaxModuleSize[m] != 0 && aDerivedModuleSize[m] != 0 && aDerivedModuleSize[m] > aMaxModuleSize[m]){
|
||||
aMaxModuleSize[m]=aDerivedModuleSize[m]
|
||||
estModuleSize=" (est.)"
|
||||
}
|
||||
if (aMaxModuleSize[m] == 0 ){
|
||||
aMaxModuleSize[m]=""
|
||||
}
|
||||
|
||||
if (a_memory[j,3] != "" && a_memory[j,4] != "" ) {
|
||||
if ( a_memory[j,3] < ( a_memory[j,4] * aDerivedModuleSize[m] ) ) {
|
||||
a_memory[j,3] = a_memory[j,4] * aDerivedModuleSize[m]
|
||||
estCap=" (est)"
|
||||
}
|
||||
}
|
||||
# print "mms:" aMaxModuleSize[m] ":dms:" aDerivedModuleSize[m] ":mc:" a_memory[j,3]
|
||||
# some cases of type 5 have too big module max size, just dump the data then
|
||||
if ( aMaxModuleSize[m] != "" && a_memory[j,3] != "" && ( aMaxModuleSize[m] > a_memory[j,3] ) ){
|
||||
aMaxModuleSize[m] = ""
|
||||
}
|
||||
if (a_memory[j,3] != "" ) {
|
||||
a_memory[j,3]=int(a_memory[j,3]) # some weird cases believe they are strings!
|
||||
if ( a_memory[j,3] < 1024 ) {
|
||||
a_memory[j,3] = a_memory[j,3]
|
||||
unit=" MB"
|
||||
}
|
||||
else if ( a_memory[j,3] < 1024000 ) {
|
||||
a_memory[j,3] = a_memory[j,3] / 1024
|
||||
unit=" GB"
|
||||
}
|
||||
else if ( a_memory[j,3] < 1024000000 ) {
|
||||
a_memory[j,3] = a_memory[j,3] / 1024000
|
||||
unit=" GB"
|
||||
}
|
||||
a_memory[j,3]=gensub(/([0-9]+\.[0-9][0-9]).*/,"\\1",1,a_memory[j,3])
|
||||
a_memory[j,3] = a_memory[j,3] unit estCap
|
||||
}
|
||||
if ( aMaxModuleSize[m] != "" ){
|
||||
aMaxModuleSize[m]=aMaxModuleSize[m] " MB"
|
||||
}
|
||||
print a_memory[j,0] "," a_memory[j,1] "," a_memory[j,2] "," a_memory[j,3] "," a_memory[j,4] "," a_memory[j,5] "," a_memory[j,6] "," aMaxModuleSize[m] estModuleSize "," a_memory[j,8]
|
||||
m++
|
||||
}
|
||||
else {
|
||||
print a_memory[j,0] "," a_memory[j,1] "," a_memory[j,2] "," a_memory[j,3] "," a_memory[j,4] "," a_memory[j,5] "," a_memory[j,6] "," a_memory[j,7] "," a_memory[j,8] "," a_memory[j,9] "," a_memory[j,10] "," a_memory[j,11] "," a_memory[j,12] "," a_memory[j,13] "," a_memory[j,14] "," a_memory[j,15]
|
||||
}
|
||||
}
|
||||
}' <<< "$DMIDECODE_DATA" ) )
|
||||
fi
|
||||
fi
|
||||
IFS="$ORIGINAL_IFS"
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
=====================================================================================
|
||||
Version: 2.1.95
|
||||
Patch Version: 00
|
||||
Script Date: 2014-08-13
|
||||
-----------------------------------
|
||||
Changes:
|
||||
-----------------------------------
|
||||
New version, new tarball. Attempting to handle bad extra data for max module size, sometimes
|
||||
it is too big, and sometimes too small. Changed data gathering to use arrays, then print/process
|
||||
the arrays once they are assembled.
|
||||
|
||||
Now it will get rid of any max module size if it's greater than the calculated capacity, and it
|
||||
will generate an estimated capacity/max module size if they are clearly wrong because actual
|
||||
module sizes are greater than listed max size, or capacity is less than greatest module sizes times
|
||||
number of devices.
|
||||
|
||||
Not perfect, but it never is, this covers more cases now correctly than before.
|
||||
|
||||
-----------------------------------
|
||||
-- Harald Hope - Wed, 13 Aug 2014 20:42:00 -0700
|
||||
|
||||
=====================================================================================
|
||||
Version: 2.1.94
|
||||
Patch Version: 00
|
||||
|
|
Loading…
Reference in a new issue