From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,343a718dc1dca343 X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1993-04-03 13:42:00 PST Path: gmd.de!ira.uka.de!yale.edu!think.com!spool.mu.edu!uwm.edu!zaphod.mps.ohio-state.edu!rpi!batcomputer!munnari.oz.au!metro!basser.cs.su.oz.au!news.adelaide.edu.au!iagu.itd.adelaide.edu.au!andrewr From: andrewr@iagu.itd.adelaide.edu.au (Andrew Rutherford) Newsgroups: comp.unix.osf.osf1 Subject: Re: How to read kernel variables under OSF1? Date: 3 Apr 1993 09:17:58 GMT Organization: Information Technology Division, Adelaide University, Australia Distribution: world Message-ID: <1pjko6$e1c@huon.itd.adelaide.edu.au> References: <1993Mar31.164952.21183@jarvis.csri.toronto.edu> Reply-To: andrewr@itd.adelaide.edu.au NNTP-Posting-Host: iagu.itd.adelaide.edu.au Apologies to those who see this twice, Idecided to redo it and cancelled the original about two minutes after I posted it. Sorry for any confusion. In article <1993Mar31.164952.21183@jarvis.csri.toronto.edu>, ahmedk@sys.toronto.edu (Khalid Ahmed) writes: +Is there an easy way to read kernel variables under +OSF1? On other systems I usually read /dev/kmem +directly to get structures I need. I'm mostly interested +in things like run queue lengths, paging rate, disk io, etc. + +There is a function called table(2) which is alluded to +in the vmstat(1) man page. However, on the machine I'm working +on the man page for table(2) is missing. If someone could kindly +mail it to me (and any other information about extracting load +information from the kernel) I'd appreciate it. I couldn't find any info on it either, so I dredged up an old Mach manual and dicovered the parameters go something like this: table(TableType, Index, Buffer, NumberOfConsectiveEntriesRead, ExpectedSizeOfRecord); Eg: /* Print out the Load Average so people can guess how long it will take */ void PrintLoadAvg() { struct tbl_loadavg LoadAvg; if (table(TBL_LOADAVG, 0, &LoadAvg, 1, sizeof(LoadAvg)) < 1) { fprintf(stderr, "Mach Factor & Load Average unavailible.\n"); } else { printf("Mach Factor: %3u.000\b\b\b%3u, %3u.000\b\b\b%3u, %3u.000\b\b\b%3u\n", LoadAvg.tl_mach_factor[0] / LoadAvg.tl_lscale, LoadAvg.tl_mach_factor[0] % LoadAvg.tl_lscale, LoadAvg.tl_mach_factor[1] / LoadAvg.tl_lscale, LoadAvg.tl_mach_factor[1] % LoadAvg.tl_lscale, LoadAvg.tl_mach_factor[2] / LoadAvg.tl_lscale, LoadAvg.tl_mach_factor[2] % LoadAvg.tl_lscale); if (LoadAvg.tl_lscale == 0) { printf("Load Average: %6.3f, %6.3f, %6.3f\n", LoadAvg.tl_avenrun.d[0], LoadAvg.tl_avenrun.d[1], LoadAvg.tl_avenrun.d[2]); } else { printf("Load Average: %3u.000\b\b\b%3u, %3u.000\b\b\b%3u, %3u.000\b\b\b%3u\n", LoadAvg.tl_avenrun.l[0] / LoadAvg.tl_lscale, LoadAvg.tl_avenrun.l[0] % LoadAvg.tl_lscale, LoadAvg.tl_avenrun.l[1] / LoadAvg.tl_lscale, LoadAvg.tl_avenrun.l[1] % LoadAvg.tl_lscale, LoadAvg.tl_avenrun.l[2] / LoadAvg.tl_lscale, LoadAvg.tl_avenrun.l[2] % LoadAvg.tl_lscale); } } } From a piece of code I wrote which produces all sorts of fun output: iagu# pinfo 6423 Mach Factor: 0.809, 0.713, 0.709 Load Average: 0.476, 0.409, 0.383 276 process slots, 68 non-empty PID: 6423, Active, Command: mwm User: andrewr Text: 87, Data: 15, Stack: 2 Block I/O: 95 input ops, 19 output ops Messages: 8045 sent, 9158 received Signals Recieved: 0, User Time: 10.753218, System Time: 18.448038 Context Switches: 8585 (8022,563) (voluntary/involuntary) I'm working on expanding it so you can just type something in and it works out what you're tyring to match up. It reads the proc table and the uarea of processes via the table call. I'm looking at getting it to read /dev/kmem to get out socket information (cf. my netproc program that runs on just about everything except OSF/1). I've stuck the preliminary version up for anonymous ftp on iagu.itd.adelaide.edu.au:/local/ftp/pub/src/pinfo.c. Any feedback appreciated, it makes me more likely to devote a bit more of my (very scarce) time to improving this - it hasn't been worked on since Feb 23 at the moment :-( Note: Although table is great and does look a lot cleaner, to get lots of real information (file desciptor table, open sockets, etc), one still has to get down and start pulling things out of /dev/kmem. Cya, Andrew. /* * Andrew Rutherford andrewr@itd.adelaide.edu.au * +61 8 228 5669 Real Programmers always confuse Christmas and * Room 1060, Adelaide Uni Halloween because OCT 31 == DEC 25 ! */