1.psutil的安装

 [root@YQY-TIAN- ~]# wget https://pypi.python.org/packages/source/p/psutil/psutil-2.0.0.tar.gz
[root@YQY-TIAN- ~]# tar -xzvf psutil-2.0..tar.gz
[root@YQY-TIAN- ~]# cd psutil-2.0.
[root@YQY-TIAN- psutil-2.0.]# python setup.py install
sp-buffer-size= -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2. -c psutil/_psutil_linux.c -o build/temp.linux-x86_64-2.6/psutil/_psutil_linux.o
unable to execute gcc: No such file or directory
error: command 'gcc' failed with exit status

发现安装psutil的安装过程中发生了缺少gcc的错误,解决办法如下:

 yum install gcc python-devel

然后执行下面语句

 [root@YQY-TIAN- psutil-2.0.]# python setup.py install

相比较而言,使用psutil库实现则更加简单明了。

 [root@YQY-TIAN- psutil-2.0.]# python
Python 2.6. (r266:, Jul , ::)
[GCC 4.4. (Red Hat 4.4.-)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
>>> mem = psutil.virtual_memory()
>>> mem.total,mem.used
(1960546304L, 382873600L)
>>>
05-11 10:50