当前位置: 技术问答>linux和unix
在UNIX中如何通过程序获得主机的资源使用状况,CPU利用率等。
来源: 互联网 发布时间:2015-02-08
本文导语: 能否通过c程序,获得网络中某台unix主机的资源使用情况呢? | 试试 getloadavg 函数 SYNOPSIS #include int getloadavg(double loadavg[], int nelem); DESCRIPTION The getloadavg() ...
能否通过c程序,获得网络中某台unix主机的资源使用情况呢?
|
试试 getloadavg 函数
SYNOPSIS
#include
int
getloadavg(double loadavg[], int nelem);
DESCRIPTION
The getloadavg() function returns the number of processes in the system
run queue averaged over various periods of time. Up to nelem samples are
retrieved and assigned to successive elements of loadavg[]. The system
imposes a maximum of 3 samples, representing averages over the last 1, 5,
and 15 minutes, respectively.
DIAGNOSTICS
If the load average was unobtainable, -1 is returned; otherwise, the num-
ber of samples actually retrieved is returned.
SEE ALSO
uptime(1), kvm_getloadavg(3), sysctl(3)
HISTORY
The getloadavg() function appeared in 4.3BSD-Reno.
SYNOPSIS
#include
int
getloadavg(double loadavg[], int nelem);
DESCRIPTION
The getloadavg() function returns the number of processes in the system
run queue averaged over various periods of time. Up to nelem samples are
retrieved and assigned to successive elements of loadavg[]. The system
imposes a maximum of 3 samples, representing averages over the last 1, 5,
and 15 minutes, respectively.
DIAGNOSTICS
If the load average was unobtainable, -1 is returned; otherwise, the num-
ber of samples actually retrieved is returned.
SEE ALSO
uptime(1), kvm_getloadavg(3), sysctl(3)
HISTORY
The getloadavg() function appeared in 4.3BSD-Reno.
|
我以前也被要求写一个实现此功能的程序,后来因为别的原因没做。当时的思路是这样的:在各台被监控的服务器上都装个守护进程,接到客户端的请求后就执行top,并将执行结果返回给客户端。。。