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