一、概述
通过top或者htop命令。可以看到每一个cpu核心的使用情况,但是服务器的整体cpu使用情况,就无法直观的看到。
需要通过shell脚本才能实现。
二、Shell脚本
cpu_ck.sh
#/bin/bash #environment variable source /etc/profile #cpu cpu_us=`vmstat | awk '{print $13}' | sed -n '$p'` cpu_sy=`vmstat | awk '{print $14}' | sed -n '$p'` cpu_id=`vmstat | awk '{print $15}' | sed -n '$p'` cpu_sum=$(($cpu_us+$cpu_sy)) echo $cpu_sum
本文参考链接: