Chinaunix首页 | 论坛 | 博客
  • 博客访问: 466366
  • 博文数量: 279
  • 博客积分: 4467
  • 博客等级: 上校
  • 技术积分: 2830
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-03 14:43
文章分类

全部博文(279)

文章存档

2013年(1)

2012年(39)

2011年(35)

2009年(29)

2008年(131)

2007年(44)

分类:

2008-06-27 11:54:48

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里可以通过这个文件监控服务器现在的状态。

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();
    }
}
?>

阅读(794) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~