Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!orion.oac.uci.edu!draco.acs.uci.edu!iglesias From: iglesias@draco.acs.uci.edu (Mike Iglesias) Newsgroups: comp.unix.ultrix Subject: rpc rstatd for RISC Ultrix Message-ID: <273AFF90.2992@orion.oac.uci.edu> Date: 9 Nov 90 19:12:16 GMT Reply-To: iglesias@draco.acs.uci.edu (Mike Iglesias) Organization: University of California, Irvine Lines: 246 Nntp-Posting-Host: draco.acs.uci.edu Recently, I posted a question about whether anyone had a rpc.rstatd (as Sun calls it) for Ultrix on DECstations. I didn't get any answers, so I started looking into it myself. I found a copy of the Sun RPC sources on uunet.uu.net in comp.sources.unix/volume13/rpc3.9 and started working from there. I found that the sources included the source for the rpc rstatd daemon, so I modified the code using the sources for 'top' that are on gatekeeper.dec.com as a guide. You need to do the following: Build rpcgen from the sources and put it in your path so it can be found in the next step. cd to the rpcsvc directory and type 'make'. Kill the make when it starts compiling the sources (let the rpcgen stuff finish!). Apply the patch at the end of this message to rstat_proc.c. Modify the Makefile CFLAGS to include -DULTRIXV4 (for Ultrix v4.x) or -DULTRIXV3 (for Ultrix v3.x). Type 'make' again and it should compile and link rstat_svc. I've run the daemon under Ultrix v3.1, v4.0, and v4.1, and it appears to work correctly. Please note that I've only run it on DECstation 3100s and 5000; we don't have any vaxen running Ultrix around here so I couldn't test it for those systems. I wasn't able to get the rpc library to compile correctly (dies in xdr_float.c), but the routines supplied by DEC (in libc.a) seem to work. I haven't been able to get any client programs (for example, xmeter) to work on the DECstations; they all complain that they can't decode the results from either my daemons or daemons running on Sun systems. I have no idea what the problem is, nor have I had time to look into it further. Clients running on Suns are able to get the data correctly from my daemons. Since I did the changes, I have found out that titan.rice.edu has a newer release of the RPC sources. I haven't had a chance to look at those and put my changes into them. If you try to put my changes into the newer sources, you're on your own! As always, use these changes at your own risk. I can't mail out the RPC sources; you'll have to get them from uunet yourself. Mike Iglesias University of California, Irvine Internet: iglesias@draco.acs.uci.edu BITNET: iglesias@uci uucp: ...!ucbvax!ucivax!iglesias *** rstat_proc.c.orig Fri Oct 19 10:53:59 1990 --- rstat_proc.c Fri Nov 9 10:25:54 1990 *************** *** 50,60 **** --- 50,73 ---- #include #include #include + #ifdef ultrix + # include + # ifdef ULTRIXV4 + # include + # include + # include + # endif + #endif #include "rstat.h" struct nlist nl[] = { + #ifdef ULTRIXV4 + #define X_CPUDATA 0 + { "_cpudata" }, + #else #define X_CPTIME 0 { "_cp_time" }, + #endif #define X_SUM 1 { "_sum" }, #define X_IFNET 2 *************** *** 67,72 **** --- 80,91 ---- { "_avenrun" }, #define X_HZ 6 { "_hz" }, + #ifdef ULTRIXV4 + #define X_LOWCPU 7 + { "_lowcpu" }, + #define X_HIGHCPU 8 + { "_highcpu" }, + #endif "", }; int kmem; *************** *** 73,78 **** --- 92,106 ---- int firstifnet, numintfs; /* chain of ethernet interfaces */ int stats_service(); + #ifdef ULTRIXV4 + struct cpudata *cpudata[MAXCPU]; + struct cpudata onecpu; + int ncpu; + int i; + int lowcpu = 0; + int highcpu = 0; + #endif + /* * Define EXIT_WHEN_IDLE if you are able to have this program invoked * automatically on demand (as from inetd). When defined, the service *************** *** 163,169 **** --- 191,201 ---- int off, i, hz; struct vmmeter sum; struct ifnet ifnet; + #if defined(ultrix) && defined(mips) + fix avrun[3]; + #else double avrun[3]; + #endif struct timeval tm, btm; #ifdef DEBUG *************** *** 186,191 **** --- 218,274 ---- fprintf(stderr, "rstat: can't read hz from kmem\n"); exit(1); } + #ifdef ULTRIXV4 + if (lseek(kmem, (long)nl[X_CPUDATA].n_value, 0) == -1) { + fprintf(stderr, "rstat: can't seek in kmem\n"); + exit(1); + } + if (read(kmem, (char *)cpudata, sizeof(cpudata)) != sizeof(cpudata)) { + fprintf(stderr, "rstat: can't read cpudata from kmem\n"); + exit(1); + } + if (lseek(kmem, (long)nl[X_LOWCPU].n_value, 0) == -1) { + fprintf(stderr, "rstat: can't seek in kmem\n"); + exit(1); + } + if (read(kmem, (char *)&lowcpu, sizeof(lowcpu)) != sizeof(lowcpu)) { + fprintf(stderr, "rstat: can't read lowcpu from kmem\n"); + exit(1); + } + + if (lseek(kmem, (long)nl[X_HIGHCPU].n_value, 0) == -1) { + fprintf(stderr, "rstat: can't seek in kmem\n"); + exit(1); + } + if (read(kmem, (char *)&highcpu, sizeof(highcpu)) != sizeof(highcpu)) { + fprintf(stderr, "rstat: can't read highcpu from kmem\n"); + exit(1); + } + + for (i = 0; i < CPUSTATES; ++i) + stats_all.s1.cp_time[i] = 0; + + stats_all.s1.v_intr = 0; + stats_all.s2.v_swtch = 0; + + for (ncpu = lowcpu; ncpu <= highcpu; ++ncpu) { + if (cpudata[ncpu]) { + if (lseek(kmem, cpudata[ncpu], 0) == -1) { + fprintf(stderr, "rstat: can't seek in kmem(cpudata)\n"); + exit(1); + } + if (read(kmem, (char *)&onecpu, sizeof (onecpu)) != sizeof(onecpu)) { + fprintf(stderr, "rstat: can't read *cpudata from kmem\n"); + exit(1); + } + stats_all.s1.v_intr += onecpu.cpu_intr; + stats_all.s2.v_swtch += onecpu.cpu_switch; + + for (i = 0; i < CPUSTATES; i++) + stats_all.s1.cp_time[i] += onecpu.cpu_cptime[i]; + } + } + #else if (lseek(kmem, (long)nl[X_CPTIME].n_value, 0) == -1) { fprintf(stderr, "rstat: can't seek in kmem\n"); exit(1); *************** *** 195,200 **** --- 278,284 ---- fprintf(stderr, "rstat: can't read cp_time from kmem\n"); exit(1); } + #endif if (lseek(kmem, (long)nl[X_AVENRUN].n_value, 0) ==-1) { fprintf(stderr, "rstat: can't seek in kmem\n"); exit(1); *************** *** 208,213 **** --- 292,306 ---- stats_all.s2.avenrun[1] = avrun[1] * FSCALE; stats_all.s2.avenrun[2] = avrun[2] * FSCALE; #endif + #if defined(ultrix) && defined(mips) + if (read(kmem, (char *)avrun, sizeof (avrun)) != sizeof (avrun)) { + fprintf(stderr, "rstat: can't read avenrun from kmem\n"); + exit(1); + } + stats_all.s2.avenrun[0] = avrun[0]; + stats_all.s2.avenrun[1] = avrun[1]; + stats_all.s2.avenrun[2] = avrun[2]; + #endif if (lseek(kmem, (long)nl[X_BOOTTIME].n_value, 0) == -1) { fprintf(stderr, "rstat: can't seek in kmem\n"); exit(1); *************** *** 238,248 **** stats_all.s1.v_pgpgout = sum.v_pgpgout; stats_all.s1.v_pswpin = sum.v_pswpin; stats_all.s1.v_pswpout = sum.v_pswpout; stats_all.s1.v_intr = sum.v_intr; gettimeofday(&tm, (struct timezone *) 0); stats_all.s1.v_intr -= hz*(tm.tv_sec - btm.tv_sec) + hz*(tm.tv_usec - btm.tv_usec)/1000000; ! stats_all.s2.v_swtch = sum.v_swtch; if (lseek(kmem, (long)nl[X_DKXFER].n_value, 0) == -1) { fprintf(stderr, "rstat: can't seek in kmem\n"); --- 331,345 ---- stats_all.s1.v_pgpgout = sum.v_pgpgout; stats_all.s1.v_pswpin = sum.v_pswpin; stats_all.s1.v_pswpout = sum.v_pswpout; + #ifndef ULTRIXV4 stats_all.s1.v_intr = sum.v_intr; + stats_all.s2.v_swtch = sum.v_swtch; + #endif + #ifndef ULTRIXV3 gettimeofday(&tm, (struct timezone *) 0); stats_all.s1.v_intr -= hz*(tm.tv_sec - btm.tv_sec) + hz*(tm.tv_usec - btm.tv_usec)/1000000; ! #endif if (lseek(kmem, (long)nl[X_DKXFER].n_value, 0) == -1) { fprintf(stderr, "rstat: can't seek in kmem\n");