From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96078608810161.tru64-unix-managers.marc@archive.invalid> From: Stephane Bortzmeyer Date: Fri, 07 Feb 1997 15:35:24 +0000 To: tru64-unix-managers Subject: SUMMARY: Program for computing load average? X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96078608810161 On Friday 7 February 97, at 15 h 10, the keyboard of Stephane Bortzmeyer wrote: > Does anyone has the source code (I prefer in C) to compute the load > average (as displayed by uptime or xload) on Digital Unix (3 and 4)? The > code I had on Ultrix doesn't work anymore (the macro FIX_TO_DBL > disappeared) and the thing is severely underdocumented... The program is here. I forgot about table(2). #include #include main() { struct tbl_loadavg t; table(TBL_LOADAVG, 0, &t, 1, sizeof(struct tbl_loadavg)); printf("%g %g %g\n", (double) t.tl_avenrun.l[0]/t.tl_lscale, (double) t.tl_avenrun.l[1]/t.tl_lscale, (double) t.tl_avenrun.l[2]/t.tl_lscale); }; Many thanks to pas@hopper.unh.edu (Paul A Sand) who was really fast :-) Christophe Wolfhugel told me about the sendmail sources: there is code for every Unix to compute (in a different way) load average but sendmail represents load as an integer, while I needed a floating-point (and I'm not good enough for bit-level manipulations).