Get the system startup time and cpu core count commands through the shell

In Linux, we often use the uptime command to see the running time of the system. It is related to a file, which is /proc/uptime, which is described in detail below.

master@jay-intel:# cat /proc/uptime
6447032.12 48185264.69
master@jay-intel:# cat /proc/cpuinfo  | grep processor | wc -l
8

master@jay-intel/ :# cat /proc/cpuinfo
Processor       : AArch64 Processor rev 3 (aarch64)
processor       : 0
model name      : AArch64 Processor rev 3 (aarch64)
BogoMIPS        : 26.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 3
processor       : 1
model name      : AArch64 Processor rev 3 (aarch64)
BogoMIPS        : 26.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 3

processor       : 2
model name      : AArch64 Processor rev 3 (aarch64)
BogoMIPS        : 26.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 3

processor       : 3
model name      : AArch64 Processor rev 3 (aarch64)
BogoMIPS        : 26.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 3

Hardware        : MT6737T
master@jay-intel/ #
master@jay-intel/ #
master@jay-intel/ #
master@jay-intel/ #
master@jay-intel/ #
master@jay-intel/ # cat /proc/cpuinfo
Processor       : AArch64 Processor rev 3 (aarch64)
processor       : 0
model name      : AArch64 Processor rev 3 (aarch64)
BogoMIPS        : 26.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 3

processor       : 1
model name      : AArch64 Processor rev 3 (aarch64)
BogoMIPS        : 26.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 3

processor       : 2
model name      : AArch64 Processor rev 3 (aarch64)
BogoMIPS        : 26.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 3

processor       : 3
model name      : AArch64 Processor rev 3 (aarch64)
BogoMIPS        : 26.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 3

Hardware        : MT6764T

The output in the first column is the time from system startup to the present (in seconds) , which is abbreviated as num1 here;
the output in the second column is the idle time of the system (in seconds) , which is abbreviated as num2 here.

Note that many people know that the second is the system idle time, but you may not know that, in an SMP system, the system idle time is sometimes several times the system running time. What is going on?
Because the calculation of system idle time is to include SMP, that is to say, you have several logical CPUs (including hyperthreading).

System idle rate (%) = num2/(num1*N) where N is the number of CPUs in the SMP system.

From the data on one of my machines above, it can be seen that
the length of time since the machine started: 6447032.12 seconds = 74.6 days
Idle rate: 48185264.69/(6447032.12*8)=93.4%

The higher the system idle rate, the more idle the system, which can increase some load; while the system idle rate is small, you may consider upgrading the hardware of the machine or migrating part of the load to other machines.

Some docs from Redhat:
The first number is the total number of seconds the system has been up. The second number is how much of that time the machine has spent idle, in seconds. (Jay’s comments: Please pay attention to SMP system.)

Guess you like

Origin blog.csdn.net/jinhoward/article/details/108381403