Path: utzoo!mnetor!tmsoft!torsqnt!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!uakari.primate.wisc.edu!bin From: bin@primate.wisc.edu (Brain in Neutral) Newsgroups: comp.sys.dec Subject: Re: average load statistics on DS300? Message-ID: <1819@uakari.primate.wisc.edu> Date: 3 Mar 90 17:19:47 GMT References: <797@shodha.dec.com> Sender: bin@primate.wisc.edu Reply-To: bin@primate.wisc.edu Lines: 81 Something I have used to get load average out of a MIPS M/120. Might be useful on a DECstation as well... strip out the irrelevant junk... /* RISC/os 4.0 version xloadback - back end for xload for machines with no X server. Just sends load average to stdout every now and then. Should attach over network to xloadfront process on machine with X server that reads it and displays it a la regular xload. Sends the load*100 as a 32-bit quantity in network byte order. 12 July 1989 Paul DuBois dubois@rhesus.primate.wisc.edu */ # include # include # include # include # define UNIX "/unix" # define KMEM_FILE "/dev/kmem" # define KMEM_ERROR "cannot open /dev/kmem" # define LOADAV 0 struct nlist namelist[] = { /* namelist for vmunix grubbing */ {"avenrun"}, {0} }; char hostname[256]; main () { register int kmem; /* kmem pointer */ long lavgSeek; /* offset to load average in kmem */ ufix tmpLoad; /* system load info */ long iLoad; if (gethostname (hostname, sizeof (hostname))) smerror ("don't know hostname"); /* Get name list. Then open kmem so we can seek for information */ nlist(UNIX, namelist); if (namelist[LOADAV].n_type == 0) smerror("cannot get name list"); lavgSeek = namelist[LOADAV].n_value; kmem = open(KMEM_FILE, O_RDONLY); if (kmem < 0) smerror(KMEM_ERROR); write (1, hostname, strlen (hostname) + 1); for (;;) { sleep (5); lseek(kmem, lavgSeek, 0); read(kmem, (char *) &tmpLoad, sizeof (tmpLoad)); iLoad = (long) (FIX_TO_DBL (tmpLoad) * 100.0); iLoad = htonl (iLoad); printf ("%d %d %g\n", iLoad, ntohl (iLoad), FIX_TO_DBL (tmpLoad)); /*write(1, (char *) &iLoad, sizeof (iLoad));*/ fflush (stdout); } } /* Diagnostic printer - Print message and exit */ smerror(message) char *message; { fprintf (stderr, "%s\n", message); exit(1); }