Linux Monitoring platform Build-cpu
Currently the main CPU of the server is Intel or AMD. What the frequency is. Multicore, multi-threading, concurrency, parallel, overclocking, primary cache, level two cache, level three cache. i386, x86
CPU: contains arithmetic logic, control, memory and other units
frequency: is the number of times the CPU can work per second. 3.0GHz This CPU is 3.0*10 within one second (9)
FSB: CPU and external components for data transmission, operation is the speed. It is best to match the memory.
total number of cores = number of physical CPUs X number of cores per physical CPU
Total logical CPUs = number of physical CPUs x number of cores per physical CPU X number of hyper-threads
To view the number of physical CPUs: cat/proc/cpuinfo| grep "Physical ID" | Sort| uniq| Wc-l
View the number of cores in each physical CPU (that is, the number of nuclei): cat/proc/cpuinfo| grep "CPU Cores" | Uniq
To view the number of logical CPUs: cat/proc/cpuinfo| grep "Processor" | Wc-l
View CPU information (model): Cat/proc/cpuinfo | grep name | Cut-f2-d: | Uniq-c
To view the CPU's main frequency: Cat/proc/cpuinfo |grep Mhz|uniq
1. Monitor the relevant CPU calculation methods: By collecting/proc/stat, you can refer to the statistical output of SAR commands to understand.
The percentage of time that Cpu.idle:CPU or CPUs is idle and the system does not have outstanding disk I/O requests.
Cpu.busy: As opposed to Cpu.idle, his value equals 100 minus cpu.idle.
The percentage of time Cpu.guest:CPU or CPUs is used to run the virtual processor.
The percentage of time spent by Cpu.iowait:CPU or CPUs to maintain hardware interrupts.
The percentage of time spent by Cpu.irq:CPU or CPUs to maintain hardware interrupts.
The percentage of time spent by Cpu.softirq:CPU or CPUs to service software outages.
Cpu.nice: The percentage of CPU utilization that is performed at a high-priority user level.
Cpu.steal: The percentage of time that a virtual CPU or CPUs spends in an involuntary wait while the hypervisor is serving another virtual processor.
Cpu.system: The percentage of CPU utilization that is performed at the system level (kernel).
Cpu.user: Percentage of CPU usage at User level (application) execution.
CPU.CNT:CPU number of cores.
Cpu.switches:cpu the number of context switches, counter type. In stat, it's this ctxt 30516916343.
CPU Time =USER+SYSTEM+NICE+IDLE+IOWAIT+IRQ+SOFTIRQ
Example: View CPU core 0
%USR%nice%sys%iowait%irq%soft%steal%guest%idle
Cpu0 3143580 88 2678777 3863810314 2442 0 5461 0 0
Btime: This line shows the time from the start of the system up to now (in epoch time, 1970-01-01 00:00:00 +0000 (UTC)), in seconds.
Processes: (Total_forks) The number of tasks created since the system started.
Procs_running: The number of tasks currently running the queue.
Procs_blocked: The number of tasks that are currently blocked.
SOFTIRQ: Accumulated from the start of the system to the current moment, soft interrupt time (unit: jiffies)
Intr: This line gives the interrupt information, the first is the number of interrupts that have occurred since the system started, and then each number corresponds to the number of times that a particular interrupt has occurred since the system started.
2. Monitoring the relevant Cpu-load calculation method: Read/proc/loadavg, which are primitive value types:
Load.1min: Represents the average load for the last 1 minutes (depending on the number of cores of the machine)
Load.5min: Indicates the average negative of the last 5 minutes (depending on the number of cores of the machine)
Load.15min: Represents the average load for the last 15 minutes (depending on the number of cores of the machine)
Common commands: SAR, Mpstat, Top, Iostat, Vmstat, W ...
Mpstat [-p {cpu| All}] [internal [count]]
3. How to get process cmd:
Ps-e o User,pid,cmd | grep ssh
PS W-p $pid
4. Calculate when the process started:
Ps-p $pid-O lstart
or script
#!/bin/bash
Pid=$1
elt=$ (PS w-p $pid o pid=,cmd=,etime= | awk ' {print $NF} ')
Case $ (echo $elt | sed-e ' s/:/:\n/g ' | grep ":"-c) in
"1")
elt=$ (echo $elt | sed-e ' s/:/minutes ago/')
;;
*)
elt=$ (echo $elt | sed-e ' s/-/days ago/'-E ' s/:/hours ago/'-e ' s/:/minutes ago/')
;;
Esac
date-d "$elt seconds Ago"
5. View the status of a single process:
cat/proc/$pid/stat
Reference:
http://blog.51cto.com/asinego/1949715
Linux Monitoring platform Build-cpu