Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!samsung!usc!ucla-cs!ucla-seas!seashell.seas.ucla.edu!orachat From: orachat@seashell.seas.ucla.edu (Orachat Choedamphai) Newsgroups: comp.unix.aux Subject: How do I read the load average values from /dev/kmem? Message-ID: <480@lee.SEAS.UCLA.EDU> Date: 23 Mar 90 01:37:27 GMT Sender: news@SEAS.UCLA.EDU Reply-To: orachat@seashell.seas.ucla.edu (Orachat Choedamphai) Distribution: usa Organization: SEASnet, University of California, Los Angeles Lines: 45 Hello, I'm trying to get the value of the variable "avenrun" from /dev/kmem. The following is a program that I used. Could someone please tell me what I did wrong or maybe someone could send me a C program that will do this job? I would appreciate any help or suggestion. Thank you in advance. _Orachat #include #include #include #include #include #include #define UNIX "/unix" int kmemf; /* descriptor of /dev/kmem */ struct nlist nl[2]; extern int errno; main () { float avenrun[3]; (void) strcpy (nl[0].n_name, "avenrun"); (void) strcpy (nl[1].n_name, "0"); nlist(UNIX, nl); if (nl[0].n_value == 0) { fprintf (stderr, "/vmunix: No namelist\n"); exit(1); } printf ("address = %d\n", nl[0].n_value); if ((kmemf = open("/dev/kmem", O_RDONLY)) < 0) { perror ("/dev/kmem"); exit (1); } if (lseek (kmemf, (off_t)nl[0].n_value, 0) < 0) printf ("lseek failed\n");; (void) read (kmemf, (char *)avenrun, sizeof(avenrun)); printf ("load = %e,%e,%e\n", avenrun[0], avenrun[1], avenrun[2]); }