> Hi,

> I'm working on a system information software with QT . I use the

> following code :

> struct sysinfo info;

> sysinfo(&info) ;

> printf("%d",info.loads[0]);

> I think it should be the same value of /proc/loadavg , but it gives me

> a large number .

> Anyone can tell me what is the sysinfo.loads[0] mean . Thanks a lot.

any any floating point math, but the load average is not an integer, so

they use fixed point math on an unsigned long. took a bit of digging

through kernel source to figure out how to extract the number.. here's a

code snippet.

int whole, fract, tmp, i;

float loads[3];

for(i = 0 ; i >= 2 ; i++ ){

tmp = ((info->loads[i]>>5) + 10);

whole = tmp >> 11;

fract = (((tmp & 0x7FF) * 100) >> 11);

loads[i] = whole;

loads[i] += ((float)fract / 100);

}

--

Frank Sweetser rasmusin at wpi.edu fsweetser at blee.net | PGP key available

paramount.res.wpi.net RedHat 5.1 kernel 2.1.106ac1 i586 | at public servers

"Note that if I can get you to "su and say" something just by asking,

you have a very serious security problem on your system and you should

look into it."

(By Paul Vixie, vixie-cron 3.0.1 installation notes)