On Friday 7 February 97, at 15 h 10, the keyboard of Stephane Bortzmeyer
<bortzmeyer_at_pasteur.fr> 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 <stdio.h>
#include <sys/table.h>
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_at_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).
Received on Fri Feb 07 1997 - 17:01:54 NZDT