From ad98ca6626265443234bc9be54a8a5aab51883d0 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 25 Mar 2016 23:43:24 +0100 Subject: fix cpu_speed reading for fixed speed cpu --- sysinfo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysinfo.sh b/sysinfo.sh index 563e3f4..d382cfa 100755 --- a/sysinfo.sh +++ b/sysinfo.sh @@ -23,7 +23,7 @@ if [ -z "${cpu}" ]; then # fallback cpu=`uname -p` fi -cpu_speed=`cat /proc/cpuinfo | head -n 7 | tail -n 1 | cut -d ":" -f 2 | cut -d "." -f 1 | sed 's/^ *//'` +cpu_speed=`cat /proc/cpuinfo | grep '^cpu MHz' | head -n 1 | cut -f2 -d':' | cut -c2- | cut -f1 -d'.'` cpu_load=` cat /proc/loadavg | cut -d " " -f 1 | sed 's/,//'` # Detect frequency scaler -- cgit v1.2.3 From aeda521695b7b0383889f2ea607a70873ddd12f0 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 26 Mar 2016 00:03:33 +0100 Subject: enable long version --- sysinfo.sh | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/sysinfo.sh b/sysinfo.sh index d382cfa..eebff52 100755 --- a/sysinfo.sh +++ b/sysinfo.sh @@ -45,19 +45,36 @@ if [ -x `which lspci` ]; then vga=`lspci | grep VGA | cut -d ":" -f 3 | sed 's/ *(rev.*//' | sed 's/^ *//' | sed 's/^.*\[//' | sed 's/\].*//'` fi +case "${1}" in + '-l'|'--long') + #---[ PRINT LONG VERSION ]------------- -#echo "[system] ${os} uptime: ${uptime}" -#echo "[cpu] ${cpu} ${cpu_speed} Mhz" -#echo "[memory] ${mem_total}Mib total ${mem_app} Mb used ${mem_free}Mb free ${mem_buffers}Mib buffers ${mem_cache}Mb cache" -#echo "[swap] ${swap_total}Mib total ${swap_used} Mb used ${swap_free}Mib free" -#echo "[disk] ${disk_size} Gib total ${disk_used} Gib used ${disk_free} Gib free" + + vga_line='' + if [ ! -z "${vga}" ]; then + vga_line="[vga] ${vga}" + fi + + grep -v '^$' <<-EOF + [host] ${host} + [system] ${os}, uptime: ${uptime}, load: ${cpu_load} + [cpu] ${cpu}, ${cpu_speed} Mhz + ${vga_line} + [memory] ${mem_total} Mib total, ${mem_used} Mib used, ${mem_free} Mib free + [swap] ${swap_total} Mib total, ${swap_used} Mb used, ${swap_free} Mib free + [disk] ${disk_size} Gib total, ${disk_used} Gib used, ${disk_free} Gib free + EOF + + exit + ;; +esac #--- [ PRINT SHORT VERSION ]---------- echo -n "[${host}]" echo -n "[${os}]" echo -n "[${cpu}]" -if [ "x${vga}" != "x" ]; then +if [ ! -z "${vga}" ]; then echo -n "[${vga}]" fi echo -n "[Memory used: ${mem_used}/${mem_total} Mib]" -- cgit v1.2.3 From a2fc10aa5e07c1f95626019dfea98ed71ad2855a Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 26 Mar 2016 00:09:16 +0100 Subject: better cpu frequency displaying (only Intel puts frequency in cpu name) --- sysinfo.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sysinfo.sh b/sysinfo.sh index eebff52..e0e1827 100755 --- a/sysinfo.sh +++ b/sysinfo.sh @@ -18,7 +18,7 @@ swap_free=`cat /proc/meminfo | grep -i SwapFree | awk '{printf "%d",$2/1024;}'` swap_used=`echo ${swap_total} ${swap_free} | awk '{printf "%d",$1-$2;}'` #--- [ CPU ] -------------------------- -cpu=`cat /proc/cpuinfo | grep "model name" | head -n 1 | sed 's/^.*: //'` +cpu=`cat /proc/cpuinfo | grep "model name" | head -n 1 | sed 's/[ ][ ]*/ /g;s/^.*: //' | sed -e 's/ @ .*//'` if [ -z "${cpu}" ]; then # fallback cpu=`uname -p` @@ -73,7 +73,7 @@ esac echo -n "[${host}]" echo -n "[${os}]" -echo -n "[${cpu}]" +echo -n "[${cpu} @ ${cpu_speed} MHz]" if [ ! -z "${vga}" ]; then echo -n "[${vga}]" fi -- cgit v1.2.3 From 3b3838e2252a3813d95ddf84d755173452417752 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 26 Mar 2016 00:14:47 +0100 Subject: add cpu core count (only AMD puts cpu core count in cpu name) --- sysinfo.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sysinfo.sh b/sysinfo.sh index e0e1827..d588b41 100755 --- a/sysinfo.sh +++ b/sysinfo.sh @@ -18,7 +18,7 @@ swap_free=`cat /proc/meminfo | grep -i SwapFree | awk '{printf "%d",$2/1024;}'` swap_used=`echo ${swap_total} ${swap_free} | awk '{printf "%d",$1-$2;}'` #--- [ CPU ] -------------------------- -cpu=`cat /proc/cpuinfo | grep "model name" | head -n 1 | sed 's/[ ][ ]*/ /g;s/^.*: //' | sed -e 's/ @ .*//'` +cpu=`cat /proc/cpuinfo | grep "model name" | head -n 1 | sed 's/[ ][ ]*/ /g;s/^.*: //' | sed -e 's/ @ .*//' | sed -e 's/ [A-Za-z]*[ -]Core Processor//'` if [ -z "${cpu}" ]; then # fallback cpu=`uname -p` @@ -26,6 +26,12 @@ fi cpu_speed=`cat /proc/cpuinfo | grep '^cpu MHz' | head -n 1 | cut -f2 -d':' | cut -c2- | cut -f1 -d'.'` cpu_load=` cat /proc/loadavg | cut -d " " -f 1 | sed 's/,//'` +cpu_count=`grep '^processor' /proc/cpuinfo | wc -l` +if [ "${cpu_count}" -gt 1 ] +then + cpu_count_notice=" * ${cpu_count} cores" +fi + # Detect frequency scaler if [ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq ]; then cpu_speed_max=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq | awk '{ printf "%d", $1/1000;}'` @@ -58,7 +64,7 @@ case "${1}" in grep -v '^$' <<-EOF [host] ${host} [system] ${os}, uptime: ${uptime}, load: ${cpu_load} - [cpu] ${cpu}, ${cpu_speed} Mhz + [cpu] ${cpu}${cpu_count_notice}, ${cpu_speed} Mhz ${vga_line} [memory] ${mem_total} Mib total, ${mem_used} Mib used, ${mem_free} Mib free [swap] ${swap_total} Mib total, ${swap_used} Mb used, ${swap_free} Mib free @@ -73,7 +79,7 @@ esac echo -n "[${host}]" echo -n "[${os}]" -echo -n "[${cpu} @ ${cpu_speed} MHz]" +echo -n "[${cpu}${cpu_count_notice} @ ${cpu_speed} MHz]" if [ ! -z "${vga}" ]; then echo -n "[${vga}]" fi -- cgit v1.2.3 From 3adec3aa7e6f9dea4e5f22831aa669fefcc752f9 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 26 Mar 2016 01:12:16 +0100 Subject: remove annoying trademark/registered notices in cpu name --- sysinfo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysinfo.sh b/sysinfo.sh index d588b41..b4011d9 100755 --- a/sysinfo.sh +++ b/sysinfo.sh @@ -18,7 +18,7 @@ swap_free=`cat /proc/meminfo | grep -i SwapFree | awk '{printf "%d",$2/1024;}'` swap_used=`echo ${swap_total} ${swap_free} | awk '{printf "%d",$1-$2;}'` #--- [ CPU ] -------------------------- -cpu=`cat /proc/cpuinfo | grep "model name" | head -n 1 | sed 's/[ ][ ]*/ /g;s/^.*: //' | sed -e 's/ @ .*//' | sed -e 's/ [A-Za-z]*[ -]Core Processor//'` +cpu=`cat /proc/cpuinfo | grep "model name" | head -n 1 | sed 's/[ ][ ]*/ /g;s/^.*: //' | sed -e 's/ @ .*//' | sed -e 's/ [A-Za-z]*[ -]Core Processor//' | sed -e 's/([Tt][Mm])//;s/([Rr])//'` if [ -z "${cpu}" ]; then # fallback cpu=`uname -p` -- cgit v1.2.3 From aa2aaefa13267b51c9548fb0c3192f838b95a5ea Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 26 Mar 2016 01:27:31 +0100 Subject: better gpu print (add vendor name) --- sysinfo.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sysinfo.sh b/sysinfo.sh index b4011d9..fa988e1 100755 --- a/sysinfo.sh +++ b/sysinfo.sh @@ -46,9 +46,12 @@ disk_used=`echo $sua | awk '{printf "%d",$3/1048576;}'`; disk_free=`echo $sua | awk '{printf "%d",$4/1048576;}'`; #---[ VGA ] --------------------------- -vga="" +gpu='' if [ -x `which lspci` ]; then - vga=`lspci | grep VGA | cut -d ":" -f 3 | sed 's/ *(rev.*//' | sed 's/^ *//' | sed 's/^.*\[//' | sed 's/\].*//'` + gpu_slot=`lspci -mm | grep 'VGA' | head -n 1 | cut -f1 -d' '` + gpu_vendor=`lspci -s "${gpu_slot}" -mm -v | grep '^Vendor' | sed -e 's/Vendor:\t//' | sed -e 's/.*[ ]\[//;s/\].*//'` + gpu_model=`lspci -s "${gpu_slot}" -mm -v | grep '^Device' | sed -e 's/Device:\t//' | sed -e 's/.*[ ]\[//;s/\].*//'` + gpu="${gpu_vendor} ${gpu_model}" fi case "${1}" in @@ -56,16 +59,16 @@ case "${1}" in #---[ PRINT LONG VERSION ]------------- - vga_line='' - if [ ! -z "${vga}" ]; then - vga_line="[vga] ${vga}" + gpu_line='' + if [ ! -z "${gpu}" ]; then + gpu_line="[gpu] ${gpu}" fi grep -v '^$' <<-EOF [host] ${host} [system] ${os}, uptime: ${uptime}, load: ${cpu_load} [cpu] ${cpu}${cpu_count_notice}, ${cpu_speed} Mhz - ${vga_line} + ${gpu_line} [memory] ${mem_total} Mib total, ${mem_used} Mib used, ${mem_free} Mib free [swap] ${swap_total} Mib total, ${swap_used} Mb used, ${swap_free} Mib free [disk] ${disk_size} Gib total, ${disk_used} Gib used, ${disk_free} Gib free @@ -80,8 +83,8 @@ esac echo -n "[${host}]" echo -n "[${os}]" echo -n "[${cpu}${cpu_count_notice} @ ${cpu_speed} MHz]" -if [ ! -z "${vga}" ]; then - echo -n "[${vga}]" +if [ ! -z "${gpu}" ]; then + echo -n "[${gpu}]" fi echo -n "[Memory used: ${mem_used}/${mem_total} Mib]" echo -n "[Swap used: ${swap_used}/${swap_total} Mib]" -- cgit v1.2.3 From d320b733714053cc699b6e7684dc43bd62a14d1f Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 26 Mar 2016 00:58:00 +0100 Subject: remove annoying corp/inc/ltd notices in gpu vendor name --- sysinfo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysinfo.sh b/sysinfo.sh index fa988e1..55b5990 100755 --- a/sysinfo.sh +++ b/sysinfo.sh @@ -49,7 +49,7 @@ disk_free=`echo $sua | awk '{printf "%d",$4/1048576;}'`; gpu='' if [ -x `which lspci` ]; then gpu_slot=`lspci -mm | grep 'VGA' | head -n 1 | cut -f1 -d' '` - gpu_vendor=`lspci -s "${gpu_slot}" -mm -v | grep '^Vendor' | sed -e 's/Vendor:\t//' | sed -e 's/.*[ ]\[//;s/\].*//'` + gpu_vendor=`lspci -s "${gpu_slot}" -mm -v | grep '^Vendor' | sed -e 's/Vendor:\t//' | sed -e 's/.*[ ]\[//;s/\].*//' | sed -e 's/, Inc.//;s/ Corporation//;s/ Co.//;s/,Ltd.//'` gpu_model=`lspci -s "${gpu_slot}" -mm -v | grep '^Device' | sed -e 's/Device:\t//' | sed -e 's/.*[ ]\[//;s/\].*//'` gpu="${gpu_vendor} ${gpu_model}" fi -- cgit v1.2.3 From c2adef241453fea1bdf27f8d78896fde7e8a88dc Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 26 Mar 2016 12:08:28 +0100 Subject: Cleaned up program flow, capitalized B for binary units --- sysinfo.sh | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/sysinfo.sh b/sysinfo.sh index 55b5990..4b80d7f 100755 --- a/sysinfo.sh +++ b/sysinfo.sh @@ -54,42 +54,49 @@ if [ -x `which lspci` ]; then gpu="${gpu_vendor} ${gpu_model}" fi +#---[ OUTPUT ]------------------------ + case "${1}" in '-l'|'--long') -#---[ PRINT LONG VERSION ]------------- + #---[ LONG VERSION ]-- gpu_line='' if [ ! -z "${gpu}" ]; then gpu_line="[gpu] ${gpu}" fi + # output until EOF, strip leading TAB characters and empty lines grep -v '^$' <<-EOF [host] ${host} [system] ${os}, uptime: ${uptime}, load: ${cpu_load} [cpu] ${cpu}${cpu_count_notice}, ${cpu_speed} Mhz ${gpu_line} - [memory] ${mem_total} Mib total, ${mem_used} Mib used, ${mem_free} Mib free - [swap] ${swap_total} Mib total, ${swap_used} Mb used, ${swap_free} Mib free - [disk] ${disk_size} Gib total, ${disk_used} Gib used, ${disk_free} Gib free + [memory] ${mem_total} MiB total, ${mem_used} MiB used, ${mem_free} MiB free + [swap] ${swap_total} MiB total, ${swap_used} MiB used, ${swap_free} MiB free + [disk] ${disk_size} GiB total, ${disk_used} GiB used, ${disk_free} GiB free EOF + ;; + *) + #---[ SHORT VERSION ]- + + gpu_line='' + if [ ! -z "${gpu}" ]; then + gpu_line="[${gpu}]" + fi - exit - ;; + # output until EOF, strip TAB characters + tr -d "\t" <<-EOF + [${host}]\ + [${os}]\ + [${cpu}${cpu_count_notice} @ ${cpu_speed} MHz]\ + ${gpu_line}\ + [Memory used: ${mem_used}/${mem_total} MiB]\ + [Swap used: ${swap_used}/${swap_total} MiB]\ + [Disk used: ${disk_used}/${disk_size} GiB]\ + [Load ${cpu_load}]\ + [Uptime ${uptime}] + EOF + ;; esac -#--- [ PRINT SHORT VERSION ]---------- - -echo -n "[${host}]" -echo -n "[${os}]" -echo -n "[${cpu}${cpu_count_notice} @ ${cpu_speed} MHz]" -if [ ! -z "${gpu}" ]; then - echo -n "[${gpu}]" -fi -echo -n "[Memory used: ${mem_used}/${mem_total} Mib]" -echo -n "[Swap used: ${swap_used}/${swap_total} Mib]" -echo -n "[Disk used: ${disk_used}/${disk_size} Gib]" -echo -n "[Load ${cpu_load}]" -echo -n "[Uptime ${uptime}]" -echo "" - -- cgit v1.2.3