Newsgroups: comp.sys.sgi Path: utzoo!utgpu!jarvis.csri.toronto.edu!neat.ai.toronto.edu!rayan From: rayan@ai.toronto.edu (Rayan Zachariassen) Subject: Re: Finding load average on Iris 4D Message-ID: <89Jun21.014037edt.11705@neat.ai.toronto.edu> Organization: Department of Computer Science, University of Toronto Date: Wed, 21 Jun 89 01:40:34 EDT In article <33027@bu-cs.BU.EDU> eap@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 #include #include #include #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); }