mirror of
https://github.com/smxi/inxi.git
synced 2024-11-17 00:31:19 +00:00
testing commit, this is mainly just to test the sample data file, and to fix some bugs in the cpu sections
This commit is contained in:
parent
274e065ddb
commit
b1503df5ae
184
inxi
184
inxi
|
@ -1,8 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
########################################################################
|
########################################################################
|
||||||
#### Script Name: inxi
|
#### Script Name: inxi
|
||||||
#### version: 0.9.4-b1-t2
|
#### version: 0.9.6-b1-t1
|
||||||
#### Date: January 8, 2009
|
#### Date: 23 January 2009
|
||||||
########################################################################
|
########################################################################
|
||||||
#### SPECIAL THANKS
|
#### SPECIAL THANKS
|
||||||
########################################################################
|
########################################################################
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
#### Gaim/Pidgin, Weechat, KVIrc and Kopete.
|
#### Gaim/Pidgin, Weechat, KVIrc and Kopete.
|
||||||
#### Original infobash author and copyright holder:
|
#### Original infobash author and copyright holder:
|
||||||
#### Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif
|
#### Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif
|
||||||
#### inxi version: Copyright (C) 2008 Scott Rogers & Harald Hope
|
#### inxi version: Copyright (C) 2008-9 Scott Rogers & Harald Hope
|
||||||
#### Further fixes (listed as known): Horst Tritremmel <hjt at sidux.com>
|
#### Further fixes (listed as known): Horst Tritremmel <hjt at sidux.com>
|
||||||
####
|
####
|
||||||
#### Current script home page: http://techpatterns.com/forums/about1131.html
|
#### Current script home page: http://techpatterns.com/forums/about1131.html
|
||||||
|
@ -180,7 +180,8 @@ B_MODULES_DIR='false' #
|
||||||
B_PARTITIONS_DIR='false' #
|
B_PARTITIONS_DIR='false' #
|
||||||
|
|
||||||
### Directory's used when present
|
### Directory's used when present
|
||||||
DIR_CPUINFO='/proc/cpuinfo'
|
# DIR_CPUINFO='/proc/cpuinfo'
|
||||||
|
DIR_CPUINFO="$HOME/bin/scripts/inxi/svn/modules/data/xeon_2x_2"
|
||||||
DIR_MEMINFO='/proc/meminfo'
|
DIR_MEMINFO='/proc/meminfo'
|
||||||
DIR_ASOUND_DEVICE='/proc/asound/cards'
|
DIR_ASOUND_DEVICE='/proc/asound/cards'
|
||||||
DIR_ASOUND_VERSION='/proc/asound/version'
|
DIR_ASOUND_VERSION='/proc/asound/version'
|
||||||
|
@ -263,7 +264,7 @@ CN=''
|
||||||
### Distro Data
|
### Distro Data
|
||||||
# In cases of derived distros where the version file of the base distro can also be found under /etc,
|
# In cases of derived distros where the version file of the base distro can also be found under /etc,
|
||||||
# the derived distro's version file should go first. (Such as with Sabayon / Gentoo)
|
# the derived distro's version file should go first. (Such as with Sabayon / Gentoo)
|
||||||
DISTROS_DERIVED="antix-version kanotix-version knoppix-version mandrake-release sabayon-release sidux-version turbolinux-release zenwalk-version"
|
DISTROS_DERIVED="antix-version kanotix-version knoppix-version mandrake-release pardus-release sabayon-release sidux-version turbolinux-release zenwalk-version"
|
||||||
# debian_version excluded from DISTROS_PRIMARY so Debian can fall through to /etc/issue detection. Same goes for Ubuntu.
|
# debian_version excluded from DISTROS_PRIMARY so Debian can fall through to /etc/issue detection. Same goes for Ubuntu.
|
||||||
DISTROS_EXCLUDE_LIST="debian_version ubuntu_version"
|
DISTROS_EXCLUDE_LIST="debian_version ubuntu_version"
|
||||||
DISTROS_PRIMARY="gentoo-release redhat-release slackware-version SuSE-release"
|
DISTROS_PRIMARY="gentoo-release redhat-release slackware-version SuSE-release"
|
||||||
|
@ -1377,6 +1378,7 @@ get_cpu_core_count()
|
||||||
# count the number of processors given
|
# count the number of processors given
|
||||||
local cpu_core_count=${A_CPU_TYPE_PCNT_CCNT[2]}
|
local cpu_core_count=${A_CPU_TYPE_PCNT_CCNT[2]}
|
||||||
local cpu_type=''
|
local cpu_type=''
|
||||||
|
echo A_CPU_TYPE_PCNT_CCNT ${A_CPU_TYPE_PCNT_CCNT[2]}
|
||||||
|
|
||||||
if [[ ${A_CPU_TYPE_PCNT_CCNT[0]} == "HT" || ${A_CPU_TYPE_PCNT_CCNT[0]} == "SMP" ]]; then
|
if [[ ${A_CPU_TYPE_PCNT_CCNT[0]} == "HT" || ${A_CPU_TYPE_PCNT_CCNT[0]} == "SMP" ]]; then
|
||||||
# note the use of the space, this avoids a double space if this is null in the output
|
# note the use of the space, this avoids a double space if this is null in the output
|
||||||
|
@ -1409,11 +1411,12 @@ get_cpu_data()
|
||||||
|
|
||||||
if [[ $B_CPUINFO == 'true' ]];then
|
if [[ $B_CPUINFO == 'true' ]];then
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
A_CPU_DATA=($(gawk -F': ' '
|
A_CPU_DATA=( $( gawk -F': ' '
|
||||||
{ IGNORECASE=1 }
|
{ IGNORECASE=1 }
|
||||||
|
# TAKE STRONGER NOTE: \t+ does NOT always work, MUST be [ \t]+
|
||||||
# TAKE NOTE: \t+ will work for $DIR_CPUINFO, but SOME ARBITRARY FILE used for TESTING might contain SPACES!
|
# TAKE NOTE: \t+ will work for $DIR_CPUINFO, but SOME ARBITRARY FILE used for TESTING might contain SPACES!
|
||||||
# Therefore PATCH to use [ \t]+ when TESTING!
|
# Therefore PATCH to use [ \t]+ when TESTING!
|
||||||
/^processor\t+:/ { nr = $NF }
|
/^processor[ \t]+:/ { nr = $NF }
|
||||||
|
|
||||||
/^model name|^cpu\t+:/ {
|
/^model name|^cpu\t+:/ {
|
||||||
gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF )
|
gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF )
|
||||||
|
@ -1468,10 +1471,11 @@ get_cpu_data()
|
||||||
else {
|
else {
|
||||||
printf("%s %s\n", max, "Mhz")
|
printf("%s %s\n", max, "Mhz")
|
||||||
}
|
}
|
||||||
}' $DIR_CPUINFO))
|
}' $DIR_CPUINFO ) )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
IFS="$ORIGINAL_IFS"
|
IFS="$ORIGINAL_IFS"
|
||||||
|
# echo getMainCpu: ${[@]}
|
||||||
}
|
}
|
||||||
|
|
||||||
## this is for counting processors and finding HT types
|
## this is for counting processors and finding HT types
|
||||||
|
@ -1484,36 +1488,57 @@ get_cpu_ht_multicore_smp_data()
|
||||||
# if = 1 processor then single core/processor Uni-Processor (UP)
|
# if = 1 processor then single core/processor Uni-Processor (UP)
|
||||||
|
|
||||||
if [[ $B_CPUINFO == 'true' ]]; then
|
if [[ $B_CPUINFO == 'true' ]]; then
|
||||||
{
|
# A_CPU_TYPE_PCNT_CCNT=( $(
|
||||||
A_CPU_TYPE_PCNT_CCNT=( $(gawk '
|
gawk '
|
||||||
BEGIN { FS=": "; i = 0 } {IGNORECASE = 1}
|
BEGIN {
|
||||||
/^processor/ { num_of_processors = $NF + 1 } # counts logical processors, both HT and physical
|
FS=": "
|
||||||
/^cpu cores/ { num_of_cores = $NF } # counts physical cores
|
IGNORECASE = 1
|
||||||
/^physical/ { physical_id[i] = $NF } # array of physical cpus ids
|
i = 0
|
||||||
/^core id/ { core_id[i] = $NF; i++ } # array of core ids
|
|
||||||
{
|
|
||||||
processors = 1
|
processors = 1
|
||||||
cores = 1 # single cores are obviously a Uni-processor
|
cores = 1 # single cores are obviously a Uni-processor
|
||||||
type = "UP"
|
type = "UP"
|
||||||
cpu_temp = 0
|
cpu_temp = 0
|
||||||
core_temp = 0
|
core_temp = 0
|
||||||
|
}
|
||||||
|
# counts logical processors, both HT and physical
|
||||||
|
/^processor/ {
|
||||||
|
num_of_processors = $NF + 1
|
||||||
|
}
|
||||||
|
# counts physical cores
|
||||||
|
/^cpu cores/ {
|
||||||
|
num_of_cores = $NF
|
||||||
|
}
|
||||||
|
# array of physical cpus ids
|
||||||
|
/^physical/ {
|
||||||
|
physical_id[i] = $NF
|
||||||
|
}
|
||||||
|
# array of core ids
|
||||||
|
/^core id/ {
|
||||||
|
core_id[i] = $NF
|
||||||
|
i++
|
||||||
|
# print "i: " i
|
||||||
|
}
|
||||||
|
END {
|
||||||
# look for the largest id number, and assign it
|
# look for the largest id number, and assign it
|
||||||
for ( j = 0; j <= num_of_processors; j++)
|
for ( j = 0; j < num_of_processors; j++ )
|
||||||
{
|
{
|
||||||
if ( physical[j] > cpu_temp )
|
if ( physical_id[j] > cpu_temp )
|
||||||
{
|
{
|
||||||
cpu_temp = physical[j]
|
cpu_temp = physical_id[j]
|
||||||
|
# print "physical_id: " physical_id[j]
|
||||||
}
|
}
|
||||||
if ( core_id[j] > core_temp )
|
if ( core_id[j] > core_temp )
|
||||||
{
|
{
|
||||||
core_temp = core_id[j]
|
core_temp = core_id[j]
|
||||||
|
# print "core_temp: " core_id[j]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
physical_cpu_count = cpu_temp + 1
|
physical_cpu_count = cpu_temp + 1
|
||||||
core_count = core_temp + 1
|
core_count = core_temp + 1
|
||||||
|
|
||||||
|
# print "physical_cpu_count: " physical_cpu_count
|
||||||
|
|
||||||
# looking at logical processor counts over 1, which means either HT, SMP or MCP
|
# looking at logical processor counts over 1, which means either HT, SMP or MCP
|
||||||
if ( num_of_processors > 1 )
|
if ( num_of_processors > 1 )
|
||||||
{
|
{
|
||||||
|
@ -1549,11 +1574,12 @@ get_cpu_ht_multicore_smp_data()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
print type " " processors " " cores
|
||||||
}
|
}
|
||||||
END { print type " " processors " " cores }
|
' $DIR_CPUINFO
|
||||||
' $DIR_CPUINFO ))
|
# ) )
|
||||||
}
|
|
||||||
fi
|
fi
|
||||||
|
# echo A_CPU_TYPE_PCNT_CCNT:1 ${A_CPU_TYPE_PCNT_CCNT[@]}
|
||||||
}
|
}
|
||||||
|
|
||||||
# for more on distro id, please reference this python thread: http://bugs.python.org/issue1322
|
# for more on distro id, please reference this python thread: http://bugs.python.org/issue1322
|
||||||
|
@ -1861,101 +1887,37 @@ get_hdd_data_basic()
|
||||||
{
|
{
|
||||||
local hdd_used=''
|
local hdd_used=''
|
||||||
|
|
||||||
# dfdata="Filesystem 1K-blocks Used Available Use% Mounted on
|
hdd_used=$( df | gawk '
|
||||||
# /dev/hdc7 5289348 2811800 2208864 57% /
|
/^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/ {
|
||||||
# tmpfs 1037688 0 1037688 0% /lib/init/rw
|
# this handles the case where the first item is too long
|
||||||
# udev 10240 116 10124 2% /dev
|
# and makes df wrap output to next line, so here we advance
|
||||||
# tmpfs 1037688 0 1037688 0% /dev/shm
|
# it to the next line for that single case
|
||||||
# /dev/hdc8 8420132 4218360 3774044 53% /home
|
if ( NF == 1 ) {
|
||||||
# /dev/hdc5 32981408 20955204 12026204 64% /media/hd2
|
getline
|
||||||
# /dev/sdb1 390700768 188926868 201773900 49% /media/Snusmumrikken
|
|
||||||
# /dev/sda1 732572000 248156936 484415064 34% /media/Mr. Big"
|
|
||||||
# # hdd_used=$( df | gawk '
|
|
||||||
if [[ $B_TESTING_1 == 'true' ]];then
|
|
||||||
hdd_used=$( df | gawk '
|
|
||||||
/^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/ {
|
|
||||||
# this handles the case where the first item is too long
|
|
||||||
# and makes df wrap output to next line, so here we advance
|
|
||||||
# it to the next line for that single case
|
|
||||||
if ( NF == 1 ) {
|
|
||||||
getline
|
|
||||||
}
|
|
||||||
if ( $4 ~ /.*\%/ ) {
|
|
||||||
print "b: " $1 " used: " $2 " full: " $1
|
|
||||||
used += $2
|
|
||||||
full += $1
|
|
||||||
}
|
|
||||||
else if ( $5 ~ /.*\%/ ) {
|
|
||||||
print "a: " $1 " used: " $3 " full: " $2
|
|
||||||
used += $3
|
|
||||||
full += $2
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
next
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
END {
|
# if the first item caused a wrap, use one less than standard
|
||||||
print "Remember, this is only for your mounted stuff in df!!"
|
# testing for the field with % in it, ie: 34%, then go down from there
|
||||||
used = used*1024/1000**3
|
# this also protects against cases where the mount point has a space in the
|
||||||
print "used : " used
|
# file name, thus breaking going down from $NF directly.
|
||||||
full = full*1024/1000**3
|
if ( $4 ~ /.*\%/ ) {
|
||||||
print "full : " full
|
used += $2
|
||||||
percent = used/full
|
|
||||||
print "percent : " percent
|
|
||||||
}' )
|
|
||||||
elif [[ $B_TESTING_2 == 'true' ]];then
|
|
||||||
hdd_used=$( df | gawk '
|
|
||||||
p {
|
|
||||||
if (/^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/) {
|
|
||||||
if (NF == 1) {
|
|
||||||
getline
|
|
||||||
if (NF == 5) {
|
|
||||||
c += $2
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
next
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (NF == 6) {
|
|
||||||
c += $3
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/^Filesystem/ { p++ }
|
# otherwise use standard
|
||||||
END {
|
else if ( $5 ~ /.*\%/ ) {
|
||||||
print c
|
used += $3
|
||||||
}' )
|
|
||||||
else
|
|
||||||
hdd_used=$( df | gawk '
|
|
||||||
/^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/ {
|
|
||||||
# this handles the case where the first item is too long
|
|
||||||
# and makes df wrap output to next line, so here we advance
|
|
||||||
# it to the next line for that single case
|
|
||||||
if ( NF == 1 ) {
|
|
||||||
getline
|
|
||||||
}
|
|
||||||
# if the first item caused a wrap, use one less than standard
|
|
||||||
if ( $4 ~ /.*\%/ ) {
|
|
||||||
used += $2
|
|
||||||
}
|
|
||||||
# otherwise use standard
|
|
||||||
else if ( $5 ~ /.*\%/ ) {
|
|
||||||
used += $3
|
|
||||||
}
|
|
||||||
# and if this is not detected, give up, we need user data to debug
|
|
||||||
else {
|
|
||||||
next
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
END {
|
# and if this is not detected, give up, we need user data to debug
|
||||||
print used
|
else {
|
||||||
}' )
|
next
|
||||||
fi
|
}
|
||||||
|
}
|
||||||
|
END {
|
||||||
|
print used
|
||||||
|
}' )
|
||||||
|
|
||||||
if [[ -z $hdd_used ]];then
|
if [[ -z $hdd_used ]];then
|
||||||
hdd_used='na'
|
hdd_used='na'
|
||||||
fi
|
fi
|
||||||
echo hdd_used "$hdd_used"
|
|
||||||
|
|
||||||
# create the initial array strings:
|
# create the initial array strings:
|
||||||
# disk-dev, capacity, name, usb or not
|
# disk-dev, capacity, name, usb or not
|
||||||
|
|
Loading…
Reference in a new issue