From: Eyal Rif <EYALRI () amdocs ! com>
To: tru64-unix-managers
Subject: SUMMERY: how to get kernel variables using c
Date: Wed, 01 Dec 1999 07:50:17 +0000 [thread overview]
Message-ID: <96079091516081.tru64-unix-managers.marc@archive.invalid> (raw)
First of all thanks to everyone who answered
this is truely a very good mailing list,
I was ammazed by the number of answers and
the response time that was very fast.
all the answers i got detailed the following system calls/ c functions:
Table - a very usefull system call which can get real time details on the
system
getsysinfo, sysconf, sysinfo - get fixed variables on the system
detailed information on this functions can found in man "function"
here is a sample program that Paul A Sand sent me:
#include <sys/table.h>
#include <stdio.h>
#include <time.h>
main()
{
struct tbl_sysinfo stab;
struct tbl_loadavg ltab;
table(TBL_SYSINFO, 0, &stab, 1, sizeof(struct tbl_sysinfo));
printf("System was booted at %ld\n", stab.si_boottime);
printf("System up %0.2f days\n",
(time(NULL) - stab.si_boottime)/86400.0);
table(TBL_LOADAVG, 0, <ab, 1, sizeof(struct tbl_loadavg));
if (ltab.tl_lscale == 0) {
printf("Load averages: %0.2f, %0.2f, %0.2f\n",
ltab.tl_avenrun.d[0],
ltab.tl_avenrun.d[1],
ltab.tl_avenrun.d[2]);
}
else {
printf("Load averages: %0.2f, %0.2f, %0.2f\n",
((double) ltab.tl_avenrun.l[0])/ltab.tl_lscale,
((double) ltab.tl_avenrun.l[1])/ltab.tl_lscale,
((double) ltab.tl_avenrun.l[2])/ltab.tl_lscale);
}
}
reply other threads:[~1999-12-01 7:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox