博客首页 注册 建议与交流 排行榜 加入友情链接
推荐 投诉 搜索: 帮助 

Linux

月光如水
viviecho.cublog.cn
关于作者  
姓名:  *****
性别:  女
年龄:  24
位置:  SH
职业:  *****


我的分类  




/proc/loadavg 各项数据的含义

5.2.16. /proc/loadavg

This file provides a look at the load average in regard to both the CPU and IO over time, as well as additional data used by uptime and other commands. A sample /proc/loadavg file looks similar to the following:

         0.20 0.18 0.12 1/80 11206 

The first three columns measure CPU and IO utilization of the last one, five, and 10 minute periods. The fourth column shows the number of currently running processes and the total number of processes. The last column displays the last process ID used.


wuyu@xa192:~$ cat /proc/loadavg
1.41 1.61 1.79 6/149 2331

这里的平均负载也就是可运行的进程的平均数
前三个值分别对应系统在5分钟、10分钟、15分钟内的平均负载
第四个值的分子是正在运行的进程数,分母是进程总数,最后一个是最近运行的进程ID号
 
php里可以通过这个文件监控服务器现在的状态。

<?php
if($fp = @fopen('/proc/loadavg', 'r')) {
    list($loadaverage) = explode(' ', fread($fp, 6));
    fclose($fp);
    if($loadaverage > 一个数) {
        header("HTTP/1.0 503 Service Unavailable");
        echo 'server die 囧';
        exit();
    }
}
?>

 发表于: 2008-06-27,修改于: 2008-06-27 12:25
 已浏览46次,有评论0条
推荐 投诉

  网友评论

  发表评论



Copyright © 2001-2006 ChinaUnix.net All Rights Reserved

感谢所有关心和支持过ChinaUnix的朋友们
页面生成时间:0.01769

京ICP证041476号