From 29bb85ca7a243ae83432128b4f442b57e782fff6 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 6 Sep 2004 16:14:16 +0000 Subject: [PATCH] implement loadavg --- src/os/osf1/osf1_sigar.c | 22 +++++++++++++++++++--- src/os/osf1/sigar_os.h | 1 + 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/os/osf1/osf1_sigar.c b/src/os/osf1/osf1_sigar.c index e6f9732f..3d47649b 100644 --- a/src/os/osf1/osf1_sigar.c +++ b/src/os/osf1/osf1_sigar.c @@ -89,9 +89,25 @@ int sigar_uptime_get(sigar_t *sigar, int sigar_loadavg_get(sigar_t *sigar, sigar_loadavg_t *loadavg) { - loadavg->loadavg[0] = -1; - loadavg->loadavg[1] = -1; - loadavg->loadavg[2] = -1; + int i; + struct tbl_loadavg avg; + + if (table(TBL_LOADAVG, 0, &avg, 1, sizeof(avg)) < 0) { + return errno; + } + + if (avg.tl_lscale) { + for (i=0; i<3; i++) { + loadavg->loadavg[i] = + ((double)avg.tl_avenrun.l[i] / + (double)avg.tl_lscale); + } + } + else { + for (i=0; i<3; i++) { + loadavg->loadavg[i] = avg.tl_avenrun.d[i]; + } + } return SIGAR_OK; } diff --git a/src/os/osf1/sigar_os.h b/src/os/osf1/sigar_os.h index 378270fd..147a4ede 100644 --- a/src/os/osf1/sigar_os.h +++ b/src/os/osf1/sigar_os.h @@ -7,6 +7,7 @@ #undef usr #undef sys +#include #include #include