home *** CD-ROM | disk | FTP | other *** search
- From: wht@n4hgf.Mt-Park.GA.US (Warren Tucker)
- Newsgroups: alt.sources
- Subject: X386MON part 05/06
- Message-ID: <325@n4hgf.Mt-Park.GA.US>
- Date: 16 Feb 91 19:35:54 GMT
-
- Submitted-by: wht@n4hgf
- Archive-name: x386monx100/part05
-
- #!/bin/sh
- # This is part 05 of x386monx100
- # ============= x386mon/tune.c ==============
- if test ! -d 'x386mon'; then
- echo 'x - creating directory x386mon'
- mkdir 'x386mon'
- fi
- if test -f 'x386mon/tune.c' -a X"$1" != X"-c"; then
- echo 'x - skipping x386mon/tune.c (File already exists)'
- else
- echo 'x - extracting x386mon/tune.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'x386mon/tune.c' &&
- X/*+-------------------------------------------------------------------------
- X tune.c - X386MON tune struct display
- X wht@n4hgf.Mt-Park.GA.US
- X
- X Defined functions:
- X draw_Tune(x,y)
- X
- X--------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */
- X
- X#include "unixincs.h"
- X#if defined(mips)
- X#define t_gpgsmsk t_gpgslmsk
- X#endif
- X#define WANT_MON_EXTERNS
- X#include "x386mon.h"
- X#include "buttons.h"
- X#include "utoa.h"
- X#include "disp_info.h"
- X
- Xstatic int line_style = LineSolid;
- Xstatic int cap_style = CapButt;
- Xstatic int join_style = JoinMiter;
- X
- X/*+-------------------------------------------------------------------------
- X draw_Tune(x,y)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xdraw_Tune(x,y)
- Xint x;
- Xint y;
- X{
- Xregister itmp;
- Xchar *cptr;
- Xchar s32[32];
- Xint fwidth = FWIDTH;
- Xint fheight = FHEIGHT;
- Xint len;
- Xint x2 = x;
- Xint yl1 = y + (FASCENT / 2);
- Xint yl2 = y + (fheight / 2) - 1;
- Xint ys = y + FASCENT;
- X
- X switch(current_display_mode)
- X {
- X case BUTTON_main:
- X break;
- X default:
- X return;
- X }
- X
- X if(DrawAreaXYWH.height < (y + (fheight * 2)))
- X return;
- X
- X cptr = "---Tune----------";
- X len = strlen(cptr);
- X /* the "background" bar */
- X XSetForeground(display,gc,colorSlate.pixel);
- X XSetLineAttributes(display,gc,fheight,line_style,cap_style,join_style);
- X XDrawLine(display,window,gc, x,yl1, x + (len * fwidth),yl1);
- X
- X /* draw the black line before "Tune" */
- X XSetForeground(display,gc,foreground);
- X XSetLineAttributes(display,gc,FASCENT / 2,line_style,cap_style,join_style);
- X XDrawLine(display,window,gc,
- X x2,yl1,
- X x2 + (len = (fwidth * 3)) - FGAP,yl1);
- X x2 += len;
- X
- X /* draw "Tune" */
- X cptr = "Tune";
- X XDrawString(display,window,gc, x2, ys, cptr,len = strlen(cptr));
- X XDrawString(display,window,gc, x2+1,ys, cptr,len);
- X x2 += fwidth * len;
- X
- X /* draw the black line after "Tune" */
- X XDrawLine(display,window,gc,
- X x2 + FGAP + 1,yl1,
- X x2 + (len = (fwidth * 10)),yl1);
- X y += fheight;
- X
- X#ifdef SVR32
- X disp_static_int(x,y,"t_ageintvl ",5,tune.t_ageinterval);
- X y += fheight;
- X#endif
- X disp_static_int(x,y,"t_bdflushr ",5,tune.t_bdflushr);
- X y += fheight;
- X disp_static_int(x,y,"t_gpgshi ",5,tune.t_gpgshi);
- X y += fheight;
- X disp_static_int(x,y,"t_gpgslo ",5,tune.t_gpgslo);
- X y += fheight;
- X strcpy(s32,"t_gpgsmsk 0x");
- X ultoxa(s32 + strlen(s32),3,tune.t_gpgsmsk);
- X disp_static_text(x,y,s32);
- X y += fheight;
- X disp_static_int(x,y,"t_maxfc ",5,tune.t_maxfc);
- X y += fheight;
- X disp_static_int(x,y,"t_maxsc ",5,tune.t_maxsc);
- X y += fheight;
- X disp_static_int(x,y,"t_maxumem ",5,tune.t_maxumem);
- X y += fheight;
- X disp_static_int(x,y,"t_minarmem ",5,tune.t_minarmem);
- X y += fheight;
- X disp_static_int(x,y,"t_minasmem ",5,tune.t_minasmem);
- X y += fheight;
- X
- X} /* end of draw_Tune */
- X
- X/* vi: set tabstop=4 shiftwidth=4: */
- X/* end of tune.c */
- SHAR_EOF
- chmod 0644 x386mon/tune.c ||
- echo 'restore of x386mon/tune.c failed'
- Wc_c="`wc -c < 'x386mon/tune.c'`"
- test 2851 -eq "$Wc_c" ||
- echo 'x386mon/tune.c: original size 2851, current size' "$Wc_c"
- fi
- # ============= x386mon/unixincs.h ==============
- if test -f 'x386mon/unixincs.h' -a X"$1" != X"-c"; then
- echo 'x - skipping x386mon/unixincs.h (File already exists)'
- else
- echo 'x - extracting x386mon/unixincs.h (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'x386mon/unixincs.h' &&
- X
- X/*+-------------------------------------------------------------------------
- X unixincs.h
- X wht@n4hgf.Mt-Park.GA.US
- X--------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */
- X
- X#include <stdio.h>
- X#include <ctype.h>
- X#include <signal.h>
- X#include <string.h>
- X#include <malloc.h>
- X#include <fcntl.h>
- X#include <nlist.h>
- X#include <time.h>
- X#include <sys/errno.h>
- X#include <sys/types.h>
- X#include <sys/timeb.h>
- X#include <sys/lock.h>
- X#include <sys/utsname.h>
- X#include <sys/stat.h>
- X#include <sys/ascii.h>
- X#undef NGROUPS_MAX
- X#undef NULL
- X#include <sys/param.h>
- X#include <sys/bootinfo.h>
- X#include <sys/tuneable.h>
- X#include <sys/sysinfo.h>
- X#include <sys/sysmacros.h>
- X#include <sys/immu.h>
- X#include <sys/region.h>
- X#include <sys/proc.h>
- X#include <sys/var.h>
- X#include <sys/sysi86.h>
- X#include <sys/swap.h>
- X#include <sys/trap.h>
- X
- X/* vi: set tabstop=4 shiftwidth=4: */
- X/* end of unixincs.h */
- SHAR_EOF
- chmod 0644 x386mon/unixincs.h ||
- echo 'restore of x386mon/unixincs.h failed'
- Wc_c="`wc -c < 'x386mon/unixincs.h'`"
- test 961 -eq "$Wc_c" ||
- echo 'x386mon/unixincs.h: original size 961, current size' "$Wc_c"
- fi
- # ============= x386mon/util.c ==============
- if test -f 'x386mon/util.c' -a X"$1" != X"-c"; then
- echo 'x - skipping x386mon/util.c (File already exists)'
- else
- echo 'x - extracting x386mon/util.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'x386mon/util.c' &&
- X/*+-------------------------------------------------------------------------
- X util.c - X386MON utility functions
- X wht@n4hgf.Mt-Park.GA.US
- X
- X Defined functions:
- X basename(fullname)
- X get_elapsed_time(elapsed_seconds)
- X
- X--------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */
- X
- X#include <sys/types.h>
- X
- X/*+-------------------------------------------------------------------------
- X basename(fullname) - strip directory name from filename
- X
- Xreturns address of static string
- X--------------------------------------------------------------------------*/
- Xchar *
- Xbasename(fullname)
- Xchar *fullname;
- X{
- Xregister char *start;
- Xstatic char outstr[256];
- Xchar *strrchr();
- X
- X start = strrchr(fullname,'/'); /* find last slash */
- X if(!start)
- X return(fullname);
- X start++;
- X strcpy(outstr,start);
- X return(outstr);
- X} /* end of basename */
- X
- X/*+-----------------------------------------------------------------------
- X char *get_elapsed_time(elapsed_seconds) - "ddd+hh:mm:ss" returned
- X static string address is returned
- X------------------------------------------------------------------------*/
- Xchar *
- Xget_elapsed_time(elapsed_seconds)
- Xtime_t elapsed_seconds;
- X{
- Xstatic char elapsed_time_str[32];
- Xtime_t dd,hh,mm,ss;
- X
- X dd = 0;
- X hh = elapsed_seconds / 3600;
- X if(hh > 24)
- X {
- X dd = hh / 24;
- X elapsed_seconds -= dd * 3600 * 24;
- X hh %= 24;
- X }
- X elapsed_seconds -= hh * 3600;
- X mm = elapsed_seconds / 60L;
- X elapsed_seconds -= mm * 60L;
- X ss = elapsed_seconds;
- X
- X if(dd)
- X (void)sprintf(elapsed_time_str,"%3ld+%02ld:%02ld:%02ld",dd,hh,mm,ss);
- X else
- X (void)sprintf(elapsed_time_str," %2ld:%02ld:%02ld",hh,mm,ss);
- X return(elapsed_time_str);
- X} /* end of get_elapsed_time */
- X
- X/* vi: set tabstop=4 shiftwidth=4: */
- X/* end of util.c */
- SHAR_EOF
- chmod 0644 x386mon/util.c ||
- echo 'restore of x386mon/util.c failed'
- Wc_c="`wc -c < 'x386mon/util.c'`"
- test 1791 -eq "$Wc_c" ||
- echo 'x386mon/util.c: original size 1791, current size' "$Wc_c"
- fi
- # ============= x386mon/utoa.c ==============
- if test -f 'x386mon/utoa.c' -a X"$1" != X"-c"; then
- echo 'x - skipping x386mon/utoa.c (File already exists)'
- else
- echo 'x - extracting x386mon/utoa.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'x386mon/utoa.c' &&
- X/* CHK=0xDD15 */
- X/*+-------------------------------------------------------------------------
- X utoa.c - fast substitutes for most sprintf needs
- X wht@n4hgf.Mt-Park.GA.US
- X
- X Defined functions:
- X utoda_common(buf,width,n,leading)
- X utoxa_common(buf,width,n,leading)
- X
- X--------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */
- X
- X#include "utoa.h"
- X
- X/*+-------------------------------------------------------------------------
- X utoda_common(buf,width,n,leading) unsigned to decimal ascii
- X--------------------------------------------------------------------------*/
- Xvoid
- Xutoda_common(buf,width,n,leading)
- Xchar *buf;
- Xint width;
- Xunsigned long n;
- Xchar leading;
- X{
- X register unsigned div;
- X register char *ep = &buf[width];
- X
- X *ep = '\0';
- X if(n == 0)
- X *--ep = '0';
- X while(ep-- > buf)
- X {
- X if(n <= 0)
- X *ep = leading;
- X else
- X {
- X div = n / 10;
- X *ep = n - 10*div + '0';
- X n = div;
- X }
- X }
- X} /* end of utoda_common */
- X
- X/*+-------------------------------------------------------------------------
- X utoxa_common(buf,width,n,leading) unsigned to octal ascii
- X--------------------------------------------------------------------------*/
- Xvoid
- Xutoxa_common(buf,width,n,leading)
- Xchar *buf;
- Xint width;
- Xunsigned long n;
- Xchar leading;
- X{
- Xregister unsigned div;
- Xregister char *ep = &buf[width];
- Xstatic char hexchars[] = "0123456789ABCDEF";
- X
- X *ep = '\0';
- X if(n == 0)
- X *--ep = '0';
- X while(ep-- > buf)
- X {
- X if(n <= 0)
- X *ep = leading;
- X else
- X {
- X div = n >> 4;
- X *ep = hexchars[n - (div << 4)];
- X n = div;
- X }
- X }
- X} /* end of utoxa_common */
- X
- X/* vi: set tabstop=4 shiftwidth=4: */
- X/* end of utoa.c */
- SHAR_EOF
- chmod 0644 x386mon/utoa.c ||
- echo 'restore of x386mon/utoa.c failed'
- Wc_c="`wc -c < 'x386mon/utoa.c'`"
- test 1669 -eq "$Wc_c" ||
- echo 'x386mon/utoa.c: original size 1669, current size' "$Wc_c"
- fi
- # ============= x386mon/utoa.h ==============
- if test -f 'x386mon/utoa.h' -a X"$1" != X"-c"; then
- echo 'x - skipping x386mon/utoa.h (File already exists)'
- else
- echo 'x - extracting x386mon/utoa.h (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'x386mon/utoa.h' &&
- X/* CHK=0x3B34 */
- X/*+-----------------------------------------------------------------------
- X utoa.h
- X wht@n4hgf.Mt-Park.GA.US
- X------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */
- X
- X/* unsigned to decimal ascii w/ leading spaces */
- X#define utoda(b,w,n) utoda_common((b),(w),(unsigned long)(n),' ')
- X#define ultoda(b,w,n) utoda_common((b),(w),n,' ')
- X
- X/* unsigned to decimal ascii w/leading zeroes */
- X#define utoda_lz(b,w,n) utoda_common((b),(w),(unsigned long)(n),'0')
- X#define ultoda_lz(b,w,n) utoda_common((b),(w),(n),'0')
- X
- X/* unsigned to hexadecimal ascii w/ leading spaces */
- X#define utoxa(b,w,n) utoxa_common((b),(w),(unsigned long)(n),' ')
- X#define ultoxa(b,w,n) utoxa_common((b),(w),(n),' ')
- X
- X/* unsigned to hexadecimal ascii w/leading zeroes */
- X#define utoxa_lz(b,w,n) utoxa_common((b),(w),(unsigned long)(n),'0')
- X#define ultoxa_lz(b,w,n) utoxa_common((b),(w),(n),'0')
- X
- X#ifndef BUILDING_PROTOTYPES
- X#ifdef __STDC__
- X/* utoa.c */
- Xvoid utoda_common(char *,int ,unsigned long ,char );
- Xvoid utoxa_common(char *,int ,unsigned long ,char );
- X#else /* compiler doesn't know about prototyping */
- X/* utoa.c */
- Xvoid utoda_common();
- Xvoid utoxa_common();
- X#endif /* __STDC__ */
- X#endif /* BUILDING_PROTOTYPES */
- X
- X/* end of utoa.h */
- SHAR_EOF
- chmod 0644 x386mon/utoa.h ||
- echo 'restore of x386mon/utoa.h failed'
- Wc_c="`wc -c < 'x386mon/utoa.h'`"
- test 1322 -eq "$Wc_c" ||
- echo 'x386mon/utoa.h: original size 1322, current size' "$Wc_c"
- fi
- # ============= x386mon/var.c ==============
- if test -f 'x386mon/var.c' -a X"$1" != X"-c"; then
- echo 'x - skipping x386mon/var.c (File already exists)'
- else
- echo 'x - extracting x386mon/var.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'x386mon/var.c' &&
- X/*+-------------------------------------------------------------------------
- X var.c - X386MON var struct handler
- X wht@n4hgf.Mt-Park.GA.US
- X
- X Defined functions:
- X draw_Var(x,y)
- X
- X--------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */
- X
- X#include "unixincs.h"
- X#define WANT_MON_EXTERNS
- X#include "x386mon.h"
- X#include "buttons.h"
- X#include "disp_info.h"
- X
- Xstatic int line_style = LineSolid;
- Xstatic int cap_style = CapButt;
- Xstatic int join_style = JoinMiter;
- X
- X/*+-------------------------------------------------------------------------
- X draw_Var(x,y)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xdraw_Var(x,y)
- Xint y;
- Xint x;
- X{
- Xregister itmp;
- Xchar *cptr;
- Xchar s80[80];
- Xint fwidth = FWIDTH;
- Xint fheight = FHEIGHT;
- Xint len;
- Xint x2 = x;
- Xint yl1 = y + (FASCENT / 2);
- Xint yl2 = y + (FHEIGHT / 2) - 1;
- Xint ys = y + FASCENT;
- X
- X switch(current_display_mode)
- X {
- X case BUTTON_main:
- X break;
- X default:
- X return;
- X }
- X
- X if(DrawAreaXYWH.height < (y + (fheight * 2)))
- X return;
- X
- X cptr = "---Var----------";
- X len = strlen(cptr);
- X /* the "background" bar */
- X XSetForeground(display,gc,colorSlate.pixel);
- X XSetLineAttributes(display,gc,fheight,line_style,cap_style,join_style);
- X XDrawLine(display,window,gc, x,yl1, x + (len * fwidth),yl1);
- X
- X /* draw the black line before "Var" */
- X XSetForeground(display,gc,foreground);
- X XSetLineAttributes(display,gc,FASCENT / 2,line_style,cap_style,join_style);
- X XDrawLine(display,window,gc,
- X x2,yl1,
- X x2 + (len = (fwidth * 3)) - FGAP,yl1);
- X x2 += len;
- X
- X /* draw "Var" */
- X cptr = "Var";
- X XDrawString(display,window,gc, x2, ys, cptr,len = strlen(cptr));
- X XDrawString(display,window,gc, x2+1,ys, cptr,len = strlen(cptr));
- X x2 += fwidth * len;
- X
- X /* draw the black line after "Var" */
- X XDrawLine(display,window,gc,
- X x2 + FGAP + 1,yl1,
- X x2 + (len = (fwidth * 10)),yl1);
- X y += fheight;
- X
- X disp_static_int(x,y,"v_autoup ",5,v.v_autoup);
- X y += fheight;
- X disp_static_int(x,y,"v_buf ",5,v.v_buf);
- X y += fheight;
- X disp_static_int(x,y,"v_clist ",5,v.v_clist);
- X y += fheight;
- X disp_static_int(x,y,"v_file ",5,v.v_file);
- X y += fheight;
- X disp_static_int(x,y,"v_hbuf ",5,v.v_hbuf);
- X y += fheight;
- X disp_static_int(x,y,"v_inode ",5,v.v_inode);
- X y += fheight;
- X disp_static_int(x,y,"v_maxpmem ",5,v.v_maxpmem);
- X y += fheight;
- X disp_static_int(x,y,"v_maxup ",5,v.v_maxup);
- X y += fheight;
- X disp_static_int(x,y,"v_mount ",5,v.v_mount);
- X y += fheight;
- X disp_static_int(x,y,"v_pbuf ",5,v.v_pbuf);
- X y += fheight;
- X disp_static_int(x,y,"v_proc ",5,v.v_proc);
- X y += fheight;
- X disp_static_int(x,y,"v_region ",5,v.v_region);
- X y += fheight;
- X disp_static_int(x,y,"v_vhndfrac ",5,v.v_vhndfrac);
- X
- X} /* end of draw_Var */
- X
- X/* vi: set tabstop=4 shiftwidth=4: */
- X/* end of var.c */
- SHAR_EOF
- chmod 0644 x386mon/var.c ||
- echo 'restore of x386mon/var.c failed'
- Wc_c="`wc -c < 'x386mon/var.c'`"
- test 2829 -eq "$Wc_c" ||
- echo 'x386mon/var.c: original size 2829, current size' "$Wc_c"
- fi
- # ============= x386mon/x386mon.c ==============
- if test -f 'x386mon/x386mon.c' -a X"$1" != X"-c"; then
- echo 'x - skipping x386mon/x386mon.c (File already exists)'
- else
- echo 'x - extracting x386mon/x386mon.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'x386mon/x386mon.c' &&
- Xchar *revision = "x1.00";
- X/*+-------------------------------------------------------------------------
- X x386mon.c - SCO ODT (UNIX 386) system watcher
- X wht@n4hgf.Mt-Park.GA.US
- X
- X Defined functions:
- X calc_cpu_avg(per_state)
- X calc_wait_avg(per_state)
- X delta_StatCycle(delta_msec)
- X draw_display()
- X draw_lower_main_statics()
- X entry_callback(widget,client_data,call_data)
- X expose_callback(widget,client_data,call_data)
- X get_cpu_avg(cpu_ticks,period)
- X get_wait_avg(wait_ticks,period)
- X input_callback(widget,client_data,call_data)
- X input_callback_key_event(widget,client_data,call_data)
- X main(argc,argv)
- X quit_now()
- X read_sysinfo_and_minfo()
- X resize_callback(widget,client_data,call_data)
- X set_display_mode(new_mode)
- X set_update_timer()
- X update_StatCycle()
- X update_StatPeriod()
- X update_Tod()
- X update_display(read_new_kernel_data)
- X update_timer_proc(client_data)
- X
- XAll of the Motif dependencies appear in this module; the rest of
- Xthe code is Xlib or {private widget,conservative use of Xt} only
- XSome hacking will be necessary on the Button widget to un-Motifize
- Xit, like changing 'Primitive' to 'Simple' or the like
- X
- X--------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */
- X
- X#include "unixincs.h"
- X#define WANT_MON_EXTERNS
- X#include "x386mon.h"
- X#include <X11/StringDefs.h>
- X#include <X11/Shell.h>
- X#include <Xm/DrawingA.h>
- X#include "nlsym.h"
- X#include "libkmem.h"
- X#include "libmem.h"
- X#include "libswap.h"
- X#include "libnlsym.h"
- X#include "scales.h"
- X#include "buttons.h"
- X#include "utoa.h"
- X
- Xchar *basename();
- Xvoid quit_now();
- X
- Xextern XtWorkProcId ps_WorkProc_ID;
- X
- XXtAppContext appcon;
- XWidget AppShellW;
- XWidget DrawAreaW;
- XXWindowAttributes DrawAreaXYWH;
- XDisplay *display;
- XWindow window = 0;
- Xint screen;
- Xint display_width;
- Xint display_height;
- XGC gc;
- XColormap cmap;
- Xint redrawing_entire_DrawArea = 1;
- Xchar DrawArea_title[128];
- XXtIntervalId update_timer_ID = (XtIntervalId)0;
- Xchar *make_taller_to_restore_Ps = "make taller to restore PS";
- Xchar *make_taller_for_Ps = "make taller for PS display";
- X
- XMyResources res;
- X
- Xchar preferred_geom[64] = "";
- X
- X#define offset(field) XtOffset(MyResources *, field)
- Xstatic XtResource appResources[] =
- X{
- X {"geometry", "Geometry", XtRString, sizeof(char *),
- X offset(geometry), XtRString, preferred_geom },
- X
- X {"font", "Font", XtRString, sizeof(char *),
- X offset(font), XtRString, "6x10" },
- X
- X {"background", "Background", XtRString, sizeof(char *),
- X offset(background), XtRString, "black" },
- X
- X {"foreground", "Foreground", XtRString, sizeof(char *),
- X offset(foreground), XtRString, "black" },
- X
- X {"busyWarningThreshhold","WarningThreshhold", XtRInt, sizeof(int),
- X offset(busyWarningThreshhold), XtRString, "70" },
- X
- X {"busyAlarmThreshhold","AlarmThreshhold", XtRInt, sizeof(int),
- X offset(busyAlarmThreshhold), XtRString, "90" },
- X
- X {"breakWarningThreshhold","WarningThreshhold",XtRInt, sizeof(int),
- X offset(breakWarningThreshhold), XtRString, "2" },
- X
- X {"breakAlarmThreshhold","AlarmThreshhold", XtRInt, sizeof(int),
- X offset(breakAlarmThreshhold), XtRString, "5" },
- X
- X {"waitWarningThreshhold","WarningThreshhold", XtRInt, sizeof(int),
- X offset(waitWarningThreshhold), XtRString, "20" },
- X
- X {"waitAlarmThreshhold","AlarmThreshhold", XtRInt, sizeof(int),
- X offset(waitAlarmThreshhold), XtRString, "50" },
- X
- X {"swapWarningThreshhold","WarningThreshhold", XtRInt, sizeof(int),
- X offset(swapWarningThreshhold), XtRString, "10" },
- X
- X {"swapAlarmThreshhold","AlarmThreshhold", XtRInt, sizeof(int),
- X offset(swapAlarmThreshhold), XtRString, "20" },
- X
- X};
- X#undef offset
- X
- Xstatic XrmOptionDescRec optionDescList[] =
- X{
- X/* geometry must be first record */
- X {"-geometry", "*geometry", XrmoptionSepArg, (caddr_t)0},
- X {"-fg", "*foreground", XrmoptionSepArg, (caddr_t)0},
- X {"-bg", "*background", XrmoptionSepArg, (caddr_t)0},
- X {"-fn", "*font", XrmoptionSepArg, (caddr_t)0},
- X {"-ms", "*pointerColor", XrmoptionSepArg, (caddr_t)0},
- X {"-bwt", "*busyWarningThreshhold", XrmoptionSepArg, (caddr_t)0},
- X {"-bat", "*busyAlarmThreshhold", XrmoptionSepArg, (caddr_t)0},
- X {"-Bwt", "*breakWarningThreshhold", XrmoptionSepArg, (caddr_t)0},
- X {"-Bat", "*breakAlarmThreshhold", XrmoptionSepArg, (caddr_t)0},
- X {"-wwt", "*waitWarningThreshhold", XrmoptionSepArg, (caddr_t)0},
- X {"-wat", "*waitAlarmThreshhold", XrmoptionSepArg, (caddr_t)0},
- X {"-swt", "*swapWarningThreshhold", XrmoptionSepArg, (caddr_t)0},
- X {"-sat", "*swapAlarmThreshhold", XrmoptionSepArg, (caddr_t)0},
- X};
- X
- Xtypedef struct myusagelist
- X{
- X char *opt;
- X char *desc;
- X} MyUsageList;
- X
- Xstatic MyUsageList usage_list[] =
- X{
- X { "-help", "print out this message" },
- X { "-display displayname", "X server to contact" },
- X { "-geometry geom", "size (in characters) and position" },
- X { "-bg color", "background color" },
- X { "-fg color", "foreground color" },
- X { "-iconic", "start iconic" },
- X { "-bd color", "border color" },
- X { "-bw number", "border width in pixels" },
- X { "-fn fontname", "normal text font" },
- X { "-uc color", "user CPU percentage scale color" },
- X { "-kc color", "kernel CPU percentage scale color" },
- X { "-bc color", "break CPU percentage scale color" },
- X { "-ic color", "(block) I/O wait percentage scale color" },
- X { "-pc color", "physical I/O wait percentage scale color" },
- X { "-sc color", "swap I/O wait percentage scale color" },
- X { (char *)0, (char *)0 }
- X};
- X/* "our" stuff */
- X
- X#define delta_msec(t,t0) ((( t.time * 1000L) + t.millitm) - \
- X ((t0.time * 1000L) + t0.millitm))
- X
- X#define StatCycle_msecDef 2000L
- X#define StatCycle_msecMin 1000L
- X#define StatCycle_msecMax 4000L
- X
- Xunsigned long StatCycle_msec = StatCycle_msecDef;
- X
- Xstruct sysinfo sysinfo;
- Xstruct sysinfo sysinfo_last;
- X
- Xstruct minfo minfo;
- Xstruct minfo minfo_last;
- X
- X#if defined(HAS_BOOTINFO)
- Xstruct bootinfo bootinfo;
- X#endif
- X
- Xswpt_t swaptab [MSFILES];
- Xswpi_t swapint = {SI_LIST, (char *)swaptab};
- Xstruct tune tune;
- Xstruct utsname utsname;
- Xstruct var v;
- X
- Xstruct timeb timeb_cycle_start;
- Xstruct timeb timeb_cycle_end;
- Xstruct timeb timeb_info_read;
- Xstruct timeb timeb_last_info_read;
- X
- Xint hz;
- Xint nswap; /* seems to be in units of NBPSCTR bytes */
- Xint maxmem;
- Xint freemem;
- Xdaddr_t myreadlen = 0L;
- Xint myreadcnt = 0;
- Xlong StatPeriod_msec;
- Xint current_display_mode = -1;
- X
- Xint cpu_avg_init = 0;
- Xtime_t *cpu_avg[CPU_AVG_MAX];
- Xtime_t cpu_ticks[5];
- X
- Xint wait_avg_init = 0;
- Xtime_t *wait_avg[WAIT_AVG_MAX];
- Xtime_t wait_ticks[5];
- Xint ps_procs_to_display = 0;
- X#define PS_X_TOO_BIG 99999
- Xint ps_x,ps_y;
- Xint fresh_Ps_paint = 1;
- X
- Xvoid caught_signal();
- X
- X/*+-------------------------------------------------------------------------
- X update_Tod() - show current time
- X--------------------------------------------------------------------------*/
- Xvoid
- Xupdate_Tod()
- X{
- Xtime_t now;
- Xstruct tm *lt;
- Xchar tod[12];
- Xchar *cptr = tod;
- X
- X if(DrawAreaXYWH.width < (DispMsg_tlx + Tod_WIDTH + (FWIDTH * 2)))
- X return;
- X
- X (void)time(&now);
- X lt = localtime(&now);
- X utoda_lz(cptr,2,lt->tm_hour);
- X cptr += 2;
- X *cptr++ = ':';
- X utoda_lz(cptr,2,lt->tm_min);
- X cptr += 2;
- X *cptr++ = ':';
- X utoda_lz(cptr,2,lt->tm_sec);
- X cptr += 2;
- X *cptr = 0;
- X XClearArea(display,window,Tod_TLX,Tod_TLY,FWIDTH * 8,FHEIGHT,0);
- X XSetForeground(display,gc,colorCyan.pixel);
- X XDrawString(display,window,gc,Tod_TLX,Tod_TLY + FASCENT,tod,8);
- X
- X} /* end of update_Tod */
- X
- X/*+-------------------------------------------------------------------------
- X update_StatPeriod() - show time since last update
- X--------------------------------------------------------------------------*/
- Xvoid
- Xupdate_StatPeriod()
- X{
- Xunsigned long pixel = colorGreen.pixel;
- Xchar msecstr[32];
- Xint pct = (StatPeriod_msec * 100) / StatCycle_msec;
- X
- X if(DrawAreaXYWH.width <
- X (DispMsg_tlx + StatPeriod_WIDTH + Tod_WIDTH + (FWIDTH * 2)))
- X {
- X return;
- X }
- X
- X if(StatPeriod_msec < 50)
- X strcpy(msecstr,"--------");
- X else
- X {
- X ultoda(msecstr,7,StatPeriod_msec);
- X strcat(msecstr,"ms");
- X }
- X
- X XClearArea(display,window,
- X StatPeriod_TLX,StatPeriod_TLY,FWIDTH * 8,FHEIGHT,0);
- X if(pct < 20)
- X pixel = colorSlate.pixel;
- X else if(pct < 80)
- X pixel = colorOrange.pixel;
- X else if((pct > 200) || ((StatPeriod_msec - StatCycle_msec) > 3000L))
- X pixel = colorRed.pixel;
- X else if((pct > 150) || ((StatPeriod_msec - StatCycle_msec) > 2000L))
- X pixel = colorYellow.pixel;
- X XSetForeground(display,gc,pixel);
- X XDrawString(display,window,gc,
- X StatPeriod_TLX,StatPeriod_TLY + FASCENT,msecstr,strlen(msecstr));
- X
- X} /* end of update_StatPeriod */
- X
- X/*+-------------------------------------------------------------------------
- X update_StatCycle() - show planned time between updates
- X--------------------------------------------------------------------------*/
- Xvoid
- Xupdate_StatCycle()
- X{
- Xchar msecstr[32];
- Xint pct = (StatCycle_msec * 100) / StatCycle_msec;
- X
- X if(DrawAreaXYWH.width <
- X (DispMsg_tlx + StatCycle_WIDTH + StatPeriod_WIDTH +
- X Tod_WIDTH + (FWIDTH * 4)))
- X {
- X return;
- X }
- X
- X ultoda(msecstr,6,StatCycle_msec);
- X strcat(msecstr,"ms");
- X XClearArea(display,window,
- X StatCycle_TLX,StatCycle_TLY,FWIDTH * 8,FHEIGHT,0);
- X XSetForeground(display,gc,colorBlue.pixel);
- X XDrawString(display,window,gc,
- X StatCycle_TLX,StatCycle_TLY + FASCENT,msecstr,strlen(msecstr));
- X
- X} /* end of update_StatCycle */
- X
- X/*+-------------------------------------------------------------------------
- X calc_cpu_avg(per_state) - add per_state array to avg array
- X--------------------------------------------------------------------------*/
- Xvoid
- Xcalc_cpu_avg(per_state)
- Xtime_t per_state[];
- X{
- Xregister itmp;
- X
- X if(!cpu_avg_init)
- X {
- X for(itmp = 0; itmp < CPU_AVG_MAX; itmp++)
- X (void)memcpy(cpu_avg[itmp],per_state,sizeof(time_t) * 5);
- X cpu_avg_init = 1;
- X }
- X else
- X {
- X for(itmp = 0; itmp < CPU_AVG_MAX - 1; itmp++)
- X (void)memcpy(cpu_avg[itmp],cpu_avg[itmp + 1],sizeof(time_t) * 5);
- X (void)memcpy(cpu_avg[itmp],per_state,sizeof(time_t) * 5);
- X }
- X
- X} /* end of calc_cpu_avg */
- X
- X/*+-------------------------------------------------------------------------
- X get_cpu_avg(cpu_ticks,period)
- X--------------------------------------------------------------------------*/
- Xget_cpu_avg(cpu_ticks,period)
- Xtime_t cpu_ticks[];
- Xint period;
- X{
- Xregister iperiod = CPU_AVG_MAX;
- Xregister istate;
- Xregister count = period;
- X
- X for(istate = 0; istate < 5; istate++)
- X cpu_ticks[istate] = 0;
- X
- X while(count--)
- X {
- X iperiod--;
- X for(istate = 0; istate < 5; istate++)
- X cpu_ticks[istate] += (cpu_avg[iperiod])[istate];
- X }
- X
- X for(istate = 0; istate < 5; istate++)
- X cpu_ticks[istate] /= period;
- X
- X} /* end of get_cpu_avg */
- X
- X/*+-------------------------------------------------------------------------
- X calc_wait_avg(per_state) - add per_state array to avg array
- X--------------------------------------------------------------------------*/
- Xvoid
- Xcalc_wait_avg(per_state)
- Xtime_t per_state[];
- X{
- Xregister itmp;
- X
- X if(!wait_avg_init)
- X {
- X for(itmp = 0; itmp < WAIT_AVG_MAX; itmp++)
- X (void)memcpy(wait_avg[itmp],per_state,sizeof(time_t) * 3);
- X wait_avg_init = 1;
- X }
- X else
- X {
- X for(itmp = 0; itmp < WAIT_AVG_MAX - 1; itmp++)
- X (void)memcpy(wait_avg[itmp],wait_avg[itmp + 1],sizeof(time_t) * 3);
- X (void)memcpy(wait_avg[itmp],per_state,sizeof(time_t) * 3);
- X }
- X
- X} /* end of calc_wait_avg */
- X
- X/*+-------------------------------------------------------------------------
- X get_wait_avg(wait_ticks,period)
- X--------------------------------------------------------------------------*/
- Xget_wait_avg(wait_ticks,period)
- Xtime_t wait_ticks[];
- Xint period;
- X{
- Xregister iperiod = WAIT_AVG_MAX;
- Xregister istate;
- Xregister count = period;
- X
- X for(istate = 0; istate < 3; istate++)
- X wait_ticks[istate] = 0;
- X
- X while(count--)
- X {
- X iperiod--;
- X for(istate = 0; istate < 3; istate++)
- X {
- X wait_ticks[istate] += (wait_avg[iperiod])[istate];
- X }
- X }
- X
- X for(istate = 0; istate < 3; istate++)
- X wait_ticks[istate] /= period;
- X
- X} /* end of get_wait_avg */
- X
- X/*+-------------------------------------------------------------------------
- X draw_lower_main_statics() - draw lower main static portion
- X--------------------------------------------------------------------------*/
- Xvoid
- Xdraw_lower_main_statics()
- X{
- X
- X draw_Var(Var_TLX,Var_TLY);
- X#if defined(HAS_BOOTINFO)
- X draw_Bootinfo(Bootinfo_TLX,Bootinfo_TLY);
- X#endif
- X draw_Tune(Tune_TLX,Tune_TLY);
- X} /* end of draw_lower_main_statics */
- X
- X/*+-------------------------------------------------------------------------
- X read_sysinfo_and_minfo() - rattle kmem for sysinfo/minfo data
- X--------------------------------------------------------------------------*/
- Xvoid
- Xread_sysinfo_and_minfo()
- X{
- X timeb_last_info_read = timeb_info_read;
- X (void)ftime(&timeb_info_read);
- X kread((caddr_t)&sysinfo,sysinfoaddr,sizeof(sysinfo));
- X kread((caddr_t)&minfo,minfoaddr,sizeof(minfo));
- X} /* end of read_sysinfo_and_minfo */
- X
- X/*+-------------------------------------------------------------------------
- X update_display(read_new_kernel_data) - update dynamic display
- X--------------------------------------------------------------------------*/
- Xvoid
- Xupdate_display(read_new_kernel_data)
- Xint read_new_kernel_data;
- X{
- Xint itmp;
- Xtime_t total_ticks;
- X
- X update_Tod();
- X
- X if(read_new_kernel_data)
- X {
- X ftime(&timeb_cycle_start);
- X StatPeriod_msec = delta_msec(timeb_info_read,timeb_last_info_read);
- X kread((caddr_t)&freemem,freememaddr,sizeof(freemem));
- X read_sysinfo_and_minfo();
- X
- X for (itmp = 0; itmp < 5; itmp++)
- X {
- X if(itmp != CPU_WAIT)
- X cpu_ticks[itmp] = sysidelta(cpu[itmp]);
- X }
- X cpu_ticks[CPU_WAIT] = 0;
- X for (itmp = 0; itmp < 3; itmp++)
- X cpu_ticks[CPU_WAIT] += (wait_ticks[itmp] = sysidelta(wait[itmp]));
- X }
- X
- X update_StatPeriod();
- X update_StatCycle();
- X
- X total_ticks = update_CpuScale(CpuScale_TLX,
- X CpuScale_TLY + (FHEIGHT * 1),cpu_ticks);
- X update_WaitScale(WaitScale_TLX,
- X WaitScale_TLY + (FHEIGHT * 1),wait_ticks,total_ticks);
- X
- X if(read_new_kernel_data)
- X {
- X calc_cpu_avg(cpu_ticks);
- X calc_wait_avg(wait_ticks);
- X }
- X
- X get_cpu_avg(cpu_ticks,5);
- X total_ticks = update_CpuScale(CpuScale_TLX,
- X CpuScale_TLY + (FHEIGHT * 2),cpu_ticks);
- X get_wait_avg(wait_ticks,5);
- X update_WaitScale(WaitScale_TLX,
- X WaitScale_TLY + (FHEIGHT * 2),wait_ticks,total_ticks);
- X
- X get_cpu_avg(cpu_ticks,10);
- X total_ticks = update_CpuScale(CpuScale_TLX,
- X CpuScale_TLY + (FHEIGHT * 3),cpu_ticks);
- X get_wait_avg(wait_ticks,10);
- X update_WaitScale(WaitScale_TLX,
- X WaitScale_TLY + (FHEIGHT * 3),wait_ticks,total_ticks);
- X
- X switch(current_display_mode)
- X {
- X case BUTTON_main:
- X update_Sysinfo();
- X draw_Proc(Proc_TLX,Proc_TLY,redrawing_entire_DrawArea);
- X break;
- X
- X case BUTTON_ps:
- X update_Sysinfo();
- X /* fall through */
- X
- X case BUTTON_Ps:
- X if(DrawAreaXYWH.height < (ps_y + (FHEIGHT * 2)))
- X {
- X if(ps_y != PS_X_TOO_BIG)
- X {
- X turn_on_MyButton(current_display_mode,colorYellow.pixel);
- X disp_msg(colorOrange.pixel,make_taller_to_restore_Ps);
- X ps_y = PS_X_TOO_BIG;
- X }
- X fresh_Ps_paint = 1;
- X break;
- X }
- X if(fresh_Ps_paint)
- X turn_on_MyButton(current_display_mode,colorCyan.pixel);
- X draw_Ps(ps_x,ps_y,ps_procs_to_display,fresh_Ps_paint);
- X fresh_Ps_paint = 0;
- X break;
- X }
- X redrawing_entire_DrawArea = 0;
- X
- X sysinfo_last = sysinfo;
- X minfo_last = minfo;
- X
- X} /* end of update_display */
- X
- X/*+-------------------------------------------------------------------------
- X set_display_mode(new_mode) - select main/ps/Ps
- XThis krock betrays the Kludgosity of Affairs
- X--------------------------------------------------------------------------*/
- Xvoid
- Xset_display_mode(new_mode)
- Xint new_mode;
- X{
- Xvoid expose_callback();
- Xint old_display_mode = current_display_mode;
- Xint clear_y = -1;
- X
- X if(new_mode == BUTTON_quit)
- X quit_now();
- X
- X if(current_display_mode == new_mode)
- X return;
- X
- X switch(old_display_mode)
- X {
- X case BUTTON_main:
- X ps_procs_to_display = 0;
- X switch(new_mode)
- X {
- X case BUTTON_ps:
- X draw_Ps_stop_work_proc();
- X clear_y = ps_y = EXTRA_TLY;
- X break;
- X case BUTTON_Ps:
- X draw_Ps_stop_work_proc();
- X clear_y = Sysinfo_TLY;
- X break;
- X }
- X if(DrawAreaXYWH.height < (clear_y + (FHEIGHT * 3)))
- X {
- X disp_msg(colorRed.pixel,make_taller_for_Ps);
- X return;
- X }
- X ps_y = clear_y;
- X ps_x = 0;
- X ps_procs_to_display = (DrawAreaXYWH.height - ps_y) / FHEIGHT;
- X fresh_Ps_paint = 1;
- X break;
- X
- X case BUTTON_ps:
- X draw_Ps_stop_work_proc();
- X switch(new_mode)
- X {
- X case BUTTON_main:
- X clear_y = EXTRA_TLY;
- X break;
- X case BUTTON_Ps:
- X clear_y = Sysinfo_TLY;
- X ps_y = clear_y;
- X fresh_Ps_paint = 1;
- X if(DrawAreaXYWH.height < (ps_y + (FHEIGHT * 2)))
- X {
- X current_display_mode = new_mode;
- X turn_off_MyButton(old_display_mode);
- X turn_on_MyButton(current_display_mode,
- X colorOrange.pixel);
- X disp_msg(colorOrange.pixel,make_taller_to_restore_Ps);
- X ps_y = PS_X_TOO_BIG;
- X return;
- X }
- X break;
- X }
- X break;
- X
- X case BUTTON_Ps:
- X draw_Ps_stop_work_proc();
- X clear_y = Sysinfo_TLY;
- X switch(new_mode)
- X {
- X case BUTTON_main:
- X clear_y = Sysinfo_TLY;
- X break;
- X case BUTTON_ps:
- X ps_y = EXTRA_TLY;
- X fresh_Ps_paint = 1;
- X if(DrawAreaXYWH.height < (ps_y + (FHEIGHT * 2)))
- X {
- X current_display_mode = new_mode;
- X turn_off_MyButton(old_display_mode);
- X turn_on_MyButton(current_display_mode,
- X colorOrange.pixel);
- X disp_msg(colorOrange.pixel,make_taller_to_restore_Ps);
- X ps_y = PS_X_TOO_BIG;
- X if(clear_y < DrawAreaXYWH.height)
- X {
- X XClearArea(display,window,0,clear_y,
- X DrawAreaXYWH.width,
- X DrawAreaXYWH.height - clear_y,0);
- X draw_Sysinfo_literals(Sysinfo_TLX,Sysinfo_TLY);
- X redrawing_entire_DrawArea = 1;
- X }
- X return;
- X }
- X break;
- X }
- X break;
- X }
- X
- X current_display_mode = new_mode;
- X disp_msg(background,"");
- X if((clear_y > 0) && (clear_y < DrawAreaXYWH.height))
- X {
- X XClearArea(display,window,0,clear_y,
- X DrawAreaXYWH.width,DrawAreaXYWH.height - clear_y,0);
- X expose_callback(DrawAreaW,(caddr_t)0,(caddr_t)0);
- X }
- X else
- X {
- X turn_off_MyButton(old_display_mode);
- X turn_on_MyButton(current_display_mode,colorCyan.pixel);
- X }
- X
- X} /* end of set_display_mode */
- X
- X/*+-------------------------------------------------------------------------
- X draw_display() - draw display literals
- X--------------------------------------------------------------------------*/
- Xvoid
- Xdraw_display()
- X{
- Xchar *cptr;
- X
- X place_MyButtons_all_off();
- X turn_on_MyButton(current_display_mode,colorCyan.pixel);
- X disp_msg(colorBlack.pixel,"");
- X
- X XClearArea(display,window,
- X DispMsg_tlx,0,DrawAreaXYWH.width - DispMsg_tlx,FHEIGHT,0);
- X#ifdef LABELLED_STAT_TIMES
- X cptr = "sleep:";
- X XSetForeground(display,gc,colorBlue.pixel);
- X XDrawString(display,window,gc,
- X StatCycleL_TLX,StatCycleL_TLY + FASCENT,cptr,strlen(cptr));
- X cptr = "last:";
- X XDrawString(display,window,gc,
- X StatPeriodL_TLX,StatPeriodL_TLY + FASCENT,cptr,strlen(cptr));
- X#endif
- X
- X draw_CpuScale_literals(CpuScale_TLX,CpuScale_TLY);
- X draw_WaitScale_literals(WaitScale_TLX,WaitScale_TLY);
- X
- X ps_y = PS_X_TOO_BIG; /* shud be MAXPOS or something */
- X ps_procs_to_display = 0;
- X
- X switch(current_display_mode)
- X {
- X case BUTTON_main:
- X draw_Sysinfo_literals(Sysinfo_TLX,Sysinfo_TLY);
- X draw_lower_main_statics();
- X break;
- X
- X case BUTTON_ps:
- X draw_Sysinfo_literals(Sysinfo_TLX,Sysinfo_TLY);
- X ps_y = EXTRA_TLY;
- X ps_x = 0;
- X fresh_Ps_paint = 1;
- X break;
- X
- X case BUTTON_Ps:
- X ps_y = Sysinfo_TLY;
- X ps_x = 0;
- X fresh_Ps_paint = 1;
- X break;
- X }
- X
- X if(DrawAreaXYWH.height > (ps_y + (FHEIGHT * 2)))
- X {
- X ps_procs_to_display = (DrawAreaXYWH.height - ps_y) / FHEIGHT;
- X draw_Ps(ps_x,ps_y,ps_procs_to_display,fresh_Ps_paint);
- X fresh_Ps_paint = 0;
- X }
- X
- X} /* end of draw_display */
- X
- X/*+-------------------------------------------------------------------------
- X update_timer_proc(client_data) - "callback" for application timeout
- X--------------------------------------------------------------------------*/
- Xvoid
- Xupdate_timer_proc(client_data)
- Xcaddr_t client_data;
- X{
- Xvoid set_update_timer();
- X
- X update_timer_ID = (XtIntervalId)0;
- X if(!ps_WorkProc_ID)
- X {
- X update_display(1);
- X if(!ps_WorkProc_ID)
- X set_update_timer();
- X }
- X
- X} /* end of update_timer_proc */
- X
- X/*+-------------------------------------------------------------------------
- X set_update_timer() - start application timeout for display cycle
- X--------------------------------------------------------------------------*/
- Xvoid
- Xset_update_timer()
- X{
- X update_timer_ID = XtAddTimeOut(StatCycle_msec,update_timer_proc,
- X (caddr_t)0);
- X} /* end of set_update_timer */
- X
- X/*+-------------------------------------------------------------------------
- X expose_callback(widget,client_data,call_data)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xexpose_callback(widget,client_data,call_data)
- XWidget widget;
- Xcaddr_t client_data;
- XXmDrawingAreaCallbackStruct *call_data;
- X{
- XXExposeEvent *event = (XExposeEvent *)0;
- Xstatic int first_expose = 1;
- X
- X if(!XtIsRealized(widget))
- X return;
- X if(call_data)
- X event = (XExposeEvent *)call_data->event;
- X if(event && (event->count != 0))
- X return;
- X
- X XGetWindowAttributes(display,window,&DrawAreaXYWH);
- X
- X choose_MyFont();
- X
- X draw_Ps_stop_work_proc();
- X redrawing_entire_DrawArea = 1;
- X draw_display();
- X update_display(1);
- X redrawing_entire_DrawArea = 0;
- X if(first_expose)
- X set_update_timer();
- X first_expose = 0;
- X
- X} /* end of expose_callback */
- X
- X/*+-------------------------------------------------------------------------
- X resize_callback(widget,client_data,call_data)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xresize_callback(widget,client_data,call_data)
- XWidget widget;
- Xcaddr_t client_data;
- XXmDrawingAreaCallbackStruct *call_data;
- X{
- X
- X XGetWindowAttributes(display,window,&DrawAreaXYWH);
- X invalidate_last_DispMsg();
- X
- X} /* end of resize_callback */
- X
- X/*+-------------------------------------------------------------------------
- X quit_now() - good bye
- X--------------------------------------------------------------------------*/
- Xvoid
- Xquit_now()
- X{
- X turn_off_all_MyButtons();
- X turn_on_MyButton(BUTTON_quit,colorRed.pixel);
- X XSync(display,False);
- X sleep(1);
- X leave(0);
- X} /* end of quit_now */
- X
- X/*+-------------------------------------------------------------------------
- X delta_StatCycle(delta_msec) - user has changed display cycle period
- X--------------------------------------------------------------------------*/
- Xvoid
- Xdelta_StatCycle(delta_msec)
- Xunsigned long delta_msec;
- X{
- Xunsigned long new_msec = StatCycle_msec + delta_msec;
- X
- X if((new_msec < StatCycle_msecMin) || (new_msec > StatCycle_msecMax))
- X {
- X fputc(7,stderr);
- X return;
- X }
- X StatCycle_msec = new_msec;
- X update_StatCycle();
- X draw_CpuScale_literals(CpuScale_TLX,CpuScale_TLY);
- X draw_WaitScale_literals(WaitScale_TLX,WaitScale_TLY);
- X
- X} /* end of delta_StatCycle */
- X
- X/*+-------------------------------------------------------------------------
- X input_callback_key_event(widget,client_data,call_data)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xinput_callback_key_event(widget,client_data,call_data)
- XWidget widget;
- Xcaddr_t client_data;
- XXmDrawingAreaCallbackStruct *call_data;
- X{
- XXKeyEvent *event = (XKeyEvent *)(call_data->event);
- Xint numkeys;
- XKeySym keysym;
- Xunsigned char kbuf[8];
- X
- X numkeys = XLookupString(event,kbuf,sizeof(kbuf),
- X &keysym,(XComposeStatus *)0);
- X
- X if((event->type == KeyPress) && (numkeys == 1))
- X {
- X switch(kbuf[0])
- X {
- X case 'm': set_display_mode(BUTTON_main); break;
- X case 'p': set_display_mode(BUTTON_ps); break;
- X case 'P': set_display_mode(BUTTON_Ps); break;
- X case '+': delta_StatCycle(+1000L); break;
- X case '-': delta_StatCycle(-1000L); break;
- X case 'q': quit_now();
- X /*NOTREACHED*/
- X default: fputs("\7",stderr); /* Ackkkkk -- lazy */
- X }
- X }
- X
- X} /* end of input_callback_key_event */
- X
- X/*+-------------------------------------------------------------------------
- X input_callback(widget,client_data,call_data)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xinput_callback(widget,client_data,call_data)
- XWidget widget;
- Xcaddr_t client_data;
- XXmDrawingAreaCallbackStruct *call_data;
- X{
- X
- X switch (call_data->event->type)
- X {
- X case KeyPress:
- X case KeyRelease:
- X input_callback_key_event(widget,client_data,call_data);
- X break;
- X }
- X
- X} /* end of input_callback */
- X
- X/*+-------------------------------------------------------------------------
- X entry_callback(widget,client_data,call_data)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xentry_callback(widget,client_data,call_data)
- XWidget widget;
- Xcaddr_t client_data;
- XXmDrawingAreaCallbackStruct *call_data;
- X{
- X
- X/*
- X switch(call_data->event->type)
- X {
- X default:
- X return;
- X }
- X*/
- Xprintf("entry callback evtype=%d\n",call_data->event->type);
- X
- X} /* end of entry_callback */
- X
- X/*+-------------------------------------------------------------------------
- X main(argc,argv)
- X--------------------------------------------------------------------------*/
- Xmain(argc,argv)
- Xint argc;
- Xchar **argv;
- X{
- Xint itmp;
- Xchar *cptr;
- Xint plock_indicator = 0;
- XArg args[32];
- Xint argcount;
- XPosition x = 0;
- XPosition y = 0;
- XDimension width = DrawArea_DEFAULT_WIDTH;
- XDimension height = DrawArea_DEFAULT_HEIGHT;
- Xchar *progname = strdup(basename(argv[0]));
- Xchar *basename();
- X
- X/*
- X * set default geometry
- X */
- X sprintf(preferred_geom,"%dx%d-0-0",width,height);
- X
- X/*
- X * if man wants to plock() try it; fail silently if non-root
- X */
- X if(plock_indicator && plock(PROCLOCK))
- X {
- X nice(-5);
- X plock_indicator = 0;
- X }
- X
- X/*
- X * Real(tm) performance watcher users will have done a kernel link
- X * and won't need to rely on /etc/systemid
- X */
- X if(uname(&utsname))
- X {
- X leave_text("uname failed",255);
- X exit(1);
- X }
- X
- X/*
- X * allocate memory for cpu time array averaging buckets
- X */
- X for(itmp = 0; itmp < CPU_AVG_MAX; itmp++)
- X {
- X if(!(cpu_avg[itmp] = (time_t *)malloc(sizeof(time_t) * 5)))
- X leave_text("cannot alloc memory for cpu avg arrays",1);
- X }
- X
- X/*
- X * allocate memory for wait time array averaging buckets
- X */
- X for(itmp = 0; itmp < WAIT_AVG_MAX; itmp++)
- X {
- X if(!(wait_avg[itmp] = (time_t *)malloc(sizeof(time_t) * 3)))
- X leave_text("cannot alloc memory for wait avg arrays",1);
- X }
- X
- X/*
- X * read nlist symbols, open /dev/kmem, /dev/mem, /dev/swap,
- X * initialize detail environment
- X * drop euid and egid (after opening privileged mem/devices)
- X * initialize process status uid->name hasher
- X */
- X nlsym_read();
- X kinit(0); /* /dev/kmem, read access only */
- X minit(0); /* /dev/mem, read access only */
- X sinit(); /* /dev/swap, only read access available */
- X (void)setuid(getuid()); /* some people run us setuid, so clen that up */
- X (void)setgid(getgid()); /* now that we have the fds open, drop egid */
- X
- X/*
- X * make initial kmem readings
- X */
- X hz = (cptr = getenv("HZ")) ? atoi(cptr) : HZ;
- X kread((caddr_t)&maxmem,maxmemaddr,sizeof(maxmem));
- X kread((caddr_t)&tune,tuneaddr,sizeof(tune));
- X kread((caddr_t)&v,vaddr,sizeof(v));
- X
- X kread((caddr_t)&nswap,nswapaddr,sizeof(nswap));
- X itmp = -1;
- X#if defined(S3BSWPI) /* 68000 handled here, not AT&T 3B */
- X itmp = _sysm68k (S3BSWPI,&swapint); /* per nba@sysware.sysware.dk */
- X#endif
- X#if defined(SI86SWPI)
- X itmp = sysi86(SI86SWPI,&swapint);
- X#endif
- X#if defined(SMIPSSWPI)
- X itmp = sysmips(SMIPSSWPI,&swapint);
- X#endif
- X if(!itmp)
- X {
- X nswap = 0;
- X for (itmp = 0; itmp < MSFILES; itmp++)
- X nswap += swaptab[itmp].st_npgs * NBPP / NBPSCTR;
- X }
- X
- X#if defined(HAS_BOOTINFO)
- X kread((caddr_t)&bootinfo,bootinfoaddr,sizeof(bootinfo));
- X#endif
- X read_sysinfo_and_minfo();
- X sysinfo_last = sysinfo;
- X minfo_last = minfo;
- X timeb_last_info_read = timeb_info_read;
- X
- X/*
- X * XForeplay
- X */
- X
- X /*
- X * initialize
- X */
- X AppShellW = XtInitialize("x386mon","X386mon",
- X optionDescList, XtNumber(optionDescList), &argc, argv);
- X
- X XtGetApplicationResources(AppShellW,&res,
- X appResources,XtNumber(appResources),NULL,0);
- X
- X appcon = XtWidgetToApplicationContext(AppShellW);
- X display = XtDisplay(AppShellW);
- X screen = DefaultScreen(display);
- X cmap = DefaultColormap(display,screen);
- X gc = DefaultGC(display,screen);
- X display_width = XDisplayWidth(display,screen);
- X display_height = XDisplayHeight(display,screen);
- X
- X itmp = XParseGeometry(res.geometry,
- X &x,&y,&width,&height);
- X /*
- X * Adjust user request to limits
- X */
- X
- X if(width < DrawArea_MIN_WIDTH)
- X width = DrawArea_MIN_WIDTH;
- X else if (width > display_width)
- X width = display_width;
- X
- X if(height < DrawArea_MIN_HEIGHT)
- X height = DrawArea_MIN_HEIGHT;
- X else if (height > display_height)
- X height = display_height;
- X
- X /*
- X * Create the drawing area widget (DrawAreaW)
- X */
- X
- X init_MyFonts();
- X init_color();
- X
- X argcount = 0;
- X XtSetArg(args[argcount],XmNforeground,(XtArgVal)foreground);
- X argcount++;
- X XtSetArg(args[argcount],XmNbackground,(XtArgVal)background);
- X argcount++;
- X XtSetArg(args[argcount],XmNwidth,(XtArgVal)width);
- X argcount++;
- X XtSetArg(args[argcount],XmNheight,(XtArgVal)height);
- X argcount++;
- X XtSetArg(args[argcount],XmNmarginWidth,(XtArgVal)0);
- X argcount++;
- X XtSetArg(args[argcount],XmNmarginHeight,(XtArgVal)0);
- X argcount++;
- X XtSetArg(args[argcount],XmNresizePolicy,(XtArgVal)XmRESIZE_NONE);
- X argcount++;
- X
- X DrawAreaW = XmCreateDrawingArea(AppShellW,"x386mon-draw",
- X args,(Cardinal)argcount);
- X XtManageChild(DrawAreaW);
- X
- X /*
- X * Toolkit phone home
- X */
- X
- X XtAddCallback(DrawAreaW,XmNexposeCallback,expose_callback,(caddr_t)0);
- X XtAddCallback(DrawAreaW,XmNresizeCallback,resize_callback,(caddr_t)1);
- X XtAddCallback(DrawAreaW,XmNinputCallback,input_callback,(caddr_t)0);
- X
- X /*
- X * set title
- X */
- X
- X sprintf(DrawArea_title,
- X "x386mon %s (%s) '+'/'-' change interval wht@n4hgf",
- X revision,utsname.nodename);
- X XtSetArg(args[0],XtNtitle,DrawArea_title);
- X XtSetValues(AppShellW,args,1);
- X
- X /*
- X * BlapBlit - disturb display
- X */
- X
- X XtRealizeWidget(AppShellW);
- X
- X /*
- X * set up for simple XLib calls for the duration
- X */
- X
- X window = XtWindow(DrawAreaW);
- X XGetWindowAttributes(display,window,&DrawAreaXYWH);
- X
- X/*
- X * nlsym read, first sysinfo/minfo/other-structs read
- X * and X started: init Proc and Ps "objects"
- X */
- X initialize_Proc();
- X initialize_Ps();
- X
- X/*
- X * main loop
- X */
- X XSynchronize(display,0); /* <<<<<<<============== */
- X current_display_mode = BUTTON_main;
- X
- X XtMainLoop();
- X /*NOTREACHED*/
- X
- X} /* end of main */
- X
- X/* vi: set tabstop=4 shiftwidth=4: */
- X/* end of x386mon.c */
- SHAR_EOF
- chmod 0644 x386mon/x386mon.c ||
- echo 'restore of x386mon/x386mon.c failed'
- Wc_c="`wc -c < 'x386mon/x386mon.c'`"
- test 30634 -eq "$Wc_c" ||
- echo 'x386mon/x386mon.c: original size 30634, current size' "$Wc_c"
- fi
- true || echo 'restore of x386mon/x386mon.h failed'
- echo End of part 5, continue with part 6
- exit 0
-
- -----------------------------------------------------------------------
- Warren Tucker, TuckerWare gatech!n4hgf!wht or wht@n4hgf.Mt-Park.GA.US
- Many [Nobel physics] prizes have been given to people for telling us
- the universe is not as simple as we thought it was. -Stephen Hawking in
- A Brief History of Time In computing, there are no such prizes. -me
-