CPU / processor / core info in Linux :How to get ??

To get processor info we need to run below commands in Linux

1. #cat /proc/cpuinfo

or

2. #dmidecode

To get the core info in linux use the below commands. If the processor is dual core or quad core or single core processor means we will get the "core id"value in the below commands. If no core (single core) processor  means we wont get the core id . so from the word "core id" we can get the processor is core processor or physical processor.

For examble here i took  2 servers ..

server1 - has 4 physical - single cored processors 

server 2 - has 2 physical - dual core processors

4 Physical  processor with no core (single core)  means we will get o/p like below


root:server1#  egrep "^processor|^cpu cores|^core id" /proc/cpuinfo
processor       : 0
processor       : 1
processor       : 2
processor       : 3
root:server1#

To get core info (whether core is there or not)

root:server1# grep core\ id /proc/cpuinfo |uniq -d |wc -l
0

To get total no of physical processor

root:server1# grep core\ id /proc/cpuinfo | grep -c \ 0$ | grep ^0$ >> /dev/null && grep -c processor /proc/cpuinfo || grep core\ id /proc/cpuinfo | grep -c \ 0$
4


Two dual core processor means (2- physical processor) we will get o/p like below


root:server2# egrep "^processor|^cpu cores|^core id" /proc/cpuinfo
processor       : 0
core id         : 0  ----------------- processor 1
cpu cores       : 2
processor       : 1
core id         : 0  ----------------- processor 1
cpu cores       : 2

processor       : 2
core id         : 1  ----------------- processor 2
cpu cores       : 2
processor       : 3
core id         : 1  ----------------- processor 2
cpu cores       : 2

root:server2#

To get core info run the below command

root:server2# grep core\ id /proc/cpuinfo |uniq -d |wc -l   -------> this will give how many cores are there / if no core means it will give out put as 0.
2


To get how many physical processor is there on server ,then run below command

root:server2# grep core\ id /proc/cpuinfo | grep -c \ 0$ | grep ^0$ >> /dev/null && grep -c processor /proc/cpuinfo || grep core\ id /proc/cpuinfo | grep -c \ 0$
2


====================================

Post a Comment

0 Comments