Finding load average on Iris 4D
Rayan Zachariassen
rayan at ai.toronto.edu
Wed Jun 21 15:40:34 AEST 1989
In article <33027 at bu-cs.BU.EDU> eap at bu-it.bu.edu (Eric A. Pearce) writes:
# Is there a way to get a load average on the Iris? The BSD way
# would be to nlist the kernel and find "_avenrun", but I did not see
# anything similar on the Iris.
There are a couple of system calls that return all kinds of poorly
documented kernel stats. Unfortunately I don't see anything that
returns the load average directly. Here is the closest I've come
while fiddling around with this (I wish this was in the kernel...):
#include <stdio.h>
#include <sys/types.h>
#include <sys/sysmp.h>
#include <sys/sysinfo.h>
#define INTERVAL 5
#define NSAMPLES (15 /* minutes */ * 60 /* sec/min */ / INTERVAL)
int ringload[NSAMPLES];
int ringindex = 0;
main()
{
struct sysinfo sinfo;
int flag = 0, now, last1, last5, last15;
setvbuf(stdout, (char *)NULL, _IOLBF, 0);
for (;;) {
now = ringindex;
sysmp(MP_SAGET, MPSA_SINFO, &sinfo, sizeof sinfo);
ringload[ringindex++] = sinfo.runque;
if (!flag) {
while (flag < NSAMPLES)
ringload[flag++] = sinfo.runque;
if (!flag)
break; /* shut up the compiler */
}
ringindex %= NSAMPLES;
last1 = (NSAMPLES + now - 60 / INTERVAL)%NSAMPLES;
last5 = (NSAMPLES + now - 5*60 / INTERVAL)%NSAMPLES;
last15 = ringindex;
printf("%6.2f %6.2f %6.2f\n",
(ringload[now] - ringload[last1])/60.0,
(ringload[now] - ringload[last5])/(5*60.0),
(ringload[now] - ringload[last15])/(15*60.0));
sleep(INTERVAL);
}
/* NOTREACHED */
exit(0);
}
More information about the Comp.sys.sgi
mailing list