#########################################
#思路:通过/proc/stat获取cpu使用信息,根据cpu使用数值计算:
#user - CPU 花在用户模式的时间,即运行应用程序花费的时间
#nice - CPU 花在 nice 值大于一般值 0 (即有较低优先级别) 进程的时间。
#system - CPU 花在系统模式即在内核空间 (kernel space) 的时间,即在运行内核工作的时间
#idle - CPU 闲置的时间,其值一定为 /proc/uptime 中第二个项目乘 USER_HZ
#iowait - CPU 花在等候输入/输出的时间,Linux 2.5.41 开始才开始支援
#irq - CPU 花在处理硬件中断 (hardware interrupt) 的时间,Linux 2.6.0-test4 开始支持
#softirq- CPU 花在处理 softirq 软件中断的时间,Linux 2.6.0-test4 开始支持
#steal_time - 在虚拟环境下 CPU 花在处理其他作业系统的时间,Linux 2.6.11 开始支持(虚拟环境下出现,本例中无此项)
#guest - 在 Linux 内核控制下 CPU 为 guest 作业系统运行虚拟 CPU 的时间,Linux 2.6.24 开始支持(虚拟环境下出现,本例中无此项)
#CPU总时间:total=user+nice+system+idle+iowait+irq+softirq+steal_time+guest
#CPU繁忙时间:time=user+nice+system
#思路:通过/proc/stat获取cpu使用信息,根据cpu使用数值计算:
#user - CPU 花在用户模式的时间,即运行应用程序花费的时间
#nice - CPU 花在 nice 值大于一般值 0 (即有较低优先级别) 进程的时间。
#system - CPU 花在系统模式即在内核空间 (kernel space) 的时间,即在运行内核工作的时间
#idle - CPU 闲置的时间,其值一定为 /proc/uptime 中第二个项目乘 USER_HZ
#iowait - CPU 花在等候输入/输出的时间,Linux 2.5.41 开始才开始支援
#irq - CPU 花在处理硬件中断 (hardware interrupt) 的时间,Linux 2.6.0-test4 开始支持
#softirq- CPU 花在处理 softirq 软件中断的时间,Linux 2.6.0-test4 开始支持
#steal_time - 在虚拟环境下 CPU 花在处理其他作业系统的时间,Linux 2.6.11 开始支持(虚拟环境下出现,本例中无此项)
#guest - 在 Linux 内核控制下 CPU 为 guest 作业系统运行虚拟 CPU 的时间,Linux 2.6.24 开始支持(虚拟环境下出现,本例中无此项)
#CPU总时间:total=user+nice+system+idle+iowait+irq+softirq+steal_time+guest
#CPU繁忙时间:time=user+nice+system