Find cpu information in linux via script

ssh root@server.corp.com "bash -s" /tmp/server_cpu.txt

insert less than and greater symbols that include getcpu.sh after "bash -s" above

Save the following as getcpu.sh

cat /proc/cpuinfo | \
awk -v FS=':' ' \
/^physical id/ { if(nb_cpu<$2) { nb_cpu=$2 } } \
/^cpu cores/ { if(nb_cores<$2){ nb_cores=$2 } } \
/^processor/ { if(nb_units<$2){ nb_units=$2 } } \
/^model name/ { model=$2 } \
\
END{ \
nb_cpu=(nb_cpu+1); \
nb_units=(nb_units+1); \
\
print "CPU model:",model; \
print nb_cpu,"CPU,",nb_cores,"physical cores per CPU, total",nb_units,"logical CPU units" \
}'

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s