From a0314e1254187215d961fef7e85181e237838495 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 6 Sep 2004 16:20:19 +0000 Subject: [PATCH] implement uptime --- src/os/osf1/osf1_sigar.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/os/osf1/osf1_sigar.c b/src/os/osf1/osf1_sigar.c index 3d47649b..1f39122a 100644 --- a/src/os/osf1/osf1_sigar.c +++ b/src/os/osf1/osf1_sigar.c @@ -8,6 +8,7 @@ int sigar_os_open(sigar_t **sigar) *sigar = malloc(sizeof(**sigar)); (*sigar)->pagesize = getpagesize(); + (*sigar)->boot_time = 0; return SIGAR_OK; } @@ -81,7 +82,17 @@ int sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist) int sigar_uptime_get(sigar_t *sigar, sigar_uptime_t *uptime) { - uptime->uptime = -1; + if (sigar->boot_time == 0) { + struct tbl_sysinfo sysinfo; + + if (table(TBL_SYSINFO, 0, &sysinfo, 1, sizeof(sysinfo)) != 1) { + return errno; + } + + sigar->boot_time = sysinfo.si_boottime; + } + + uptime->uptime = time(NULL) - sigar->boot_time; return SIGAR_OK; }