thomas%spline.uucp@utah-gr.UUCP (Spencer W. Thomas) (08/13/87)
I ported xrload to our HP bobcat system running HPUX (a SYSV variant with Berkeley networking). In the process I had to make a few system dependent changes, and I fixed a few bugs. Here is a diff listing from the original posting (the single file version). =Spencer ({ihnp4,decvax}!utah-cs!thomas, thomas@cs.utah.edu) *** .~xrload.c Thu Aug 13 11:51:26 1987 --- xrload.c Thu Aug 13 11:51:26 1987 *************** *** 11,14 **** --- 11,17 ---- #include <setjmp.h> + #include <sys/types.h> /* This must come first */ #include <sys/file.h> + #ifndef hpux #include <sys/wait.h> + #endif #include <sys/time.h> *************** *** 15,17 **** #include <sys/resource.h> ! #include <sys/types.h> #include <netdb.h> --- 18,20 ---- #include <sys/resource.h> ! #include <sys/socket.h> /* Need to explicitly include this for HPUX */ #include <netdb.h> *************** *** 27,28 **** --- 30,35 ---- + #ifndef RUPTIME + #define RUPTIME "/usr/ucb/ruptime" + #endif + #include "back.bitmap" *************** *** 253,255 **** hh = back_height + dd + theFont->height; ! rr = (ww-1)/2; } --- 260,262 ---- hh = back_height + dd + theFont->height; ! rr = (back_width - 1) / 2; /* radius related only to icon size */ } *************** *** 358,361 **** dup2 (iofd[1], 1); /* stdout to pipe */ ! execl ("/usr/ucb/ruptime", "ruptime", 0); ! perror ("can't exec /usr/ucb/ruptime"); exit (1); --- 365,369 ---- dup2 (iofd[1], 1); /* stdout to pipe */ ! execl (RUPTIME, "ruptime", 0); ! fprintf(stderr, "xrload: Can't exec "); ! perror (RUPTIME); exit (1); *************** *** 364,366 **** --- 372,378 ---- static char hstatus[8], junk[8]; + #ifndef hpux union wait status; + #else + long status; + #endif int nh = 0, nf; *************** *** 597 **** --- 609,620 ---- } + + #ifdef hpux + #include <fcntl.h> + dup2( fd1, fd2 ) /* Simulate dup2 with fcntl */ + int fd1, fd2; + { + close(fd2); + return fcntl( fd1, F_DUPFD, fd2 ); + } + + #endif =Spencer ({ihnp4,decvax}!utah-cs!thomas, thomas@cs.utah.edu)
psi@unl::spa (Salvador Pinto Abreu) (08/13/87)
#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 6)." # Contents: MANIFEST README back.bitmap down.bitmap dump-stats.c # xrload.c # Wrapped by root@mak on Thu Aug 13 11:36:17 1987 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f MANIFEST -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"MANIFEST\" else echo shar: Extracting \"MANIFEST\" \(624 characters\) sed "s/^X//" >MANIFEST <<'END_OF_MANIFEST' X File Name Archive # Description X----------------------------------------------------------- X MANIFEST 1 This shipping list X Makefile 2 X README 1 X back.bitmap 1 X down.bitmap 1 X draw-hand.c 1 X dump-stats.c 1 X event-loop.c 3 X get-stats.c 4 X globals.c 3 X hostname.c 3 X init.c 6 X recalc-windows.c 2 X show-stats.c 2 X update-sys.c 2 X xrload.1x 5 X xrload.c 1 END_OF_MANIFEST if test 624 -ne `wc -c <MANIFEST`; then echo shar: \"MANIFEST\" unpacked with wrong size! fi # end of overwriting check fi if test -f README -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"README\" else echo shar: Extracting \"README\" \(664 characters\) sed "s/^X//" >README <<'END_OF_README' XThis is xrload(1), a tool that serves a function similar to that of Xxload(1) but monitors (part of) a TCP/IP network using a single Xwindow. This avoids having a bunch of xload windows, each with a local Xand a remote associated process, and all the resource waste this would Ximply. X XTo try it, just type: X % make X % xrload -X X XNote: I had to split this up because I'm having problems with the mailer. X--- XUUCP: ...{mcvax,inria}!inesc!hara.unl.psi!spa PSI/VMS: PSI%+26805010310::SPA XARPA: lisvax.dec!unlai!spa@decwrl.dec.com Phone: + 351 1 295 31 56 X XSnail: Salvador Pinto Abreu X Dept. of Computer Science, Universidade Nova de Lisboa X 2825 Monte Caparica, Portugal END_OF_README if test 664 -ne `wc -c <README`; then echo shar: \"README\" unpacked with wrong size! fi # end of overwriting check fi if test -f back.bitmap -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"back.bitmap\" else echo shar: Extracting \"back.bitmap\" \(679 characters\) sed "s/^X//" >back.bitmap <<'END_OF_back.bitmap' X#define back_width 32 X#define back_height 32 X#define back_x_hot 16 X#define back_y_hot 15 Xstatic short back_bits[] = { X 0xffff, 0xffff, 0x1fff, 0xfff0, X 0xe3ff, 0xff8f, 0x1cff, 0xfe70, X 0x027f, 0xfc80, 0x01bf, 0xfb00, X 0x005f, 0xf400, 0x004f, 0xe400, X 0x002f, 0xe800, 0x0017, 0xd000, X 0x0017, 0xd000, 0x0017, 0xd000, X 0x000b, 0xa000, 0x000b, 0xa000, X 0x800b, 0xa003, 0x800b, 0xa003, X 0x800b, 0xa003, 0x000b, 0xa000, X 0x000b, 0xa000, 0x0017, 0xd000, X 0xc017, 0xd007, 0x2017, 0xd008, X 0xd02f, 0xe817, 0xe84f, 0xe42f, X 0xf45f, 0xf45f, 0xfbbf, 0xfbbf, X 0xfc7f, 0xfc7f, 0xffff, 0xffff, X 0xffff, 0xffff, 0xffff, 0xffff, X 0xffff, 0xffff, 0xffff, 0xffff}; END_OF_back.bitmap if test 679 -ne `wc -c <back.bitmap`; then echo shar: \"back.bitmap\" unpacked with wrong size! fi # end of overwriting check fi if test -f down.bitmap -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"down.bitmap\" else echo shar: Extracting \"down.bitmap\" \(679 characters\) sed "s/^X//" >down.bitmap <<'END_OF_down.bitmap' X#define down_width 32 X#define down_height 32 X#define down_x_hot 16 X#define down_y_hot 15 Xstatic short down_bits[] = { X 0xffff, 0xffff, 0x1fff, 0xfff0, X 0xe3ff, 0xff8f, 0x1cff, 0xfe70, X 0x827f, 0xfc83, 0x81bf, 0xfb03, X 0x805f, 0xf403, 0x804f, 0xe403, X 0xf82f, 0xe83f, 0xf817, 0xd03f, X 0x8017, 0xd003, 0x8017, 0xd003, X 0x870b, 0xe0e2, 0x890b, 0xa123, X 0x890b, 0xa122, 0x870b, 0xa0e2, X 0x890b, 0xa022, 0xa90b, 0xa02a, X 0x890b, 0xa022, 0xc017, 0xd007, X 0xc017, 0xd007, 0x2017, 0xd008, X 0xd02f, 0xe817, 0xe84f, 0xe42f, X 0xf45f, 0xf45f, 0xfbbf, 0xfbbf, X 0xfc7f, 0xfc7f, 0xffff, 0xffff, X 0xffff, 0xffff, 0xffff, 0xffff, X 0xffff, 0xffff, 0xffff, 0xffff}; END_OF_down.bitmap if test 679 -ne `wc -c <down.bitmap`; then echo shar: \"down.bitmap\" unpacked with wrong size! fi # end of overwriting check fi if test -f dump-stats.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"dump-stats.c\" else echo shar: Extracting \"dump-stats.c\" \(741 characters\) sed "s/^X//" >dump-stats.c <<'END_OF_dump-stats.c' X/**************************************************************************/ X/* */ X/* Dump system stats (debugging) */ X/* */ X/**************************************************************************/ X X#include "xrload.h" X Xvoid dump_stats (stats, nsys) X sys_stat *stats; X int nsys; X{ X register int i; X X for (i=0; stats[i].sys_name[0]; i++) { X if (stats[i].state == UP) { X printf ("%s %s %d %f %f %f\n", X stats[i].sys_name, stats[i].how_long, X stats[i].users, X stats[i].load_average[0], X stats[i].load_average[1], X stats[i].load_average[2]); X } X else { X printf ("%s %s\n", X stats[i].sys_name, stats[i].how_long); X } X } X putchar ('\n'); X} END_OF_dump-stats.c if test 741 -ne `wc -c <dump-stats.c`; then echo shar: \"dump-stats.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f xrload.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"xrload.c\" else echo shar: Extracting \"xrload.c\" \(721 characters\) sed "s/^X//" >xrload.c <<'END_OF_xrload.c' X/**************************************************************************/ X/* */ X/* Main Program */ X/* */ X/**************************************************************************/ X X#include "xrload.h" X Xmain (argc, argv) X int argc; X char *argv[]; X{ X extern void initialize (); X extern void doit (); X X initialize (argc, argv); X doit (); X} X Xusage () X{ X fprintf (stderr, X"usage: xrload [-cols <columns>] [-delay <sec>] [-same] [-rv] [-all] [-X]\n"); X fprintf (stderr, X" [-fn <font>] [-bw <border-width>] [-spacing <spacing>]\n"); X fprintf (stderr, X" [=<geometry>] [<host>:<display>]\n"); X exit (1); X} END_OF_xrload.c if test 721 -ne `wc -c <xrload.c`; then echo shar: \"xrload.c\" unpacked with wrong size! fi # end of overwriting check fi echo shar: End of archive 1 \(of 6\). cp /dev/null ark1isdone MISSING="" for I in 1 2 3 4 5 6 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 6 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 --- UUCP: ...{mcvax,inria}!inesc!hara.unl.psi!spa PSI/VMS: PSI%+26805010310::SPA ARPA: lisvax.dec!unlai!spa@decwrl.dec.com Phone: + 351 1 295 31 56 Snail: Salvador Pinto Abreu Dept. of Computer Science, Universidade Nova de Lisboa 2825 Monte Caparica, Portugal
psi@unl::spa (Salvador Pinto Abreu) (08/13/87)
#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 2 (of 6)." # Contents: Makefile draw-hand.c recalc-windows.c show-stats.c # update-sys.c # Wrapped by root@mak on Thu Aug 13 11:36:19 1987 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f Makefile -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"Makefile\" else echo shar: Extracting \"Makefile\" \(834 characters\) sed "s/^X//" >Makefile <<'END_OF_Makefile' XPROGRAM = xrload X XOBJECTS = draw-hand.o dump-stats.o event-loop.o get-stats.o hostname.o \ X init.o recalc-windows.o show-stats.o update-sys.o globals.o \ X xrload.o X XSHARFILES = \ X README Makefile \ X xrload.1x \ X back.bitmap down.bitmap \ X draw-hand.c dump-stats.c event-loop.c get-stats.c hostname.c \ X init.c recalc-windows.c show-stats.c update-sys.c globals.c \ X xrload.c X XMAN = /usr/man/man1 XBIN = /usr/local/bin X XCFLAGS = -O XSIZE = 6k X Xall: $(PROGRAM) X Xshar: MANIFEST X makekit -s$(SIZE) -nxrload.shar. -h2 -iMANIFEST X XMANIFEST: $(SHARFILES) X makekit -m -s$(SIZE) -x $(SHARFILES) X Xinstall: all X install xrload $(BIN) X Xman: xrload.1x X cp xrload.1x $(MAN)/xrload.1 X chmod a=r $(MAN)/xrload.1 X X$(PROGRAM): $(OBJECTS) X cc $(CFLAGS) -o xrload $(OBJECTS) -lX -lm X Xxrload.h: back.bitmap down.bitmap X X$(OBJECTS): xrload.h END_OF_Makefile if test 834 -ne `wc -c <Makefile`; then echo shar: \"Makefile\" unpacked with wrong size! fi # end of overwriting check fi if test -f draw-hand.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"draw-hand.c\" else echo shar: Extracting \"draw-hand.c\" \(788 characters\) sed "s/^X//" >draw-hand.c <<'END_OF_draw-hand.c' X/**************************************************************************/ X/* */ X/* Draw a dial hand */ X/* */ X/**************************************************************************/ X X#include "xrload.h" X Xdraw_hand (w, value, scale, l0, l1, thick) X Window w; X float value, scale, l0, l1; X int thick; X{ X float theta = M_PI_4 * (5.0 - 6.0*value/scale); X int x0 = (int) (rr*l0*cos(theta)); X int x1 = (int) (rr*l1*cos(theta)); X int y0 = (int) (rr*l0*sin(-theta)); X int y1 = (int) (rr*l1*sin(-theta)); X X x0 += (ww-back.width)/2+back.x_hot; X x1 += (ww-back.width)/2+back.x_hot; X y0 += back.y_hot; X y1 += back.y_hot; X X XLine (w, x0, y0, x1, y1, thick, thick, blackPixel, GXcopy, AllPlanes); X} END_OF_draw-hand.c if test 788 -ne `wc -c <draw-hand.c`; then echo shar: \"draw-hand.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f recalc-windows.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"recalc-windows.c\" else echo shar: Extracting \"recalc-windows.c\" \(901 characters\) sed "s/^X//" >recalc-windows.c <<'END_OF_recalc-windows.c' X/**************************************************************************/ X/* */ X/* Recompute subwindow locations */ X/* */ X/**************************************************************************/ X X#include "xrload.h" X Xvoid recalc_windows (stats, nsys) X sys_stat *stats; X int nsys; X{ X WindowInfo wi; X register int x, y, i; X X XQueryWindow (mainWindow, &wi); X if (wi.width != mainLoc.width || X wi.height != mainLoc.height || X nsys != nSystems) { /* recompute subwindow locations */ X mainLoc = wi; X nSystems = nsys; X x = dd; X y = dd; X for (i=0; i<nsys; i++) { X if (stats[i].w) X XMoveWindow (stats[i].w, x, y); X else { X stats[i].w = XCreateWindow (mainWindow, x, y, ww, hh, 0, X NULL, blackPixmap); X XMapWindow (stats[i].w); X } X x += ww+dd; X if (x >= wi.width) { X x = dd; X y += hh+dd; X } X } X } X} END_OF_recalc-windows.c if test 901 -ne `wc -c <recalc-windows.c`; then echo shar: \"recalc-windows.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f show-stats.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"show-stats.c\" else echo shar: Extracting \"show-stats.c\" \(1004 characters\) sed "s/^X//" >show-stats.c <<'END_OF_show-stats.c' X/**************************************************************************/ X/* */ X/* Display system statistics */ X/* */ X/**************************************************************************/ X X#include "xrload.h" X Xvoid show_stats (stats, nsys) X sys_stat *stats; X int nsys; X{ X float max_scale; X int i; X X if (dflag) dump_stats (stats, nsys); X X recalc_windows (stats, nsys); X X if (same_scale) { X max_scale = 1.0; X for (i=0; i<nsys; i++) { X if (stats[i].state == UP) { X max_scale = max (max_scale, stats[i].load_average[0]); X max_scale = max (max_scale, stats[i].load_average[1]); X /*max_scale = max (max_scale, stats[i].load_average[2]);*/ X } X } X max_scale = ceil (max_scale); X } X X for (i=0; i<nsys; i++) { X if (!same_scale) X max_scale = ceil (max (stats[i].load_average[0], X stats[i].load_average[1])); X if (max_scale < 1.0) max_scale = 1.0; X update_sys (&stats[i], max_scale); X } X XFlush (); X} END_OF_show-stats.c if test 1004 -ne `wc -c <show-stats.c`; then echo shar: \"show-stats.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f update-sys.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"update-sys.c\" else echo shar: Extracting \"update-sys.c\" \(1133 characters\) sed "s/^X//" >update-sys.c <<'END_OF_update-sys.c' X/**************************************************************************/ X/* */ X/* Update a system's dial window */ X/* */ X/**************************************************************************/ X X#include "xrload.h" X Xvoid update_sys (stat, scale) X sys_stat *stat; X float scale; X{ X register int tw; X float tick; X X if (stat->state == DOWN) { X XBitmapBitsPut (stat->w, (ww-down.width)/2, 0, down.width, down.height, X down.bits, X blackPixel, whitePixel, NULL, GXcopy, AllPlanes); X } X else { X XBitmapBitsPut (stat->w, (ww-back.width)/2, 0, back.width, back.height, X back.bits, X blackPixel, whitePixel, NULL, GXcopy, AllPlanes); X X for (tick=1.0; tick<scale; tick += 1.0) X draw_hand (stat->w, tick, scale, 0.8, 1.1, 2); X X draw_hand (stat->w, stat->load_average[0], scale, 0.0, 0.85, 1); X draw_hand (stat->w, stat->load_average[1], scale, 0.0, 0.50, 1); X } X X tw = XQueryWidth (stat->sys_name, theFont->id); X XText (stat->w, (ww-tw)/2, hh-2-theFont->height, X stat->sys_name, strlen(stat->sys_name), X theFont->id, whitePixel, blackPixel); X} END_OF_update-sys.c if test 1133 -ne `wc -c <update-sys.c`; then echo shar: \"update-sys.c\" unpacked with wrong size! fi # end of overwriting check fi echo shar: End of archive 2 \(of 6\). cp /dev/null ark2isdone MISSING="" for I in 1 2 3 4 5 6 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 6 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 --- UUCP: ...{mcvax,inria}!inesc!hara.unl.psi!spa PSI/VMS: PSI%+26805010310::SPA ARPA: lisvax.dec!unlai!spa@decwrl.dec.com Phone: + 351 1 295 31 56 Snail: Salvador Pinto Abreu Dept. of Computer Science, Universidade Nova de Lisboa 2825 Monte Caparica, Portugal
psi@unl::spa (Salvador Pinto Abreu) (08/13/87)
#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 3 (of 6)." # Contents: event-loop.c globals.c hostname.c # Wrapped by root@mak on Thu Aug 13 11:36:21 1987 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f event-loop.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"event-loop.c\" else echo shar: Extracting \"event-loop.c\" \(1223 characters\) sed "s/^X//" >event-loop.c <<'END_OF_event-loop.c' X/**************************************************************************/ X/* */ X/* Main Event Loop */ X/* */ X/**************************************************************************/ X X#include "xrload.h" X Xvoid doit () X{ X for (;;) { X if (mapped) { X register int nsys = get_stats (stats); X show_stats (stats, nsys); X } X handle_X_events (); X } X} X Xhandle_X_events () X{ X struct timeval timeout; X int maxfds, fdmask, readfds, nfound; X XEvent event; X X if (dflag) printf ("in handle_X_event()\n"); X timeout.tv_sec = delay; X timeout.tv_usec = 0; X maxfds = dpyno() + 1; X fdmask = 1 << dpyno(); X X do { X if (XPending()) { X XNextEvent (&event); X switch (event.type) { X X case ExposeWindow: X mapped = TRUE; X show_stats (stats, nSystems); X break; X X case UnmapWindow: X mapped = FALSE; X break; X X default: X fprintf (stderr, "xrload: unexpected X event (%d)\n", X event.type); X exit(1); X } X } X X readfds = fdmask; X if ((nfound = select (maxfds, &readfds, NULL, NULL, &timeout)) < 0) { X perror ("select"); X exit (1); X } X if (dflag) printf ("select(...) -> %d\n", nfound); X } while (nfound); X} END_OF_event-loop.c if test 1223 -ne `wc -c <event-loop.c`; then echo shar: \"event-loop.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f globals.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"globals.c\" else echo shar: Extracting \"globals.c\" \(1386 characters\) sed "s/^X//" >globals.c <<'END_OF_globals.c' X/**************************************************************************/ X/* */ X/* Global Variables */ X/* */ X/**************************************************************************/ X X#include "xrload.h" X X#include "back.bitmap" X#include "down.bitmap" X X#define gray1_width 16 /* from gray1.bitmap */ X#define gray1_height 16 Xstatic short gray1_bits[] = { X 0x5555, 0xaaaa, 0x5555, 0xaaaa, X 0x5555, 0xaaaa, 0x5555, 0xaaaa, X 0x5555, 0xaaaa, 0x5555, 0xaaaa, X 0x5555, 0xaaaa, 0x5555, 0xaaaa}; X XPixmap GrayPixmap; XPixmap whitePixmap, blackPixmap; Xint whitePixel, blackPixel; X XBitmap_data gray1 = { gray1_width, gray1_height, 0, 0, gray1_bits }; XBitmap_data back = { back_width, back_height, X back_x_hot, back_y_hot, back_bits }; XBitmap_data down = { down_width, down_height, X down_x_hot, down_y_hot, down_bits }; X XFontInfo *theFont; XOpaqueFrame frame; XWindow mainWindow; XWindowInfo mainLoc; X Xchar *geometry=""; Xchar defGeometry[16]; X Xint minWidth, minHeight; XBitmap bitmap; X Xint mapped = TRUE; Xint nSystems = 0; Xint ncols = 0; Xint dflag = FALSE; Xint delay = DEFAULT_DELAY; Xint border_width = DEFAULT_BWIDTH; Xint same_scale = FALSE; Xchar *font_name = DEFAULT_FONT; Xint reverse = FALSE; Xint all_hosts = FALSE; Xint X_hosts = FALSE; Xchar *host_names[MAXSYS]; Xint ww, dd=DEFAULT_SPACING, hh, rr; X Xsys_stat stats[MAXSYS]; END_OF_globals.c if test 1386 -ne `wc -c <globals.c`; then echo shar: \"globals.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f hostname.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"hostname.c\" else echo shar: Extracting \"hostname.c\" \(1186 characters\) sed "s/^X//" >hostname.c <<'END_OF_hostname.c' X/**************************************************************************/ X/* */ X/* Stuff to deal with host names */ X/* */ X/**************************************************************************/ X X#include "xrload.h" X X/* stolen from xhost.c */ X X/* X * get_hostname - Given an internet address, return a name (CHARON.MIT.EDU) X * or a string representing the address (18.58.0.13) if the name cannot X * be found. X */ X Xjmp_buf env; X Xchar *get_hostname (address) X struct in_addr address; X{ X struct hostent *hp = NULL; X int nameserver_lost(); X char *inet_ntoa(); X X/* X * gethostbyaddr can take a LONG time if the host does not exist. X * Assume that if it does not respond in NAMESERVER_TIMEOUT seconds X * that something is wrong and do not make the user wait. X * gethostbyaddr will continue after a signal, so we have to X * jump out of it. X */ X signal(SIGALRM, nameserver_lost); X alarm(8); X if (setjmp(env) == 0) { X hp = gethostbyaddr (&address, sizeof(struct in_addr), AF_INET); X } X alarm(0); X if (hp) X return (hp->h_name); X else return (inet_ntoa(address)); X} X Xnameserver_lost() X{ X longjmp(env, -1); X} END_OF_hostname.c if test 1186 -ne `wc -c <hostname.c`; then echo shar: \"hostname.c\" unpacked with wrong size! fi # end of overwriting check fi echo shar: End of archive 3 \(of 6\). cp /dev/null ark3isdone MISSING="" for I in 1 2 3 4 5 6 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 6 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 --- UUCP: ...{mcvax,inria}!inesc!hara.unl.psi!spa PSI/VMS: PSI%+26805010310::SPA ARPA: lisvax.dec!unlai!spa@decwrl.dec.com Phone: + 351 1 295 31 56 Snail: Salvador Pinto Abreu Dept. of Computer Science, Universidade Nova de Lisboa 2825 Monte Caparica, Portugal
psi@unl::spa (Salvador Pinto Abreu) (08/13/87)
#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 5 (of 6)." # Contents: xrload.1x # Wrapped by root@mak on Thu Aug 13 11:36:24 1987 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f xrload.1x -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"xrload.1x\" else echo shar: Extracting \"xrload.1x\" \(4451 characters\) sed "s/^X//" >xrload.1x <<'END_OF_xrload.1x' X.TH XRLOAD 1 "10 August 1987" "X Version 10" X.SH NAME Xxrload - X window system remote load average display X.SH SYNOPSIS X.B xrload X[ option ] ... X.SH DESCRIPTION X.I xrload Xdisplays the system load average for some or all hosts on a TPC/IP network. X.I xrload Xruns under the X.I X Xwindow system. X.I xrload Xcreates a window in which the load average for each system is represented as a Xdial with two hands and possibly n tick marks. XEach tick mark represents one unit of load average. XThe name of each host is displayed below its dial. The X large hand stands for the load average during the last Xminute, and the small hand stands for the previous 5 minutes. X.PP X.I xrload Xgets its data from the output of the X.I ruptime(1) Xcommand. X.PP X.I xrload Xunderstands the following options: X.PP X.TP 8 X.B \-cols \fIcolumns\fP XSpecify the number of columns in which to display the load statistics. X.PP X.TP 8 X.B \-bw \fIpixels\fP XSpecify the width in pixels of the border around the X.I xrload Xwindow. The default value is 2 pixels. X.PP X.TP 8 X.B \-fn \fIfontname\fP XThe system names will be displayed in the specified font (if none Xis specified, this defaults to timrom10b). X.PP X.TP 8 X.B \-rv XCause X.I xload Xto produce all output in black-on-white instead of white-on-black. X.PP X.TP 8 X.B \-spacing \fIinteger\fP XSpecify the spacing to leave between system meters. Default is 2 (pixels). X.PP X.TP 8 X.B \-delay \fIseconds\fP XSpecify the frequency in seconds with which X.I xrload Xupdates its display (except if the X.I xload Xwindow is obscured and then exposed, immediate redisplay occurs). The default Xupdate frequency is 30 seconds. Specification of a frequency Xless than 30 seconds is ignored and the default frequency is used Xinstead. In general, it is not worth using a very high frequency since Xxrload is subject to the bradcast messages sent by the various rwhod Xdaemons running on the network. X.PP X.TP 8 X.B \-same XDirect X.I xrload Xto use the same scale for all the meters. The scale is indicated by Xtick marks around the border for each meter. X.PP X.TP 8 X.B \-all XTell X.I xrload Xto display the load stats for X.I all Xthe hosts it gets from X.I ruptime. X.PP X.TP 8 X.B \-X XTell X.I xrload Xto display the load stats for all hosts currently able to use the Xdisplay it's running on. This list of hosts can be inspected and Xmodified with the X.I xhost(1) Xcommand. X.PP X.TP 8 X.B =\fIgeometry\fP XThe window is created with the specified Xsize and location Xdetermined Xby the supplied geometry specification. XSee \fIX(1)\fP for a full explanation. X.PP X.TP 8 X.B \[\fIhost\fP]:\[\fIdisplay\fP] XNormally, X.I xrload Xgets the host and display number to use from the environment Xvariable ``DISPLAY''. Either or both can be specified with this option. X.I host Xspecifies which machine to create the X.I xload Xwindow on, and X.I display Xspecifies the display number. XFor example, X``hara.gpl.unl:0'' creates an X.I xload Xon display 0 on machine hara.gpl.unl. Either value can be defaulted Xby omission but ``:'' is necessary to specify one or both. X.SH X DEFAULTS X.PP X.TP 8 X.B BodyFont XSet the hostname font. X.PP X.TP 8 X.B BorderWidth XSet the border width of the window. X.B ReverseVideo XIf ``on'', reverse the definition of foreground and background color. X.PP X.TP 8 X.B SameScale XBoolean value (``on'' or ``off''), determines if all meters will have Xthe same scale. X.PP X.TP 8 X.B Delay XSet the update interval. X.PP X.TP 8 X.B Columns XSets the wanted number of columns for display. X.PP X.TP 8 X.B Spacing XSets the spacing (in pixels) between meters. X.PP X.TP 8 X.B Hosts XTell what system's stats should be displayed: this can be either X``All'', meaning all hosts that appear in ruptime(1), ``X'' meaning Xonly those hosts that can use your display, or a list of Xcoma-separated names. X.SH ENVIRONMENT XDISPLAY - to get the default host and display number. X.SH SEE ALSO XX(1), uwm(1), X(8C), ruptime(1C) X.SH FILES X~/.Xdefaults, /usr/ucb/ruptime X.SH DIAGNOSTICS XVarious X errors. X.SH BUGS X.I xrload Xrelies on the format of ruptime(1) messages. Right now it works fine Xunder Ultrix 1.2 and 2.0, I think it should run on most 4.x BSD systems. X.SH AUTHORS XSalvador P. Abreu (New University of Lisbon -- Portugal, ...!mcvax!inesc!spa) X.br XCopyright (c) 1985, Massachusetts Institute of Technology. X.br XCopyright (c) 1987, GPLIA - Grupo de Programacao em Logica e XInteligencia Artificial, Dep. Informatica, Universidade Nova de XLisboa, 2825 Monte de Caparica, Portugal X.br XSee X(1) for a complete copyright notice. END_OF_xrload.1x if test 4451 -ne `wc -c <xrload.1x`; then echo shar: \"xrload.1x\" unpacked with wrong size! fi # end of overwriting check fi echo shar: End of archive 5 \(of 6\). cp /dev/null ark5isdone MISSING="" for I in 1 2 3 4 5 6 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 6 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 --- UUCP: ...{mcvax,inria}!inesc!hara.unl.psi!spa PSI/VMS: PSI%+26805010310::SPA ARPA: lisvax.dec!unlai!spa@decwrl.dec.com Phone: + 351 1 295 31 56 Snail: Salvador Pinto Abreu Dept. of Computer Science, Universidade Nova de Lisboa 2825 Monte Caparica, Portugal
psi@unl::spa (Salvador Pinto Abreu) (08/13/87)
#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 4 (of 6)." # Contents: get-stats.c # Wrapped by root@mak on Thu Aug 13 11:36:23 1987 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f get-stats.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"get-stats.c\" else echo shar: Extracting \"get-stats.c\" \(1791 characters\) sed "s/^X//" >get-stats.c <<'END_OF_get-stats.c' X/**************************************************************************/ X/* */ X/* Get system statistics. */ X/* */ X/**************************************************************************/ X X#include "xrload.h" X Xint pid; /* Gets child process id */ Xint iofd[2]; /* Sincronization pipe */ X Xint get_stats (stats) X sys_stat *stats; X{ X if (pipe (iofd) < 0) { X perror ("pipe"); X exit (1); X } X X if ((pid = fork ()) < 0) X perror ("fork"); X else if (pid == 0) { /* Child: exec ruptime */ X dup2 (iofd[1], 1); /* stdout to pipe */ X execl ("/usr/ucb/ruptime", "ruptime", 0); X perror ("can't exec /usr/ucb/ruptime"); X exit (1); X } X else { /* Parent: parse the stuff */ X static char hstatus[8], junk[8]; X union wait status; X int nh = 0, nf; X FILE *pfile; X X close (iofd[1]); X pfile = fdopen (iofd[0], "r"); X X for (;;) { X nf = fscanf (pfile, "%s %s %s %d %s load %f, %f, %f", X stats[nh].sys_name, hstatus, stats[nh].how_long, X &stats[nh].users, junk, X &stats[nh].load_average[0], X &stats[nh].load_average[1], X &stats[nh].load_average[2]); X if (dflag) X printf ("sys %d(%d): %s %s %s %du, %g %g %g\n", nh, nf, X stats[nh].sys_name, hstatus, stats[nh].how_long, X stats[nh].users, X stats[nh].load_average[0], X stats[nh].load_average[1], X stats[nh].load_average[2]); X if (nf < 3) break; X stats[nh].how_long[strlen(stats[nh].how_long)-1] = '\0'; X stats[nh].state = strcmp(hstatus, "up")? DOWN: UP; X if (all_hosts) X nh++; X else { X register int i = 0; X while (host_names[i] && X !streq(stats[nh].sys_name, host_names[i])) X i++; X if (host_names[i]) X nh++; X } X } X X stats[nh].sys_name[0] = '\0'; X X fclose (pfile); X wait (&status); X return (nh); X } X} END_OF_get-stats.c if test 1791 -ne `wc -c <get-stats.c`; then echo shar: \"get-stats.c\" unpacked with wrong size! fi # end of overwriting check fi echo shar: End of archive 4 \(of 6\). cp /dev/null ark4isdone MISSING="" for I in 1 2 3 4 5 6 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 6 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 --- UUCP: ...{mcvax,inria}!inesc!hara.unl.psi!spa PSI/VMS: PSI%+26805010310::SPA ARPA: lisvax.dec!unlai!spa@decwrl.dec.com Phone: + 351 1 295 31 56 Snail: Salvador Pinto Abreu Dept. of Computer Science, Universidade Nova de Lisboa 2825 Monte Caparica, Portugal
psi@unl::spa (Salvador Pinto Abreu) (08/13/87)
#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 6 (of 6)." # Contents: init.c # Wrapped by root@mak on Thu Aug 13 11:36:25 1987 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f init.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"init.c\" else echo shar: Extracting \"init.c\" \(5144 characters\) sed "s/^X//" >init.c <<'END_OF_init.c' X/**************************************************************************/ X/* */ X/* Initialization */ X/* */ X/**************************************************************************/ X X#include "xrload.h" X Xvoid initialize (argc, argv) X int argc; X char *argv[]; X{ X register int i, nsys; X char *option, *display = NULL, *getenv(); X X if ((option = XGetDefault ("xrload", "SameScale")) != NULL) X same_scale = streq(option, "on"); X if ((option = XGetDefault ("xrload", "Columns")) != NULL) X ncols = atoi(option); X if ((option = XGetDefault ("xrload", "Delay")) != NULL) X delay = atoi(option); X if ((option = XGetDefault ("xrload", "ReverseVideo")) != NULL) X reverse = streq(option, "on"); X if ((option = XGetDefault ("xrload", "BodyFont")) != NULL) X font_name = option; X if ((option = XGetDefault ("xrload", "BorderWidth")) != NULL) X border_width = atoi(option); X if ((option = XGetDefault ("xrload", "Spacing")) != NULL) X dd = atoi(option); X X for (i=1; i<argc; i++) { X if (argv[i][0] == '-') { X if (streq(argv[i], "-same") || streq(argv[i], "-s")) { X same_scale = TRUE; X } X else if (streq(argv[i], "-cols") || streq(argv[i], "-c")) { X ncols = atoi (argv[++i]); X } X else if (streq(argv[i], "-delay") || streq(argv[i], "-d")) { X delay = atoi (argv[++i]); X } X else if (streq(argv[i], "-all") || streq(argv[i], "-a")) { X all_hosts = TRUE; X } X else if (streq(argv[i], "-X")) { X X_hosts = TRUE; X } X else if (streq(argv[i], "-DEBUG") || streq(argv[i], "-D")) { X dflag++; X } X else if (streq(argv[i], "-rv")) { X reverse = TRUE; X } X else if (streq(argv[i], "-fn") || streq(argv[i], "-font")) { X font_name = argv[++i]; X } X else if (streq(argv[i], "-bw")) { X border_width = atoi(argv[++i]); X } X else if (streq(argv[i], "-spacing") || streq(argv[i], "-sp")) { X dd = atoi(argv[++i]); X } X else { X usage (); X } X } X else if (argv[i][0] == '=') X geometry = argv[i]; X else if (display) X usage (); X else X display = argv[i]; X } X X if (!display) { X display = getenv ("DISPLAY"); X if (!display || !*display) X display = "unix:0"; X } X X if (!XOpenDisplay (display)) { X fprintf (stderr, "xrload: can't open display %s.\n", display); X exit (1); X } X X if (!all_hosts) { X option = "X"; X if (X_hosts || ((option = XGetDefault ("xrload", "Hosts")) != NULL)) { X register char *p; X char *get_hostname(); X struct in_addr *hosts, *XGetHosts(); X int nhosts; X X if (streq (option, "All")) { X all_hosts = TRUE; X } X else if (streq (option, "X")) { X register char **host_namep = host_names; X register int i; X struct in_addr *hosts; X X all_hosts = FALSE; X hosts = XGetHosts (&nhosts); X if (nhosts != 0) { X sethostent(1); /* don't close the database each time */ X for (i=0; i<nhosts; i++) { X p = get_hostname(hosts[i]); X if (!streq (p, "localhost")) { X *host_namep = (char *) malloc (strlen(p)+1); X strcpy (*host_namep, p); X } X host_namep++; X } X endhostent(); X } X *host_namep = (char *) NULL; X } X else if (*option == '(') { X register char **host_namep = host_names; X all_hosts = FALSE; X while (*host_namep++ = strtok (option, "(), ;")) X option = (char *) NULL; X } X } X else X all_hosts = TRUE; X } X X if (dflag) { X if (all_hosts) X printf ("all hosts.\n"); X else { X register int i; X printf ("hosts:\n"); X for (i=0; host_names[i]; i++) X printf (" %2d: %s\n", i, host_names[i]); X } X } X X if ((nsys = get_stats (stats)) == 0) { X fprintf (stderr, "no hosts!\n"); X exit (1); X } X X if (ncols == 0) X ncols = (nsys<6)? nsys: (nsys/2); X X if ((theFont = XOpenFont (font_name)) == NULL) { X fprintf (stderr, "xrload: can't find font %s\n", font_name); X exit (1); X } X X { X register int max_swidth = 0; X for (i=0; i<nsys; i++) X max_swidth = max (XQueryWidth (stats[i].sys_name, theFont->id), X max_swidth); X X ww = max (back.width, max_swidth) + dd; X hh = back.height + dd + theFont->height; X rr = (ww-1)/2; X } X X minWidth = ncols * ww + (ncols+1) * dd; X minHeight = ((nsys+ncols-1)/ncols) * hh + ((nsys+ncols-1)/ncols) * dd; X X sprintf (defGeometry, "=%dx%d", minWidth, minHeight); X X if (reverse) { X whitePixmap = WhitePixmap; X blackPixmap = BlackPixmap; X whitePixel = WhitePixel; X blackPixel = BlackPixel; X } X else { X whitePixmap = BlackPixmap; X blackPixmap = WhitePixmap; X whitePixel = BlackPixel; X blackPixel = WhitePixel; X } X X frame.bdrwidth = border_width; X frame.border = whitePixmap; X frame.background = blackPixmap; X X mainWindow = XCreate ("Load Averages", argv[0], X geometry, defGeometry, &frame, minWidth, minHeight); X X XStoreName (mainWindow, "Load Averages"); X XSelectInput (mainWindow, ExposeWindow|UnmapWindow); X X bitmap = XStoreBitmap (gray1.width, gray1.height, gray1.bits); X GrayPixmap = XMakePixmap (bitmap, WhitePixel, BlackPixel); X XFreeBitmap (bitmap); X X XSetResizeHint (mainWindow, dd, 0, ww+dd, hh+dd); X XMapWindow (mainWindow); X} END_OF_init.c if test 5144 -ne `wc -c <init.c`; then echo shar: \"init.c\" unpacked with wrong size! fi # end of overwriting check fi echo shar: End of archive 6 \(of 6\). cp /dev/null ark6isdone MISSING="" for I in 1 2 3 4 5 6 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 6 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 --- UUCP: ...{mcvax,inria}!inesc!hara.unl.psi!spa PSI/VMS: PSI%+26805010310::SPA ARPA: lisvax.dec!unlai!spa@decwrl.dec.com Phone: + 351 1 295 31 56 Snail: Salvador Pinto Abreu Dept. of Computer Science, Universidade Nova de Lisboa 2825 Monte Caparica, Portugal
palmer@fcs50b.UUCP (08/17/87)
Something was wrong with the set of shar files we recieved. Xrload.h was nowhere to be found. It is included by every source code file yet is not listed in the MANIFEST or amoung the SHARFILES in the Makefile. I'm really confused because it seems that other sites recieved a full distribution. Any ideas? In any event, could someone please mail me a copy of xrload.h? Thanks. -Tom Thomas C. Palmer Thomas C. Palmer NCI Supercomputer Facility c/o PRI, Inc. Phone: (301) 698-5797 PO Box B, Bldg. 430 Uucp: ...!uunet!mimsy!elsie!ncifcrf!palmer Frederick, MD 21701 Arpanet: mimsy!elsie!ncifcrf!palmer@uunet.uu.net Bitnet: uunet!mimsy!elsie!ncifcrf!palmer@psuvax1.bitnet