quick test of branch one inxi, ignore

This commit is contained in:
inxi-svn 2013-01-28 22:34:58 +00:00
parent b057a12938
commit 082151ef84

235
inxi
View file

@ -1,9 +1,9 @@
#!/bin/bash
########################################################################
#### Script Name: inxi
#### version: 1.8.26
#### Date: December 22 2012
#### Patch Number: 01-b1
#### version: 1.8.32
#### Date: January 23 2013
#### Patch Number: 01-one
########################################################################
#### SPECIAL THANKS
########################################################################
@ -12,21 +12,22 @@
########################################################################
#### ABOUT INXI
########################################################################
#### inxi is a fork of infobash 3.02, the original bash sys info script by locsmif
#### inxi is a fork of infobash 3.02, the original bash sys info tool by locsmif
#### As time permits functionality improvements and recoding will occur.
####
#### inxi, the universal, portable, system info script for irc.
#### inxi, the universal, portable, system information tool for irc.
#### Tested with Irssi, Xchat, Konversation, BitchX, KSirc, ircII,
#### Gaim/Pidgin, Weechat, KVIrc and Kopete.
#### Original infobash author and copyright holder:
#### Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif
#### inxi version: Copyright (C) 2008-12 Scott Rogers & Harald Hope
#### inxi version: Copyright (C) 2008-2013 Scott Rogers & Harald Hope
#### Further fixes (listed as known): Horst Tritremmel <hjt at sidux.com>
#### Steven Barrett (aka: damentz) - usb audio patch; swap percent used patch
#### Jarett.Stevens - dmidecde -M patch for older systems with the /sys
####
#### Current script home page: http://techpatterns.com/forums/about1131.html
#### Script svn: http://code.google.com/p/inxi
#### Current script home page/wiki/svn: http://inxi.googlecode.com
#### Script forums: http://techpatterns.com/forums/forum-33.html
#### IRC support: irc.oftc.net channel #smxi
####
#### 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
@ -107,7 +108,7 @@
#### * All variables should clearly explain what they are, except counters like i, j.
#### * Each word of Bash variable must be separated by '_' (underscore) (camel form), like: cpu_data
#### * Each word of Gawk variable must be like this (first word lower, following start with upper): cpuData
#### * Global variables are 'UPPER CASE', at top of script.
#### * Global variables are 'UPPER CASE', at top of this file.
#### ie, SOME_VARIABLE=''
#### * Local variables are 'lower case' and declared at the top of the function using local, always.
#### ie: local some_variable=''
@ -133,7 +134,7 @@
###################################################################################
#### KDE Konversation information. Moving from dcop(qt3/KDE3) to dbus(qt4/KDE4)
###################################################################################
#### * dcop and dbus -- these talk back to Konversation from this script
#### * dcop and dbus -- these talk back to Konversation from this program
#### * Scripting info -- http://konversation.berlios.de/docs/scripting.html
#### -- http://www.kde.org.uk/apps/konversation/
#### * dbus info -- http://dbus.freedesktop.org/doc/dbus-tutorial.html
@ -145,6 +146,7 @@
#### Because webpages come and go, the above information needs to be moved to inxi's wiki
########################################################################
#### Valuable Resources
#### CPU flags: http://unix.stackexchange.com/questions/43539/what-do-the-flags-in-proc-cpuinfo-mean
#### gawk arrays: http://www.math.utah.edu/docs/info/gawk_12.html
#### raid mdstat: http://www-01.ibm.com/support/docview.wss?uid=isg3T1011259
#### http://www.howtoforge.com/replacing_hard_disks_in_a_raid1_array
@ -1264,6 +1266,11 @@ script_self_updater()
eval $LOGFS
local wget_error=0 file_contents='' wget_man_error=0
local man_file_path="$MAN_FILE_LOCATION/inxi.1.gz"
if [[ $B_RUNNING_IN_SHELL != 'true' ]];then
print_screen_output "Sorry, you can't run the $SCRIPT_NAME self updater option (-U) in an IRC client."
exit 1
fi
print_screen_output "Starting $SCRIPT_NAME self updater."
print_screen_output "Currently running $SCRIPT_NAME version number: $SCRIPT_VERSION_NUMBER"
@ -2153,6 +2160,9 @@ get_parameters()
14)
script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_4" 'svn: branch four server'
;;
30)
B_RUNNING_IN_SHELL='true'
;;
ftp*)
ALTERNATE_FTP="$OPTARG"
;;
@ -2349,25 +2359,44 @@ show_options()
## print out version information for -V/--version
print_version_info()
{
local last_modified=$( grep -im 1 'date:' $SCRIPT_PATH/$SCRIPT_NAME | gawk '{print $3,$4,$5}' )
print_screen_output "$SCRIPT_NAME - the universal, portable, system info script for console and irc."
print_screen_output "Version: $SCRIPT_VERSION_NUMBER-$SCRIPT_PATCH_NUMBER"
print_screen_output "Script Last Modified: $last_modified"
print_screen_output "Script Location: $SCRIPT_PATH"
print_screen_output " "
print_screen_output "Tested in Irssi, Xchat, Konversation, BitchX, KSirc, ircII,"
print_screen_output "Gaim/Pidgin, Weechat, KVIrc, Quassel, Kopete, and others."
print_screen_output " "
print_screen_output "This script is a fork of Infobash 3.02, which is:"
print_screen_output "Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif"
print_screen_output "Subsequent changes and modifications (after Infobash 3.02) are:"
print_screen_output "Copyright (C) 2008-$(date +%y) Scott Rogers, Harald Hope, aka trash80 & h2"
print_screen_output " "
print_screen_output "This program is free software; you can redistribute it and/or modify"
print_screen_output "it under the terms of the GNU General Public License as published by"
print_screen_output "the Free Software Foundation; either version 3 of the License, or"
print_screen_output "(at your option) any later version."
# if not in PATH could be either . or directory name, no slash starting
local script_path=$SCRIPT_PATH script_symbolic_start=''
if [[ $script_path == '.' ]];then
script_path=$( pwd )
elif [[ -z $( grep '^/' <<< "$script_path" ) ]];then
script_path="$( pwd )/$script_path"
fi
# handle if it's a symbolic link, rare, but can happen with script directories in irc clients
# which would only matter if user starts inxi with -! 30 override in irc client
if [[ -L $script_path/$SCRIPT_NAME ]];then
script_symbolic_start=$script_path/$SCRIPT_NAME
script_path=$( readlink $script_path/$SCRIPT_NAME )
script_path=$( dirname $script_path )
fi
local last_modified=$( grep -m 1 '^#### Date:' $SCRIPT_PATH/$SCRIPT_NAME | gawk -F ': ' '{print $NF}' )
local year_modified=$( gawk '{print $NF}' <<< "$last_modified" )
print_screen_output "$SCRIPT_NAME $SCRIPT_VERSION_NUMBER-$SCRIPT_PATCH_NUMBER ($last_modified)"
if [[ $B_RUNNING_IN_SHELL == 'true' ]];then
print_screen_output " "
print_screen_output "Program Location: $script_path"
if [[ -n $script_symbolic_start ]];then
print_screen_output "Started via symbolic link: $script_symbolic_start"
fi
print_screen_output "Website: http://inxi.goooglecode.com - IRC: irc.oftc.net channel: #smxi"
print_screen_output "Forums: http://techpatterns.com/forums/forum-33.html"
print_screen_output " "
print_screen_output "$SCRIPT_NAME - the universal, portable, system information tool for console and irc."
print_screen_output "This program is a fork of Infobash 3.02:"
print_screen_output "Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif"
print_screen_output "Subsequent changes and modifications (after Infobash 3.02):"
print_screen_output "Copyright (C) 2008-$year_modified Scott Rogers, Harald Hope, aka trash80 & h2"
print_screen_output " "
print_screen_output "This program is free software; you can redistribute it and/or modify"
print_screen_output "it under the terms of the GNU General Public License as published by"
print_screen_output "the Free Software Foundation; either version 3 of the License, or"
print_screen_output "(at your option) any later version. (http://www.gnu.org/licenses/gpl.html)"
fi
}
########################################################################
@ -2384,7 +2413,7 @@ get_start_client()
eval $LOGFS
local irc_client_path='' irc_client_path_lower='' non_native_konvi='' i=''
local b_non_native_app='false' pppid='' app_working_name='' file_data=''
local b_qt4_konvi='false'
local b_qt4_konvi='false' ps_l=''
if [[ $B_RUNNING_IN_SHELL == 'true' ]];then
IRC_CLIENT='Shell'
@ -2401,7 +2430,7 @@ get_start_client()
# from inside itself, as a script, the parent is konversation/xchat, not perl/bash etc
# note: perl can report as: perl5.10.0, so it needs wildcard handling
case $app_working_name in
bash|dash|sh|python*|perl*) # We want to know who wrapped it into the shell or perl.
bash|dash|sh|zsh|python*|perl*) # We want to know who wrapped it into the shell or perl.
pppid="$( ps -p $PPID -o ppid --no-headers | sed 's/ //g' )"
if [[ -n $pppid && -f /proc/$pppid/exe ]];then
irc_client_path="$( readlink /proc/$pppid/exe )"
@ -2416,7 +2445,7 @@ get_start_client()
# as they appear.
case $app_working_name in
# check for shell first
bash|dash|sh)
bash|dash|sh|zsh)
unset IRC_CLIENT_VERSION
IRC_CLIENT="Shell wrapper"
;;
@ -2686,7 +2715,14 @@ get_start_client()
exit
}' )"
else
IRC_CLIENT="PPID=\"$PPID\" - empty?"
# this should handle certain cases where it's ssh or some other startup tool
# that falls through all the other tests
ps_l=$(ps -l | gawk '($5 == '$PPID') {print $NF}' )
if [[ -n $ps_l ]];then
IRC_CLIENT=$ps_l
else
IRC_CLIENT="PPID=\"$PPID\" - empty?"
fi
unset IRC_CLIENT_VERSION
fi
fi
@ -3076,15 +3112,32 @@ get_cpu_data()
# stop script for a bit to let cpu slow down before parsing cpu /proc file
sleep $CPU_SLEEP
IFS=$'\n'
A_CPU_DATA=( $( gawk -F': ' '
A_CPU_DATA=( $(
gawk -F': ' '
BEGIN {
IGNORECASE=1
# need to prime nr for arm cpus, which do not have processor number output in some cases
nr = 0
count = 0
bArm = "false"
}
# TAKE STRONGER NOTE: \t+ does NOT always work, MUST be [ \t]+
# TAKE NOTE: \t+ will work for $FILE_CPUINFO, but SOME ARBITRARY FILE used for TESTING might contain SPACES!
# Therefore PATCH to use [ \t]+ when TESTING!
/^processor[ \t]+:/ {
nr = $NF
gsub(/,/, " ", $NF)
gsub(/^ +| +$/, "", $NF)
if ( $NF ~ "^[0-9]+$" ) {
nr = $NF
}
else {
if ( $NF ~ "^ARM" ) {
bArm = "true"
}
count += 1
nr = count - 1
cpu[nr, "model"] = $NF
}
}
/^model name|^cpu\t+:/ {
@ -3118,7 +3171,7 @@ get_cpu_data()
cpu[nr, "cache"] = $NF
}
/^flags/ {
/^flags|^features/ {
cpu[nr, "flags"] = $NF
}
@ -3134,25 +3187,36 @@ get_cpu_data()
END {
#if (!nr) { print ",,,"; exit } # <- should this be necessary or should bash handle that
for ( i = 0; i <= nr; i++ ) {
# note: assuming bogomips for arm at 1 x clock
# http://en.wikipedia.org/wiki/BogoMips ARM could change so watch this
# maybe add: && bArm == "true" but I think most of the bogomips roughly equal cpu speed if not amd/intel
if ( cpu[i, "bogomips"] != "" && cpu[i, "speed"] == "" ) {
cpu[i, "speed"] = cpu[i, "bogomips"]
}
print cpu[i, "model"] "," cpu[i, "speed"] "," cpu[i, "cache"] "," cpu[i, "flags"] "," cpu[i, "bogomips"] "," cpu[nr, "vendor"]
}
# this is / was used in inxi short output only, but when it is N/A, need to use the previous array
# value, from above, the actual speed that is, for short output, key 0.
if (!min) {
print "not found"
print "N/A"
exit
}
if (min != max) {
printf("Min:%s%s Max:%s%s\n", min, "Mhz", max, "Mhz")
}
else {
printf("%s %s\n", max, "Mhz")
if (min != max) {
printf("Min:%s%s Max:%s%s\n", min, "Mhz", max, "Mhz")
}
else {
printf("%s %s\n", max, "Mhz")
}
}
}' $FILE_CPUINFO ) )
}
' $FILE_CPUINFO ) )
log_function_data 'cat' "$FILE_CPUINFO"
fi
IFS="$ORIGINAL_IFS"
temp_array=${A_CPU_DATA[@]}
log_function_data "A_CPU_DATA: $temp_array"
# echo ta: ${temp_array[@]}
eval $LOGFE
# echo getMainCpu: ${[@]}
}
@ -3179,10 +3243,27 @@ get_cpu_ht_multicore_smp_data()
cpu_id[0]
type = "-"
iter = 0
# needed to handle arm cpu, no processor number cases
count = 0
nr = 0
bArm = "false"
}
# array of logical processors, both HT and physical
/^processor/ {
processor_id[iter] = $NF
gsub(/,/, " ", $NF)
gsub(/^ +| +$/, "", $NF)
if ( $NF ~ "^[0-9]+$" ) {
processor_id[iter] = $NF
}
else {
if ( $NF ~ "^ARM" ) {
bArm = "true"
}
count += 1
nr = count - 1
processor_id[iter] = nr
}
}
# array of physical cpus ids
/^physical/ {
@ -3268,8 +3349,7 @@ get_cpu_ht_multicore_smp_data()
print type " " num_of_cpus " " num_of_cores
}
' $FILE_CPUINFO
) )
' $FILE_CPUINFO ) )
fi
temp_array=${A_CPU_TYPE_PCNT_CCNT[@]}
log_function_data "A_CPU_TYPE_PCNT_CCNT: $temp_array"
@ -3438,6 +3518,21 @@ get_desktop_environment()
elif [[ -n $( grep -is '^I3_' <<< "$xprop_root" ) ]];then
version=$( get_de_app_version 'i3' '^i3' '3' )
desktop_environment='i3'
elif [[ -n $( grep -is 'WINDOWMAKER' <<< "$xprop_root" ) ]];then
version=$( get_de_app_version 'wmaker' '^Window[[:space:]]*Maker' 'NF' )
if [[ -n $version ]];then
version="$version "
fi
desktop_environment="WindowMaker"
elif [[ -n $( grep -is '^_WM2' <<< "$xprop_root" ) ]];then
# note; there isn't actually a wm2 version available but error handling should cover it and return null
# maybe one day they will add it?
version=$( get_de_app_version 'wm2' '^wm2' 'NF' )
# not certain will always have version, so keep output right if not
if [[ -n $version ]];then
version="$version "
fi
desktop_environment="WM2"
fi
fi
# a few manual hacks for things that don't id with xprop, these are just good guesses
@ -3463,6 +3558,10 @@ get_desktop_environment()
elif [[ -n $( grep -Eis '([[:space:]]|/)dwm' <<< "$ps_aux" | grep -v 'grep' ) ]];then
version=$( get_de_app_version 'dwm' '^dwm' '1' )
desktop_environment='dwm'
elif [[ -n $( grep -is 'wmii2' <<< "$ps_aux" | grep -v 'grep' ) ]];then
version=$( get_de_app_version 'wmii2' '^wmii2' '1' )
desktop_environment='wmii2'
# note: in debian at least, wmii is actuall wmii3
elif [[ -n $( grep -is 'wmii' <<< "$ps_aux" | grep -v 'grep' ) ]];then
version=$( get_de_app_version 'wmii' '^wmii' '1' )
desktop_environment='wmii'
@ -3487,7 +3586,7 @@ get_de_app_version()
# mate-about -v = MATE Desktop Environment 1.4.0
case $1 in
dwm|jwm|mate-about|wmii)
dwm|jwm|mate-about|wmii|wmii2)
get_version='-v'
;;
esac
@ -3516,7 +3615,7 @@ get_de_app_version()
/'$2'/ {
# sample: dwm-5.8.2, ©.. etc, why no space? who knows. Also get rid of v in number string
# xfce, and other, output has , in it, so dump all commas
gsub(/(,|dwm-|wmii-|v|V)/, "",$'$3')
gsub(/(,|dwm-|wmii2-|wmii-|v|V)/, "",$'$3')
print $'$3'
exit # quit after first match prints
}' <<< "$version_data" )
@ -4518,13 +4617,13 @@ get_hard_drive_data_advanced()
IFS="$ORIGINAL_IFS"
## then we'll loop through that array looking for matches.
if [[ -n $( grep -E '[sv]d[a-z]' <<< ${A_HDD_DATA[@]} ) ]];then
if [[ -n $( grep -E 'sd[a-z]' <<< ${A_HDD_DATA[@]} ) ]];then
# first pack the main ls variable so we don't have to keep using ls /dev...
# not all systems have /dev/disk/by-id
ls_disk_by_id="$( ls -l /dev/disk/by-id 2>/dev/null )"
for (( i=0; i < ${#A_HDD_DATA[@]} - 1; i++ ))
do
if [[ -n $( grep -E '^[sv]d[a-z]' <<< ${A_HDD_DATA[$i]} ) ]];then
if [[ -n $( grep -E '^sd[a-z]' <<< ${A_HDD_DATA[$i]} ) ]];then
IFS=","
a_temp_working=( ${A_HDD_DATA[$i]} )
IFS="$ORIGINAL_IFS"
@ -6751,7 +6850,7 @@ process_cpu_flags()
i = 1 # start at one because of for increment issue
flag_string = ""
}
/^(lm|nx|pni|svm|vmx|(sss|ss)e([2-9])?([a-z])?(_[0-9])?)$/ {
/^(lm|nx|pae|pni|svm|vmx|(sss|ss)e([2-9])?([a-z])?(_[0-9])?)$/ {
if ( $0 == "pni" ){
a_flags[i] = "sse3"
}
@ -6899,9 +6998,16 @@ print_short_data()
local cpu_model="${a_cpu_working[0]}"
## assemble data for output
local cpu_clock="${a_cpu_working[1]}" # old CPU3
# this gets that weird min/max final array item
# this gets that weird min/max final array item, which almost never contains any data of use
local min_max_clock_nu=$(( ${#A_CPU_DATA[@]} - 1 ))
local min_max_clock=${A_CPU_DATA[$min_max_clock_nu]}
# this handles the case of for example ARM cpus, which will not have data for
# min/max, since they don't have speed. Since that sets a flag, not found, just
# look for that and use the speed from the first array array, same where we got
# model from
if [[ "$min_max_clock" == 'N/A' && ${a_cpu_working[1]} != '' ]];then
min_max_clock="${a_cpu_working[1]}"
fi
local script_patch_number=$( get_patch_version_string )
#set_color_scheme 12
@ -7108,7 +7214,8 @@ print_cpu_data()
# This has been confirmed by #bash on freenode.
# The above mentioned only emerges when using the debugging markers below
## print_screen_output "a_cpu_working=\"***${a_cpu_working[@]} $hostName+++++++\"----------"
# cpu cache
if [[ -z ${a_cpu_working[2]} ]];then
a_cpu_working[2]="unknown"
fi
@ -7133,6 +7240,7 @@ print_cpu_data()
fi
# only print shortened list
if [[ $B_CPU_FLAGS_FULL != 'true' ]];then
# gawk has already sorted this output
cpu_flags=$( process_cpu_flags "${a_cpu_working[3]}" )
cpu_flags=" ${C1}flags$SEP3${C2} ($cpu_flags)"
fi
@ -7149,6 +7257,7 @@ print_cpu_data()
print_screen_output "$cpu_data"
# we don't this printing out extra line unless > 1 cpu core
# note the numbering, the last array item is the min/max/not found for cpu speeds
if [[ ${#A_CPU_DATA[@]} -gt 2 && $B_SHOW_CPU == 'true' ]];then
for (( i=0; i < ${#A_CPU_DATA[@]}-1; i++ ))
do
@ -7179,18 +7288,26 @@ print_cpu_data()
print_cpu_flags_full()
{
eval $LOGFS
local cpu_flags_full="$1" a_cpu_flags='' line_starter=''
local i=0 counter=0 max_length=18 max_length_add=18 flag='' flag_data=''
# note: sort only sorts lines, not words in a string, so convert to lines
local cpu_flags_full="$( echo $1 | tr " " "\n" | sort )"
local a_cpu_flags='' line_starter=''
local i=0 counter=0 max_length=85 max_length_minus=15 flag='' flag_data=''
local line_length_max=''
# build the flag line array
for flag in $cpu_flags_full
do
a_cpu_flags[$counter]="${a_cpu_flags[$counter]}$flag "
if [[ $i -ge $max_length ]];then
(( counter++ ))
max_length=$(( $max_length + $max_length_add ))
if [[ $counter -eq 0 ]];then
line_length_max=$(( $max_length - $max_length_minus ))
else
line_length_max=$max_length
fi
if [[ $( wc -c <<< ${a_cpu_flags[$counter]} ) -gt $line_length_max ]];then
(( counter++ ))
fi
((i++))
done
# then print it out
for (( i=0; i < ${#a_cpu_flags[@]};i++ ))