编程获取linux的cpu占用率和mem和硬盘使用情况
linux下提供top、ps命令查看当前cpu、mem使用情况,简要介绍如下:
一、使用ps查看进程的资源占用
ps -aux查看进程信息时,第三列就是CPU占用。
[root@localhost utx86]# ps -aux | grep my_process
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
root 14415 3.4 0.9 37436 20328 pts/12 SL+ 14:18 0:05 ./my_process
root 14464 0.0 0.0 3852 572 pts/3 S+ 14:20 0:00 grep my_process
每一列含义如下
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
即my_process进程当前占用cpu 3.4%, 内存0.9%
二、top动态查看系统负荷
top -n 1显示后退出
[root@localhost utx86]# top -n 1
top - 14:23:20 up 5:14, 14 users, load average: 0.00, 0.04, 0.01
Tasks: 183 total, 1 running, 181 sleeping, 1 stopped, 0 zombie
Cpu(s): 1.8%us, 1.4%sy, 0.0%ni, 95.8%id, 0.7%wa, 0.1%hi, 0.2%si, 0.0%st
Mem: 2066240k total, 1507316k used, 558924k free, 190472k buffers
Swap: 2031608k total, 88k used, 2031520k free, 1087184k cached
1、获取cpu占用情况
[root@localhost utx86]# top -n 1 |grep Cpu
Cpu(s): 1.9%us, 1.3%sy, 0.0%ni, 95.9%id, 0.6%wa, 0.1%hi, 0.2%si, 0.0%st
解释:1.9%us是用户占用cpu情况
1.3%sy,是系统占用cpu情况
得到具体列的值:
[root@localhost utx86]# top -n 1 |grep Cpu | cut -d "," -f 1 | cut -d ":" -f 2
1.9%us
[root@localhost utx86]# top -n 1 |grep Cpu | cut -d "," -f 2
1.3%sy
2、获得内存占用情况
[root@localhost utx86]# top -n 1 |grep Mem
Mem: 2066240k total, 1515784k used, 550456k free, 195336k
相关文档:
1. HCI层协议概述:
HCI提供一套统一的方法来访问Bluetooth底层。如图所示:
从图上可以看出,Host Controller Interface(HCI) 就是用来沟通Host和Module。Host通常就是PC, Module则是以各种物理连接形式(USB,serial,pc-card等)连接到PC上的bluetooth Dongle。
在Host这一端:application,SDP,L2cap等协议 ......
转贴自:http://alexanderlaw.blog.hexun.com/8968782_d.html
三、ipt_table表的注册
init()函数初始化时调用了ipt_register_table函数进行表的注册
3.1 ip_tables.c 表的注册 ipt_register_table
int ipt_register_table(struct ipt_table *table)
{
......
关于此文
本文档用于升级
ExtMail
,
ExtMan
版本,升级自
ExtMail 0.24(
含以下版本)到
1.0.5
稳定版
,
本文档只能适用于数据库是
mysql
的版本
,
假设安装邮局的域名
为
extmail
.org
,读者请根据自身实际情况予以修改。
升级步骤
1.
停止服务:
postifx,http,mysql,pop3
service httpd stop
......
Linux环境进程间通信(三)
消息队列
文档选项
<tr
valign="top"><td width="8"><img alt="" height="1" width="8"
src="//www.ibm.com/i/c.gif"/></td><td width="16"><img alt="" width=" ......