tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* SUMMARY: Program for computing load average?
@ 1997-02-07 15:35 Stephane Bortzmeyer
  0 siblings, 0 replies; only message in thread
From: Stephane Bortzmeyer @ 1997-02-07 15:35 UTC (permalink / raw)
  To: tru64-unix-managers

On Friday 7 February 97, at 15 h 10, the keyboard of Stephane Bortzmeyer 
<bortzmeyer@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@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).

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-02-07 15:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-02-07 15:35 SUMMARY: Program for computing load average? Stephane Bortzmeyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox