home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2773 < prev    next >
Encoding:
Internet Message Format  |  1991-02-17  |  48.2 KB

  1. From: wht@n4hgf.Mt-Park.GA.US (Warren Tucker)
  2. Newsgroups: alt.sources
  3. Subject: X386MON part 04/06
  4. Message-ID: <324@n4hgf.Mt-Park.GA.US>
  5. Date: 16 Feb 91 19:35:17 GMT
  6.  
  7. Submitted-by: wht@n4hgf
  8. Archive-name: x386monx100/part04
  9.  
  10. #!/bin/sh
  11. # This is part 04 of x386monx100
  12. # ============= x386mon/ps.c ==============
  13. if test ! -d 'x386mon'; then
  14.     echo 'x - creating directory x386mon'
  15.     mkdir 'x386mon'
  16. fi
  17. if test -f 'x386mon/ps.c' -a X"$1" != X"-c"; then
  18.     echo 'x - skipping x386mon/ps.c (File already exists)'
  19. else
  20. echo 'x - extracting x386mon/ps.c (Text)'
  21. sed 's/^X//' << 'SHAR_EOF' > 'x386mon/ps.c' &&
  22. X/*+-------------------------------------------------------------------------
  23. X    ps.c - X386MON proc status detail
  24. X    wht@n4hgf.Mt-Park.GA.US
  25. X
  26. X  Defined functions:
  27. X    display_proc_stat(x,y,iproc,initial)
  28. X    draw_Ps(x,y,ps_procs_to_disp,initial)
  29. X    draw_Ps_work_proc(client_data)
  30. X    find_utmp_for_pgrp(pgrp)
  31. X    get_cpu_time_str(ticks)
  32. X    get_user(tproc,tuser)
  33. X    getpwent_and_enter(uid)
  34. X    init_uid_name_hash()
  35. X    initialize_Ps()
  36. X    pgrp_to_ttyname(pgrp)
  37. X    ppproc_pid_compare(ppp1,ppp2)
  38. X    read_and_sort_procs(initial)
  39. X    read_utmp()
  40. X    strcmp(cptr,)
  41. X    strindex(s1,s2)
  42. X    uid_name_enter(uid,name)
  43. X    uid_to_name(uid)
  44. X
  45. Xprocess size: There are ways that seem right to a man, but the
  46. Xend of them is death.  u_tsize and friends are not clicks, but in
  47. Xbytes.  I thought this would have been:
  48. X(ctob((u_long)user.u_tsize + user.u_dsize + user.u_ssize)) /
  49. X1024); At least this makes numbers agree with /bin/ps, although I
  50. Xcannot figure out why there is one extra page charged by ps (user
  51. Xis 2 pages).  This was evidentally wrong in SCO UNIX 3.2.0 and
  52. Xfixed in 3.2.1.  If you get lots of processes who size is
  53. X
  54. XFor ISC: p->p_size
  55. XReports exactly the same value as ps.  The values in the user
  56. Xarea seem totally bogus (u_tsize is always 0, from observation)
  57. Xso this size, the program swap size, seems the best measure.
  58. XWithout USIZE_FIXED, on ISC2.02/Dell UNIX 1.1 I get zeroes.
  59. XWith USIZE_FIXED I get values, but they're way out (e.g. vpix
  60. Xand cron shown as the same size....).
  61. X--------------------------------------------------------------------------*/
  62. X/*+:EDITS:*/
  63. X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */
  64. X
  65. X#include <sys/types.h>
  66. X#include <nlist.h>
  67. X#include <pwd.h>
  68. X#include <utmp.h>
  69. X#include <sys/param.h>
  70. X#include <sys/tuneable.h>
  71. X#include <sys/sysinfo.h>
  72. X#include <sys/sysmacros.h>
  73. X#include <sys/immu.h>
  74. X#include <sys/region.h>
  75. X#if defined(mips)
  76. X#define pg_pres pg_sv /* alias: MIPS pg_sv==page valid */
  77. X#include <sys/sbd.h>
  78. X#include <sys/pcb.h>
  79. X#endif
  80. X#include <sys/proc.h>
  81. X#include <sys/fs/s5dir.h>
  82. X#include <sys/user.h>
  83. X#include <sys/var.h>
  84. X#if defined(M_UNIX) && (defined(i386) || defined(i486)) && SYSI86_RDUBLK_WANTED
  85. X/* maybe someday, but not now: seems buggy */
  86. X# include <sys/sysi86.h>
  87. X#endif
  88. X#include "x386mon.h"
  89. X#include "buttons.h"
  90. X#include "utoa.h"
  91. X#include "nlsym.h"
  92. X#include "libkmem.h"
  93. X#include "libmem.h"
  94. X#include "libswap.h"
  95. X#include "libnlsym.h"
  96. X
  97. X#define min(a,b) (((a) > (b)) ? (b) : (a))
  98. X
  99. Xextern int errno;
  100. Xextern int nprocs;
  101. Xextern struct var v;
  102. Xextern struct proc *procs;
  103. Xextern struct proc *oldprocs;
  104. Xextern struct proc **pprocs;
  105. Xextern struct proc **poldprocs;
  106. Xextern XtIntervalId update_timer_ID;
  107. X
  108. Xint mypid;
  109. Xint noldprocs = 0;
  110. Xint nprocs = 0;
  111. Xstruct user user;
  112. X
  113. XXtWorkProcId ps_WorkProc_ID = (XtWorkProcId)0;
  114. X
  115. X#define MAX_UTMP 128
  116. Xint nutmps = 0;
  117. Xstruct utmp utmps[MAX_UTMP];
  118. X
  119. Xstatic int max_procs_to_display;
  120. Xstatic int next_proc_to_display;
  121. Xstatic int next_proc_x;
  122. Xstatic int next_proc_y;
  123. Xstatic int next_proc_initial;
  124. X
  125. Xstatic int line_style = LineSolid;
  126. Xstatic int cap_style = CapButt;
  127. Xstatic int join_style = JoinMiter;
  128. X
  129. X/*--> to keep from having to get the user structure twice,
  130. X *--> we copy some stuff out of it into unimportant proc areas
  131. X *--> using these kludge redefines to keep track
  132. X *--> (also, under SCO p_size is updated from u_{t,d,s}size;
  133. X *--> others seem to keep this value in p_size already)
  134. X */
  135. X#define p_GOT_USER    p_cursig        /* true if was able to otain user struct,
  136. X                                     * thus making the remainder of this valid
  137. X                                     */
  138. X#define p_U_PSARGS    p_sigflags        /* u_psargs copy in int[MAXSIG] array */
  139. X#define U_PSARGS_MAX (sizeof(int) * MAXSIG)
  140. X#define p_U_STIME    p_stime            /* u_stime copy */
  141. X#define p_U_UTIME    p_utime            /* u_utime copy */
  142. X#define p_PIXEL        p_sigmask        /* we need to remember the color
  143. X                                     * of the last draw
  144. X                                     */
  145. X
  146. X/*+-------------------------------------------------------------------------
  147. X    strindex(s1,s2)
  148. Xif s2 occurs in s1, return a pointer to the match in s1, else null
  149. X--------------------------------------------------------------------------*/
  150. X#ifdef NEED_STRINDEX
  151. Xchar *
  152. Xstrindex(s1,s2)
  153. Xregister char *s1;
  154. Xregister char *s2;
  155. X{
  156. X    register int l1 = strlen (s1);
  157. X    register int l2 = strlen (s2);
  158. X
  159. X    for(; l1 >= l2; l1--, s1++)
  160. X    {
  161. X        if(!strcmp(s1,s2,l2))
  162. X            return(s1);
  163. X    }
  164. X    return ((char *)0);
  165. X}    /* end of strindex  */
  166. X#endif /* NEED_STRINDEX */
  167. X
  168. X/*+-------------------------------------------------------------------------
  169. X    ppproc_pid_compare(ppp1,ppp2)
  170. X--------------------------------------------------------------------------*/
  171. Xppproc_pid_compare(ppp1,ppp2)
  172. Xregister struct proc **ppp1;
  173. Xregister struct proc **ppp2;
  174. X{
  175. X    return((*ppp1)->p_pid - (*ppp2)->p_pid);
  176. X}    /* end of ppproc_pid_compare */
  177. X
  178. X/*+-------------------------------------------------------------------------
  179. X    read_and_sort_procs(initial)
  180. X--------------------------------------------------------------------------*/
  181. Xvoid
  182. Xread_and_sort_procs(initial)
  183. Xint initial;
  184. X{
  185. Xint iproc;
  186. Xregister char *cptr;
  187. Xregister struct proc *tproc;
  188. Xint omitted_one;
  189. Xchar omitted[80];
  190. X
  191. X    omitted[0] = 0;
  192. X    if(!initial)
  193. X    {
  194. X        cptr = (char *)oldprocs;
  195. X        oldprocs = procs;
  196. X        procs = (struct proc *)cptr;
  197. X        noldprocs = nprocs;
  198. X        cptr = (char *)poldprocs;
  199. X        poldprocs = pprocs;
  200. X        pprocs = (struct proc **)cptr;
  201. X
  202. X#ifdef OLD
  203. X        (void)memcpy((char *)oldprocs,(char *)procs,
  204. X            v.v_proc * sizeof(struct proc));
  205. X        noldprocs = nprocs;
  206. X        (void)memcpy((char *)poldprocs,(char *)pprocs,
  207. X            noldprocs * sizeof(struct proc *));
  208. X#endif
  209. X    }
  210. X
  211. X/* read current procs */
  212. X    grok_proc();
  213. X
  214. X/* if slot not in use, force to end when sorting */
  215. X    nprocs = 0;
  216. X    for(iproc = 0; iproc < v.v_proc; iproc++)
  217. X    {
  218. X        tproc = pprocs[iproc];
  219. X        if(    (tproc->p_stat == 0) ||        /* if slot not in use, ... */
  220. X            (tproc->p_pid == 1)  ||        /* ... or proc is init, ... */
  221. X            (tproc->p_flag & SSYS))        /* ... or proc is system process */
  222. X        {                            /* eliminate from consideration */
  223. X            tproc->p_pid = 32767;    /* force below selected procs in qsort */
  224. X            continue;
  225. X        }
  226. X        nprocs++;
  227. X    }
  228. X
  229. X/* if too many procs, whittle zombies */
  230. X    if(nprocs > max_procs_to_display)
  231. X    {
  232. X        nprocs = 0;
  233. X        omitted_one = 0;
  234. X        for(iproc = 0; iproc < v.v_proc; iproc++)
  235. X        {
  236. X            tproc = pprocs[iproc];
  237. X            if(tproc->p_pid == 32767)    /* previously eliminated? */
  238. X                continue;
  239. X            else if(tproc->p_stat == SZOMB)
  240. X            {
  241. X                tproc->p_pid = 32767;
  242. X                omitted_one = 1;
  243. X                continue;
  244. X            }
  245. X            nprocs++;
  246. X        }
  247. X        if(omitted_one)
  248. X        {
  249. X            if(omitted[0])
  250. X                strcat(omitted,"/");
  251. X            strcat(omitted,"zombie");
  252. X        }
  253. X    }
  254. X
  255. X/* if still too many procs, whittle shells and gettys */
  256. X    if(nprocs > max_procs_to_display)
  257. X    {
  258. X        nprocs = 0;
  259. X        omitted_one = 0;
  260. X        for(iproc = 0; iproc < v.v_proc; iproc++)
  261. X        {
  262. X            tproc = pprocs[iproc];
  263. X            if(tproc->p_pid == 32767)    /* previously eliminated? */
  264. X                continue;
  265. X            else if(tproc->p_GOT_USER = get_user(tproc,&user))
  266. X            {
  267. X                cptr = user.u_comm;
  268. X                if( !strcmp(cptr,"ksh")        ||
  269. X                    !strcmp(cptr,"csh")        ||
  270. X                    !strcmp(cptr,"sh")        ||
  271. X                    !strcmp(cptr,"getty")    ||
  272. X                    !strcmp(cptr,"uugetty")    ||
  273. X                    !strcmp(cptr,"cron")    ||
  274. X                    !strcmp(cptr,"errdemon")||
  275. X                    !strcmp(cptr,"lpsched")    ||
  276. X                    !strcmp(cptr,"logger")    ||
  277. X#if defined(HAVE_NETWORKING)
  278. X                    !strcmp(cptr,"biod")    ||
  279. X                    !strcmp(cptr,"nfsd")    ||
  280. X                    !strcmp(cptr,"rwhod")    ||
  281. X                    !strcmp(cptr,"inetd")    ||
  282. X                    !strcmp(cptr,"portmap")    ||
  283. X                    !strcmp(cptr,"rlogin")    ||
  284. X                    !strcmp(cptr,"fingerd")    ||
  285. X                    !strcmp(cptr,"configd")    ||
  286. X#endif /* HAVE_NETWORKING */
  287. X#if defined(mips)
  288. X                    !strcmp(cptr,"midas")    ||
  289. X                    !strcmp(cptr,"mirerr")    ||
  290. X                    !strcmp(cptr,"errhand")    ||
  291. X                    !strcmp(cptr,"syslogd")    ||
  292. X                    !strcmp(cptr,"sssmd")    ||
  293. X#endif /* mips */
  294. X                    !strcmp(cptr,"bash")
  295. X                   )
  296. X                {
  297. X                    tproc->p_pid = 32767;
  298. X                    omitted_one = 1;
  299. X                    continue;
  300. X                }
  301. X                /* save stuff out of user in unimportant proc areas */
  302. X                tproc->p_U_UTIME = user.u_utime;
  303. X                tproc->p_U_STIME = user.u_stime;
  304. X                strncpy((char *)tproc->p_U_PSARGS,user.u_psargs,U_PSARGS_MAX);
  305. X                *((char *)tproc->p_U_PSARGS + U_PSARGS_MAX - 1) = 0;
  306. X#if defined(M_UNIX)             /* SCO */
  307. X#if defined(SCO_USIZE_BROKEN)    /* SCO UNIX 3.2.0 */
  308. X                tproc->p_size = 
  309. X                    (((u_long)user.u_tsize + 511) / 1024) +
  310. X                    (((u_long)user.u_dsize + 511) / 1024) +
  311. X                    (((u_long)user.u_ssize + 511) / 1024) +
  312. X                    (((u_long)((user.u_tsize)?1:0) * NBPP) / 1024);
  313. X#else                            /* SCO UNIX 3.2.1 and presumably later */
  314. X                tproc->p_size = 
  315. X                    (ctob((u_long)user.u_tsize + user.u_dsize + user.u_ssize))
  316. X                    / 1024;
  317. X#endif
  318. X#endif /* SCO */
  319. X            }
  320. X            nprocs++;
  321. X        }
  322. X        if(omitted_one)
  323. X        {
  324. X            if(omitted[0])
  325. X                strcat(omitted,"/");
  326. X            strcat(omitted,"shell/getty/daemon");
  327. X        }
  328. X    }
  329. X
  330. X/* if still too many procs, whittle swapped */
  331. X    if(nprocs > max_procs_to_display)
  332. X    {
  333. X        nprocs = 0;
  334. X        omitted_one = 0;
  335. X        for(iproc = 0; iproc < v.v_proc; iproc++)
  336. X        {
  337. X            tproc = pprocs[iproc];
  338. X            if(tproc->p_pid == 32767)    /* previously eliminated? */
  339. X                continue;
  340. X            else if(!(tproc->p_flag & SLOAD) && (tproc->p_stat != SRUN))
  341. X            {
  342. X                tproc->p_pid = 32767;
  343. X                omitted_one = 1;
  344. X                continue;
  345. X            }
  346. X            nprocs++;
  347. X        }
  348. X        if(omitted_one)
  349. X        {
  350. X            if(omitted[0])
  351. X                strcat(omitted,"/");
  352. X            strcat(omitted,"swapped");
  353. X        }
  354. X    }
  355. X#if !defined(mips)    /************* temp mod ***************/
  356. X
  357. X/* if still too many procs, whittle hard */
  358. X    if(nprocs > max_procs_to_display)
  359. X    {
  360. X        nprocs = 0;
  361. X        omitted_one = 0;
  362. X        for(iproc = 0; iproc < v.v_proc; iproc++)
  363. X        {
  364. X            tproc = pprocs[iproc];
  365. X            if(tproc->p_pid == 32767)    /* previously eliminated? */
  366. X                continue;
  367. X            else if(tproc->p_stat == SSLEEP)
  368. X            {
  369. X                tproc->p_pid = 32767;
  370. X                omitted_one = 1;
  371. X                continue;
  372. X            }
  373. X            nprocs++;
  374. X        }
  375. X        if(omitted_one)
  376. X        {
  377. X            if(omitted[0])
  378. X                strcat(omitted,"/");
  379. X            strcat(omitted,"sleeping");
  380. X        }
  381. X    }
  382. X#endif
  383. X
  384. X/* if still too many procs, truncate */
  385. X    if(nprocs > max_procs_to_display)
  386. X    {
  387. X        nprocs = max_procs_to_display;
  388. X        disp_msg(colorCyan.pixel,"display size too small for all processes");
  389. X        omitted[0] = 0;
  390. X    }
  391. X    if(omitted[0])
  392. X    {
  393. X        strcat(omitted," procs omitted");
  394. X        disp_msg(colorCyan.pixel,omitted);
  395. X    }
  396. X    else
  397. X        disp_msg(background,"");
  398. X
  399. X/* sort new procs array */
  400. X    (void)qsort((char *)pprocs,(unsigned)v.v_proc,
  401. X        sizeof(struct proc *),ppproc_pid_compare);
  402. X
  403. X    if(initial)    /* need to memcpy here making old a copy of new */
  404. X    {
  405. X        (void)memcpy((char *)oldprocs,(char *)procs,
  406. X            v.v_proc * sizeof(struct proc));
  407. X        noldprocs = nprocs;
  408. X        (void)memcpy((char *)poldprocs,(char *)pprocs,
  409. X            noldprocs * sizeof(struct proc *));
  410. X    }
  411. X
  412. X}    /* end of read_and_sort_procs */
  413. X
  414. X/*+-------------------------------------------------------------------------
  415. X    read_utmp()
  416. X--------------------------------------------------------------------------*/
  417. Xvoid
  418. Xread_utmp()
  419. X{
  420. Xint utmpfd;
  421. Xregister struct utmp *tutmp = utmps;
  422. X
  423. X    nutmps = 0;
  424. X    if((utmpfd = open("/etc/utmp",O_RDONLY,755)) < 0)
  425. X        leave_text("/etc/utmp open error",255);
  426. X
  427. X    while(read(utmpfd,(char *)(tutmp++),sizeof(struct utmp)) > 0)
  428. X    {
  429. X        /* ensure null termination
  430. X         * (clobbers 1st byte of ut_line, but we don't use it)
  431. X         */
  432. X        tutmp->ut_id[sizeof(tutmp->ut_id)] = 0;
  433. X        if(++nutmps == MAX_UTMP)
  434. X            leave_text("too many utmp entries for me to handle",1);
  435. X    }
  436. X    (void)close(utmpfd);
  437. X}    /* end of read_utmp */
  438. X
  439. X/*+-------------------------------------------------------------------------
  440. X    find_utmp_for_pgrp(pgrp)
  441. X--------------------------------------------------------------------------*/
  442. Xstruct utmp *
  443. Xfind_utmp_for_pgrp(pgrp)
  444. Xint pgrp;
  445. X{
  446. Xstruct utmp *tutmp = utmps;
  447. Xregister int count = nutmps;
  448. X
  449. X    while(count--)
  450. X    {
  451. X        if(tutmp->ut_pid == pgrp)
  452. X            return(tutmp);
  453. X        tutmp++;
  454. X    }
  455. X    return((struct utmp *)0);
  456. X}    /* end of find_utmp_for_pgrp */
  457. X
  458. X/*+-------------------------------------------------------------------------
  459. X    pgrp_to_ttyname(pgrp)
  460. X--------------------------------------------------------------------------*/
  461. Xchar *
  462. Xpgrp_to_ttyname(pgrp)
  463. Xint pgrp;
  464. X{
  465. Xregister itmp;
  466. Xstruct utmp *tutmp;
  467. X
  468. X    if(!(tutmp = find_utmp_for_pgrp(pgrp)))
  469. X    {
  470. X        read_utmp();
  471. X        tutmp = find_utmp_for_pgrp(pgrp);
  472. X    }
  473. X    if(!tutmp)
  474. X        return("??");
  475. X    else
  476. X    {
  477. X        itmp = strlen(tutmp->ut_id);
  478. X        return(&tutmp->ut_id[(itmp >= 2) ? (itmp - 2) : 0]);
  479. X    }
  480. X}    /* end of pgrp_to_ttyname */
  481. X
  482. X/*+-------------------------------------------------------------------------
  483. X    get_user(tproc,tuser) - read user struct for pid
  484. Xreturn 1 if successful, else 0 if not available
  485. X--------------------------------------------------------------------------*/
  486. Xint
  487. Xget_user(tproc,tuser)
  488. Xstruct proc *tproc;
  489. Xstruct user *tuser;
  490. X{
  491. X#if defined(RDUBLK)    /* see sysi86.h #include above */
  492. Xprintf(">>getuser p=%d ",tproc->p_pid);
  493. X    /* this system call is not returning 0 on success ?!? */
  494. X    int rtn = !!sysi86(RDUBLK,tproc->p_pid,(char *)tuser,sizeof(*tuser)));
  495. Xprintf(">> rtn=%d\n,rtn);
  496. X    return(rtn);
  497. X#else /* RDUBLK */
  498. X    register caddr_t uptr = (caddr_t)tuser;
  499. X    register int ubrdcount = sizeof(struct user);
  500. X    int ipde;
  501. X    paddr_t mptr;
  502. X
  503. Xprintf(">>getuser p=%d ",tproc->p_pid);
  504. X#if !defined(ISC_1) && !defined(mips) && defined(SULOAD)
  505. X    if(tproc->p_flag & SULOAD)
  506. X    {
  507. X        for(ipde = 0;
  508. X#if defined(SVR31)
  509. X            ipde < USIZE;
  510. X#else
  511. X            ipde < tproc->p_usize;
  512. X#endif
  513. X            ipde++)
  514. X        {
  515. X            if(!tproc->p_ubptbl[ipde].pgm.pg_pres)    /* if not resident */
  516. X            {
  517. X                printf(">> not resident\n");
  518. X                return(0);
  519. X            }
  520. X            mptr = tproc->p_ubptbl[ipde].pgm.pg_pfn * NBPP;
  521. X            mread(uptr,(daddr_t)mptr,min(ubrdcount,NBPP));
  522. X            uptr += NBPP;
  523. X            if((ubrdcount -= NBPP) <= 0)
  524. X                break;
  525. X        }
  526. X    }
  527. X    else
  528. X    {
  529. X#if defined(SVR31)
  530. X        mptr = tproc->p_ubdbd [0].dbd_blkno * NBPSCTR;
  531. X#else
  532. X        mptr = tproc->p_ubdbd.dbd_blkno * NBPSCTR;
  533. X#endif
  534. X        sread(uptr,mptr,ubrdcount);
  535. X    }
  536. X#else /* ISC_1: a compromise first-attempt */
  537. X    for(ipde = 0; ipde < USIZE; ipde++)
  538. X    {
  539. X        if(!tproc->p_ubptbl[ipde].pgm.pg_pres)    /* if not resident */
  540. X            return(0);
  541. X        mptr = tproc->p_ubptbl[ipde].pgm.pg_pfn * NBPP;
  542. X        mread(uptr,(daddr_t)mptr,min(ubrdcount,NBPP));
  543. X        uptr += NBPP;
  544. X        if((ubrdcount -= NBPP) <= 0)
  545. X            break;
  546. X    }
  547. X#endif /* ISC_1 */
  548. X
  549. X    /*
  550. X     * we can get crap from swap if things change after we get
  551. X     * an address to read from, so validate user as best we can
  552. X     */
  553. X    printf(">> u_ruid=%d p_uid=%d ruid=%d p_suid=%d\n",
  554. X            tuser->u_ruid,tproc->p_uid,tuser->u_ruid,tproc->p_suid,
  555. X            ((tuser->u_ruid == tproc->p_uid) || (tuser->u_ruid == tproc->p_suid)));
  556. X
  557. X    return( (tuser->u_ruid == tproc->p_uid) ||
  558. X            (tuser->u_ruid == tproc->p_suid));
  559. X
  560. X#endif /* RDUBLK */
  561. X}    /* end of get_user */
  562. X
  563. X/*+-------------------------------------------------------------------------
  564. Xuid to username conversion; thanks for the idea to William LeFebvre
  565. X--------------------------------------------------------------------------*/
  566. X#define UID_NAME_HASH_SIZE    127    /* prime */
  567. X#define HASH_EMPTY            32767
  568. X#define HASHIT(i)            ((i) % UID_NAME_HASH_SIZE)
  569. X
  570. Xstruct uid_name_hash_entry {
  571. X    ushort uid;
  572. X    char name[10];
  573. X};
  574. X
  575. Xstruct uid_name_hash_entry uid_name_table[UID_NAME_HASH_SIZE];
  576. Xint uid_count = 0;
  577. X
  578. X/*+-------------------------------------------------------------------------
  579. X    init_uid_name_hash()
  580. X--------------------------------------------------------------------------*/
  581. Xvoid
  582. Xinit_uid_name_hash()
  583. X{
  584. Xregister int ihash = 0;
  585. Xregister struct uid_name_hash_entry *hashent = uid_name_table;
  586. X
  587. X    while(ihash++ < UID_NAME_HASH_SIZE)
  588. X    {
  589. X        hashent->uid = HASH_EMPTY;
  590. X        hashent++;
  591. X    }
  592. X}    /* end of init_uid_name_hash */
  593. X
  594. X/*+-------------------------------------------------------------------------
  595. X    uid_name_enter(uid,name)
  596. X--------------------------------------------------------------------------*/
  597. Xint
  598. Xuid_name_enter(uid,name)
  599. Xregister ushort uid;
  600. Xregister char *name;
  601. X{
  602. Xregister ushort table_uid;
  603. Xregister int hashval;
  604. X
  605. X    if(++uid_count >= UID_NAME_HASH_SIZE - 1)
  606. X        leave_text("too many user names for me to handle",1);
  607. X
  608. X    hashval = HASHIT(uid);
  609. X    while((table_uid = uid_name_table[hashval].uid) != HASH_EMPTY)
  610. X    {
  611. X        if(table_uid == uid)
  612. X            return(hashval);
  613. X        hashval = (hashval + 1) % UID_NAME_HASH_SIZE;
  614. X    }
  615. X
  616. X    uid_name_table[hashval].uid = uid;
  617. X    (void)strncpy(uid_name_table[hashval].name,name,
  618. X        sizeof(uid_name_table[0].name));
  619. X
  620. X    return(hashval);
  621. X
  622. X}    /* end of uid_name_enter */
  623. X
  624. X/*+-------------------------------------------------------------------------
  625. X    getpwent_and_enter(uid)
  626. X--------------------------------------------------------------------------*/
  627. Xgetpwent_and_enter(uid)
  628. Xregister ushort uid;
  629. X{
  630. Xregister int hashval;
  631. Xregister struct passwd *pwd;
  632. Xchar errant[10];
  633. Xstruct passwd *getpwuid();
  634. X
  635. X    pwd = getpwuid(uid);
  636. X    endpwent();
  637. X    if(pwd)
  638. X    {
  639. X        hashval = uid_name_enter(pwd->pw_uid,pwd->pw_name);
  640. X        return(hashval);
  641. X    }
  642. X    (void)sprintf(errant,"%u",uid);
  643. X    return(uid_name_enter(uid,errant));
  644. X}    /* end of getpwent_and_enter */
  645. X
  646. X/*+-------------------------------------------------------------------------
  647. X    uid_to_name(uid)
  648. X--------------------------------------------------------------------------*/
  649. Xchar *
  650. Xuid_to_name(uid)
  651. Xregister ushort uid;
  652. X{
  653. Xregister int uid_hash;
  654. Xregister ushort table_uid;
  655. X
  656. X    uid_hash = HASHIT(uid);
  657. X    while((table_uid = uid_name_table[uid_hash].uid) != uid)
  658. X    {
  659. X        if(table_uid == HASH_EMPTY)
  660. X        {
  661. X            /* not in hash table */
  662. X            uid_hash = getpwent_and_enter(uid);
  663. X            break;        /* out of while */
  664. X        }
  665. X        uid_hash = (uid_hash + 1) % UID_NAME_HASH_SIZE;
  666. X    }
  667. X    return(uid_name_table[uid_hash].name);
  668. X}    /* end of uid_to_name */
  669. X
  670. X/*+-----------------------------------------------------------------------
  671. X    char *get_cpu_time_str(ticks)
  672. X  6-char static string address is returned
  673. X------------------------------------------------------------------------*/
  674. Xchar *
  675. Xget_cpu_time_str(ticks)
  676. Xtime_t ticks;
  677. X{
  678. Xstatic char timestr[10];
  679. Xtime_t mm;
  680. Xextern int hz;
  681. X
  682. X    ticks /= hz;
  683. X    mm = ticks / 60L;
  684. X    ticks -= mm * 60L;
  685. X
  686. X    if(mm < 999)
  687. X    {
  688. X        ultoda(timestr,3,mm);
  689. X        timestr[3] = ':';
  690. X        ultoda_lz(timestr + 4,2,ticks);
  691. X    }
  692. X    else if(mm < 9999)
  693. X    {
  694. X        ultoda(timestr,5,mm);
  695. X        timestr[5] = 'm';
  696. X        timestr[6] = 0;
  697. X    }
  698. X    else
  699. X        (void)strcpy(timestr,">9999m");
  700. X
  701. X    return(timestr);
  702. X
  703. X}    /* end of get_cpu_time_str */
  704. X
  705. X/*
  706. X * calculated by and dependent upon layout of string below 
  707. X * 000000000011111111112222222222333333333344444444445555555555
  708. X * 012345678901234567890123456789012345678901234567890123456789    */
  709. Xchar *Ps_label = 
  710. X    "S  USER      PID   CPU PRI NI  UCPU   SCPU  SIZE TTY CMD";
  711. X/*   #! ########X ##### ### ### ## ###### ###### #### ### ####...
  712. X */
  713. X#define PROC_Y        1
  714. X#define PROC_X        0
  715. X#define UID_X        3
  716. X#define PID_X        13
  717. X#define CPU_X        19
  718. X#define PRI_X        23
  719. X#define NICE_X        27
  720. X#define UTIME_X        30
  721. X#define STIME_X        37
  722. X#define SIZE_X        44
  723. X#define TTY_X        49
  724. X#define CMD_X        53
  725. X
  726. X/*+-------------------------------------------------------------------------
  727. X    display_proc_stat(x,y,iproc,initial)
  728. X--------------------------------------------------------------------------*/
  729. Xvoid
  730. Xdisplay_proc_stat(x,y,iproc,initial)
  731. Xint x;
  732. Xint y;
  733. Xregister int iproc;
  734. Xregister int initial;
  735. X{
  736. Xregister struct proc *tproc = pprocs[iproc];
  737. Xstruct proc          *oproc = poldprocs[iproc];
  738. Xint x2;
  739. Xchar *p_stat_str = " sRzdipx";    /* dependent on values of SSLEEP etc */
  740. Xchar *cptr;
  741. Xchar s80[80];
  742. Xint fwidth = FWIDTH;
  743. XPixel pixel;
  744. X
  745. X    pixel = colorGreen.pixel;
  746. X    if((tproc->p_stat == SRUN) && !(tproc->p_flag & SLOAD))
  747. X        pixel = colorRed.pixel;
  748. X    else if(tproc->p_stat == SRUN)
  749. X        pixel = colorYellow.pixel;
  750. X
  751. X    if((tproc->p_pid != oproc->p_pid) || (pixel != oproc->p_PIXEL))
  752. X        initial = 1;
  753. X    tproc->p_PIXEL = pixel;
  754. X
  755. X    x2 = x;
  756. X    s80[0] = p_stat_str[tproc->p_stat];
  757. X    s80[1] = 0;
  758. X    x2 += disp_info_text(x2,y,pixel,s80);
  759. X    s80[0] = (tproc->p_flag & SLOAD) ? ' ' : 'S';
  760. X    disp_info_text(x2,y,pixel,s80);
  761. X
  762. X    if(initial)
  763. X    {
  764. X        strcpy(s80,uid_to_name(tproc->p_uid));
  765. X        cptr = s80 + strlen(s80);
  766. X        *cptr++ = (tproc->p_uid != tproc->p_suid) ? '#' : ' ';
  767. X        *cptr = 0;
  768. X        strcat(cptr,"       ");
  769. X        s80[11] = 0;
  770. X        disp_info_text(x + (UID_X * fwidth),y,pixel,s80);
  771. X
  772. X        utoda(s80,5,tproc->p_pid);
  773. X        s80[5] = ' ';
  774. X        s80[6] = 0;
  775. X        disp_info_text(x + (PID_X * fwidth),y,pixel,s80);
  776. X    }
  777. X
  778. X    if(initial || (tproc->p_cpu != oproc->p_cpu))
  779. X    {
  780. X        utoda(s80,3,tproc->p_cpu);
  781. X        s80[3] = ' ';
  782. X        s80[4] = 0;
  783. X        disp_info_text(x + (CPU_X * fwidth),y,pixel,s80);
  784. X    }
  785. X
  786. X    if(initial || (tproc->p_pri != oproc->p_pri))
  787. X    {
  788. X        utoda(s80,3,tproc->p_pri);
  789. X        s80[3] = ' ';
  790. X        s80[4] = 0;
  791. X        disp_info_text(x + (PRI_X * fwidth),y,pixel,s80);
  792. X    }
  793. X
  794. X    if(initial || (tproc->p_nice != oproc->p_nice))
  795. X    {
  796. X        utoda(s80,2,tproc->p_nice);
  797. X        s80[2] = ' ';
  798. X        s80[3] = 0;
  799. X        disp_info_text(x + (NICE_X * fwidth),y,pixel,s80);
  800. X    }
  801. X
  802. X    if(tproc->p_GOT_USER)
  803. X    {
  804. X        int surely = initial || !oproc->p_GOT_USER;
  805. X        if(surely || (tproc->p_U_UTIME != oproc->p_U_UTIME))
  806. X        {
  807. X            x2 = x + (UTIME_X * fwidth);
  808. X            disp_info_text(x2,y,pixel,get_cpu_time_str(tproc->p_U_UTIME));
  809. X        }
  810. X        if(surely || (tproc->p_U_STIME != oproc->p_U_STIME))
  811. X        {
  812. X            x2 = x + (STIME_X * fwidth);
  813. X            disp_info_text(x2,y,pixel,get_cpu_time_str(tproc->p_U_STIME));
  814. X        }
  815. X        if(surely || (tproc->p_size != oproc->p_size))
  816. X        {
  817. X            x2 = x + (SIZE_X * fwidth);
  818. X            ultoda(s80,4,(u_long)tproc->p_size); /* discussed at top of file */
  819. X            disp_info_text(x2,y,pixel,s80);
  820. X        }
  821. X    }
  822. X    else
  823. X    {
  824. X        x2 = x + (UTIME_X * fwidth);
  825. X        disp_info_text(x2,y,pixel,"------ ------ ---- ");
  826. X    }
  827. X
  828. X    if(initial || (tproc->p_pgrp != oproc->p_pgrp))
  829. X    {
  830. X        strcpy(s80,pgrp_to_ttyname(tproc->p_pgrp));
  831. X        strcat(s80,"   ");
  832. X        s80[4] = 0;
  833. X        x2 = x + (TTY_X * fwidth);
  834. X        disp_info_text(x2,y,pixel,s80);
  835. X    }
  836. X
  837. X    if( (initial ||
  838. X        strcmp((char *)tproc->p_U_PSARGS,(char *)oproc->p_U_PSARGS) ||
  839. X        (tproc->p_stat != oproc->p_stat)) && (DrawAreaXYWH.width - x2) > 0)
  840. X    {
  841. X        x2 = x + (CMD_X * fwidth);
  842. X        XClearArea(display,window,x2,y,DrawAreaXYWH.width - x2,FHEIGHT,0);
  843. X        XSetForeground(display,gc,pixel);
  844. X        if(tproc->p_GOT_USER)
  845. X        {
  846. X            XDrawString(display,window,gc,x2,y + FASCENT,
  847. X                (char *)tproc->p_U_PSARGS,
  848. X                strlen((char *)tproc->p_U_PSARGS));
  849. X        }
  850. X        else
  851. X        {
  852. X            switch(tproc->p_stat)
  853. X            {
  854. X                case SZOMB:
  855. X                    cptr = "<zombie>";
  856. X                    break;
  857. X                case SXBRK:
  858. X                    cptr = "<xbreak>";
  859. X                    break;
  860. X                case SIDL:
  861. X                    cptr = "<in creation>";
  862. X                    break;
  863. X                default:
  864. X                    cptr = "<swap in progress>";
  865. X            }
  866. X            XDrawString(display,window,gc,x2,y + FASCENT,cptr,strlen(cptr));
  867. X        }
  868. X    }
  869. X
  870. X}    /* end of display_proc_stat */
  871. X
  872. X/*+-------------------------------------------------------------------------
  873. X    draw_Ps_stop_work_proc()
  874. X--------------------------------------------------------------------------*/
  875. Xvoid
  876. Xdraw_Ps_stop_work_proc()
  877. X{
  878. X    if(ps_WorkProc_ID)
  879. X    {
  880. X        XtRemoveWorkProc(ps_WorkProc_ID);
  881. X        ps_WorkProc_ID = (XtWorkProcId)0;
  882. X    }
  883. X}    /* end of draw_Ps_stop_work_proc */
  884. X
  885. X/*+-------------------------------------------------------------------------
  886. X    draw_Ps_work_proc(client_data) - XtAppLoop driven work proc
  887. X
  888. Xreturns true when work done
  889. X--------------------------------------------------------------------------*/
  890. XBoolean
  891. Xdraw_Ps_work_proc(client_data)
  892. Xcaddr_t client_data;
  893. X{
  894. Xregister int iproc = next_proc_to_display;
  895. X
  896. X    switch(current_display_mode)
  897. X    {
  898. X        case BUTTON_ps:
  899. X        case BUTTON_Ps:
  900. X            break;
  901. X        default:
  902. X            return;
  903. X    }
  904. X
  905. X    display_proc_stat(next_proc_x,next_proc_y,iproc,next_proc_initial);
  906. X    next_proc_y += FHEIGHT;
  907. X
  908. X    if(++next_proc_to_display == max_procs_to_display)
  909. X    {
  910. X        draw_Ps_stop_work_proc();
  911. X        if(next_proc_y < DrawAreaXYWH.height)
  912. X        {
  913. X            XClearArea(display,window,next_proc_x,next_proc_y,
  914. X                DrawAreaXYWH.width - next_proc_x,
  915. X                DrawAreaXYWH.height - next_proc_y,0);
  916. X        }
  917. X        if(!update_timer_ID)
  918. X            set_update_timer();
  919. X        return(True);        /* work done */
  920. X    }
  921. X
  922. X    return(False);            /* work not done */
  923. X
  924. X}    /* end of draw_Ps_work_proc */
  925. X
  926. X/*+-------------------------------------------------------------------------
  927. X    draw_Ps(x,y,ps_procs_to_disp,initial)
  928. X--------------------------------------------------------------------------*/
  929. Xvoid
  930. Xdraw_Ps(x,y,ps_procs_to_disp,initial)
  931. Xint x;
  932. Xint y;
  933. Xint ps_procs_to_disp;
  934. Xint initial;
  935. X{
  936. Xregister int iproc;
  937. Xchar *cptr;
  938. Xint fheight = FHEIGHT;
  939. Xint yl1 = y + (FASCENT / 2);
  940. Xint ys  = y + FASCENT;
  941. X
  942. Xprintf(">> darw_Ps i=%d b=%d\n",initial,current_display_mode);
  943. X
  944. X    if(ps_WorkProc_ID || (DrawAreaXYWH.height < (x + (FHEIGHT * 2))))
  945. X        return;
  946. X
  947. X    max_procs_to_display = ps_procs_to_disp;
  948. X    iproc = (DrawAreaXYWH.height - y) / FHEIGHT;
  949. X    if(max_procs_to_display > iproc)
  950. X        max_procs_to_display = iproc;
  951. X
  952. X    if(initial)
  953. X    {
  954. X        /* the "background" bar */
  955. X        XSetForeground(display,gc,colorSlate.pixel);
  956. X        XSetLineAttributes(display,gc,fheight,line_style,cap_style,join_style);
  957. X        XDrawLine(display,window,gc, x,yl1, DrawAreaXYWH.width - FGAP,yl1);
  958. X
  959. X        /* the label */
  960. X        XSetForeground(display,gc,foreground);
  961. X        XDrawString(display,window,gc, x,  ys, Ps_label,strlen(Ps_label));
  962. X        XDrawString(display,window,gc, x+1,ys, Ps_label,strlen(Ps_label));
  963. X    }
  964. X
  965. X    mypid = getpid();
  966. X    read_and_sort_procs(initial);
  967. X    max_procs_to_display = min(nprocs,max_procs_to_display);
  968. X    next_proc_to_display = 0;
  969. X    next_proc_x = x;
  970. X    next_proc_y = y + fheight;
  971. X    next_proc_initial = initial;
  972. X
  973. X    ps_WorkProc_ID = XtAppAddWorkProc(appcon,draw_Ps_work_proc,
  974. X        (caddr_t)0);
  975. X
  976. X}    /* end of draw_Ps */
  977. X
  978. X/*+-------------------------------------------------------------------------
  979. X    initialize_Ps()
  980. X--------------------------------------------------------------------------*/
  981. Xinitialize_Ps()
  982. X{
  983. X    init_uid_name_hash();
  984. X}    /* end of initialize_Ps */
  985. X
  986. X/* vi: set tabstop=4 shiftwidth=4: */
  987. X/* end of ps.c */
  988. SHAR_EOF
  989. chmod 0644 x386mon/ps.c ||
  990. echo 'restore of x386mon/ps.c failed'
  991. Wc_c="`wc -c < 'x386mon/ps.c'`"
  992. test 24812 -eq "$Wc_c" ||
  993.     echo 'x386mon/ps.c: original size 24812, current size' "$Wc_c"
  994. fi
  995. # ============= x386mon/scales.c ==============
  996. if test -f 'x386mon/scales.c' -a X"$1" != X"-c"; then
  997.     echo 'x - skipping x386mon/scales.c (File already exists)'
  998. else
  999. echo 'x - extracting x386mon/scales.c (Text)'
  1000. sed 's/^X//' << 'SHAR_EOF' > 'x386mon/scales.c' &&
  1001. X/*+-------------------------------------------------------------------------
  1002. X    scales.c - X386MON CPU and wait percentage scale handler
  1003. X    wht@n4hgf.Mt-Park.GA.US
  1004. X
  1005. X  Defined functions:
  1006. X    draw_CpuScale_literals(x,y)
  1007. X    draw_PctScale_literals(x,y,scale_name,val1_name,val2_name,val3_name)
  1008. X    draw_WaitScale_literals(x,y)
  1009. X    update_CpuScale(x,y,per_state)
  1010. X    update_PctScale(x,y,length,label,totalC,greenC,yellowC,redC)
  1011. X    update_WaitScale(x,y,per_state,total_ticks)
  1012. X
  1013. X--------------------------------------------------------------------------*/
  1014. X/*+:EDITS:*/
  1015. X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */
  1016. X
  1017. X#include "unixincs.h"
  1018. X#define WANT_MON_EXTERNS
  1019. X#include "x386mon.h"
  1020. X#include "scales.h"
  1021. X#include "utoa.h"
  1022. X
  1023. Xint PctScale_width = 0; /* calculated width of PctScale */
  1024. Xint PctScale_xoffset = 0; /* calculated x offset of PctScale */
  1025. X
  1026. X/*+-------------------------------------------------------------------------
  1027. X    draw_PctScale_literals(x,y,scale_name,val1_name,val2_name,val3_name)
  1028. X--------------------------------------------------------------------------*/
  1029. Xvoid
  1030. Xdraw_PctScale_literals(x,y,scale_name,val1_name,val2_name,val3_name)
  1031. Xint x;
  1032. Xint y;
  1033. Xchar *scale_name;
  1034. Xchar *val1_name;
  1035. Xchar *val2_name;
  1036. Xchar *val3_name;
  1037. X{
  1038. Xint x2 = x;
  1039. Xint ys  = y + FASCENT;
  1040. Xint yl1 = y + (FASCENT / 2);
  1041. Xint yl2 = y + (FHEIGHT / 2) - 1;
  1042. Xint len;
  1043. Xchar *cptr;
  1044. Xchar s80[80];
  1045. Xint line_style = LineSolid;
  1046. Xint cap_style = CapButt;
  1047. Xint join_style = JoinMiter;
  1048. X
  1049. X    /* the "background" color */
  1050. X    XSetForeground(display,gc,colorSlate.pixel);
  1051. X    XSetLineAttributes(display,gc,FHEIGHT,line_style,cap_style,join_style);
  1052. X    XDrawLine(display,window,gc,x2,yl2,
  1053. X        DrawAreaXYWH.width - BORDER_EXTRA_WIDTH,yl2);
  1054. X
  1055. X    /* -----CPU ----tot usr ker brk-------------" */
  1056. X    XSetForeground(display,gc,foreground);
  1057. X    XSetLineAttributes(display,gc,FASCENT / 2,
  1058. X        line_style,cap_style,join_style);
  1059. X    XDrawLine(display,window,gc,
  1060. X        x2,yl1,x2 + (len = (FWIDTH * 5)) - FGAP,yl1);
  1061. X    x2 += len;
  1062. X
  1063. X    strcpy(s80,scale_name);
  1064. X    strcat(s80,"    ");
  1065. X    s80[4] = 0;
  1066. X    XDrawString(display,window,gc,x2, ys,s80,len = strlen(s80));
  1067. X    XDrawString(display,window,gc,x2+1,ys,s80,len);
  1068. X    x2 += FWIDTH * len;
  1069. X
  1070. X    XDrawLine(display,window,gc,
  1071. X        x2 + FGAP + 1,yl1,x2 + (len = (FWIDTH * 4)) - FGAP,yl1);
  1072. X    x2 += len;
  1073. X
  1074. X    if(!(DrawAreaXYWH.width <= (int)(DrawArea_MIN_WIDTH * 1.5)))
  1075. X    {
  1076. X        PctScale_xoffset = x2 - x;
  1077. X        cptr = s80;
  1078. X        strcpy(cptr,"tot ");
  1079. X        cptr += 4;
  1080. X        strcpy(cptr,val1_name);
  1081. X        cptr += 3;
  1082. X        *cptr++ = ' ';
  1083. X        strcpy(cptr,val2_name);
  1084. X        cptr += 3;
  1085. X        *cptr++ = ' ';
  1086. X        strcpy(cptr,val3_name);
  1087. X        cptr += 3;
  1088. X        *cptr++ = ' ';
  1089. X        *cptr = 0;
  1090. X        XDrawString(display,window,gc,x2, ys,s80,len = strlen(s80));
  1091. X        XDrawString(display,window,gc,x2+1,ys,s80,len);
  1092. X        x2 += FWIDTH * len;
  1093. X    }
  1094. X
  1095. X    XDrawLine(display,window,gc,
  1096. X        x2,yl1,DrawAreaXYWH.width - BORDER_EXTRA_WIDTH,yl1);
  1097. X    PctScale_width = DrawAreaXYWH.width - BORDER_EXTRA_WIDTH - x2;
  1098. X
  1099. X    XSetForeground(display,gc,colorBlue.pixel);
  1100. X
  1101. X    if(DrawAreaXYWH.width <= (int)(DrawArea_MIN_WIDTH * 1.5))
  1102. X        return;
  1103. X
  1104. X    /* per scale labels */
  1105. X    XClearArea(display,window,x,y + (FHEIGHT * 1),FWIDTH * 13,FHEIGHT,0);
  1106. X    if(StatCycle_msec == 1000L)
  1107. X        cptr = " Instant %   ";
  1108. X    else
  1109. X    {
  1110. X        ultoda(s80,2,(int)(StatCycle_msec / 1000L));
  1111. X        strcpy(s80 + 2," Sec Avg % ");
  1112. X        cptr = s80;
  1113. X    }
  1114. X    XDrawString(display,window,gc,
  1115. X        x,y + (FHEIGHT * 1) + FASCENT,cptr,strlen(cptr));
  1116. X
  1117. X    XClearArea(display,window,x,y + (FHEIGHT * 2),FWIDTH * 13,FHEIGHT,0);
  1118. X    ultoda(s80,2,(int)((StatCycle_msec * 5) / 1000L));
  1119. X    strcpy(s80 + 2," Sec Avg % ");
  1120. X    XDrawString(display,window,gc,
  1121. X        x,y + (FHEIGHT * 2) + FASCENT,s80,strlen(s80));
  1122. X
  1123. X    XClearArea(display,window,x,y + (FHEIGHT * 3),FWIDTH * 13,FHEIGHT,0);
  1124. X    ultoda(s80,2,(int)((StatCycle_msec * 10) / 1000L));
  1125. X    strcpy(s80 + 2," Sec Avg % ");
  1126. X    XDrawString(display,window,gc,
  1127. X        x,y + (FHEIGHT * 3) + FASCENT,s80,strlen(s80));
  1128. X
  1129. X}    /* end of draw_PctScale_literals */
  1130. X
  1131. X/*+-------------------------------------------------------------------------
  1132. X    draw_CpuScale_literals(x,y)
  1133. X--------------------------------------------------------------------------*/
  1134. Xvoid
  1135. Xdraw_CpuScale_literals(x,y)
  1136. Xint x;
  1137. Xint y;
  1138. X{
  1139. X    draw_PctScale_literals(x,y,"CPU","usr","ker","brk");
  1140. X}    /* end of draw_CpuScale_literals */
  1141. X
  1142. X/*+-------------------------------------------------------------------------
  1143. X    draw_WaitScale_literals(x,y)
  1144. X--------------------------------------------------------------------------*/
  1145. Xvoid
  1146. Xdraw_WaitScale_literals(x,y)
  1147. Xint x;
  1148. Xint y;
  1149. X{
  1150. X    draw_PctScale_literals(x,y,"Wait"," io","pio","swp");
  1151. X}    /* end of draw_WaitScale_literals */
  1152. X
  1153. X/*+-------------------------------------------------------------------------
  1154. X    update_PctScale(x,y,scale_length,totalC,greenC,yellowC,redC)
  1155. X--------------------------------------------------------------------------*/
  1156. Xvoid
  1157. Xupdate_PctScale(x,y,scale_length,label,totalC,greenC,yellowC,redC)
  1158. Xint x,y,scale_length;
  1159. Xchar *label;
  1160. Xunsigned long totalC;
  1161. Xunsigned long greenC;
  1162. Xunsigned long yellowC;
  1163. Xunsigned long redC;
  1164. X{
  1165. Xint yl = y + (FHEIGHT / 2) - 1;    /* y for lines */
  1166. Xint ys = y + FASCENT;        /* y for strings */
  1167. Xint line_length;
  1168. Xint used_length = 0;
  1169. Xint line_style = LineSolid;
  1170. Xint cap_style = CapButt;
  1171. Xint join_style = JoinMiter;
  1172. X
  1173. X    if(scale_length < 6)
  1174. X        return;
  1175. X
  1176. X    if(totalC < (greenC + yellowC + redC))
  1177. X        totalC = greenC + yellowC + redC;
  1178. X
  1179. X    XClearArea(display,window,x,y,scale_length,FHEIGHT,0);
  1180. X    XSetLineAttributes(display,gc,FHEIGHT,line_style,cap_style,join_style);
  1181. X
  1182. X    if(line_length = (int)(((float)greenC * scale_length) / (float)totalC))
  1183. X    {
  1184. X        XSetForeground(display,gc,colorGreen.pixel);
  1185. X        XDrawLine(display,window,gc,x,yl,x + line_length,yl);
  1186. X        if(line_length > FWIDTH)
  1187. X        {
  1188. X            XSetForeground(display,gc,colorBlack.pixel);
  1189. X            XDrawString(display,window,gc,x,    ys,label + 0,1);
  1190. X            XDrawString(display,window,gc,x + 1,ys,label + 0,1);
  1191. X        }
  1192. X        used_length += line_length;
  1193. X        x += line_length;
  1194. X    }
  1195. X
  1196. X    if(line_length = (int)(((float)yellowC * scale_length) / (float)totalC))
  1197. X    {
  1198. X        XSetForeground(display,gc,colorYellow.pixel);
  1199. X        XDrawLine(display,window,gc,x,yl,x + line_length,yl);
  1200. X        if(line_length > FWIDTH)
  1201. X        {
  1202. X            XSetForeground(display,gc,colorBlack.pixel);
  1203. X            XDrawString(display,window,gc,x,    ys,label + 1,1);
  1204. X            XDrawString(display,window,gc,x + 1,ys,label + 1,1);
  1205. X        }
  1206. X        used_length += line_length;
  1207. X        x += line_length;
  1208. X    }
  1209. X
  1210. X    if(line_length = (int)(((float)redC * scale_length) / (float)totalC))
  1211. X    {
  1212. X        XSetForeground(display,gc,colorRed.pixel);
  1213. X        XDrawLine(display,window,gc,x,yl,x + line_length,yl);
  1214. X        if(line_length > FWIDTH)
  1215. X        {
  1216. X            XSetForeground(display,gc,colorBlack.pixel);
  1217. X            XDrawString(display,window,gc,x,    ys,label + 2,1);
  1218. X            XDrawString(display,window,gc,x + 1,ys,label + 2,1);
  1219. X        }
  1220. X        used_length += line_length;
  1221. X        x += line_length;
  1222. X    }
  1223. X
  1224. X    if((scale_length - used_length) > 0)
  1225. X    {
  1226. X        XSetForeground(display,gc,background);
  1227. X        XDrawLine(display,window,gc,x + used_length,yl,x + scale_length,yl);
  1228. X    }
  1229. X
  1230. X}    /* end of update_PctScale */
  1231. X
  1232. X/*+-------------------------------------------------------------------------
  1233. X    update_CpuScale(x,y,per_state)
  1234. X
  1235. X000000000011111111112222222222333333333344444444445555555555666666
  1236. X012345678901234567890123456789012345678901234567890123456789012345
  1237. Xtot usr ker brk 
  1238. X### ### ### ### xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  1239. X--------------------------------------------------------------------------*/
  1240. X#define _CPUSCALE_TX    (FWIDTH * 0)
  1241. X#define _CPUSCALE_UX    (FWIDTH * 4)
  1242. X#define _CPUSCALE_KX    (FWIDTH * 8)
  1243. X#define _CPUSCALE_BX    (FWIDTH * 12)
  1244. X#define _CPUSCALE_SX    (FWIDTH * 16)
  1245. X
  1246. Xtime_t
  1247. Xupdate_CpuScale(x,y,per_state)
  1248. Xint x;
  1249. Xint y;
  1250. Xtime_t *per_state;
  1251. X{
  1252. Xtime_t idle = per_state[CPU_IDLE] + per_state[CPU_WAIT];
  1253. Xtime_t cpu_ticks_total = idle + per_state[CPU_SXBRK] + 
  1254. X                         per_state[CPU_KERNEL] + per_state[CPU_USER];
  1255. Xtime_t percent_user    = (per_state[CPU_USER]   * 100) / cpu_ticks_total;
  1256. Xtime_t percent_kernel  = (per_state[CPU_KERNEL] * 100) / cpu_ticks_total;
  1257. Xtime_t percent_break   = (per_state[CPU_SXBRK]  * 100) / cpu_ticks_total;
  1258. Xtime_t percent_busy    = percent_user + percent_kernel + percent_break;
  1259. Xunsigned long pixel;
  1260. Xchar numstr[8];
  1261. X
  1262. X    x += PctScale_xoffset;
  1263. X
  1264. X    if(DrawAreaXYWH.width <= 200)
  1265. X    {
  1266. X        XClearArea(display,window,0,y,DrawAreaXYWH.width,FHEIGHT,0);
  1267. X        update_PctScale(0,y,DrawAreaXYWH.width,
  1268. X            "ukb",100,percent_user,percent_kernel,percent_break);
  1269. X    }
  1270. X    else
  1271. X    {
  1272. X        XClearArea(display,window,x,y,FWIDTH * 16,FHEIGHT,0);
  1273. X
  1274. X        if(!idle)            /* take care of integer div truncation */
  1275. X            percent_busy = 100;
  1276. X
  1277. X        if(percent_busy > res.busyAlarmThreshhold)
  1278. X            pixel = colorRed.pixel;
  1279. X        else if(percent_busy > res.busyWarningThreshhold)
  1280. X            pixel = colorYellow.pixel;
  1281. X        else
  1282. X            pixel = colorGreen.pixel;
  1283. X
  1284. X        XSetForeground(display,gc,pixel);
  1285. X        ultoda(numstr,3,percent_busy);
  1286. X        XDrawString(display,window,gc,
  1287. X            x + _CPUSCALE_TX,y + FASCENT,numstr,3);
  1288. X
  1289. X        XSetForeground(display,gc,colorGreen.pixel);
  1290. X
  1291. X        ultoda(numstr,3,percent_user);
  1292. X        XDrawString(display,window,gc,
  1293. X            x + _CPUSCALE_UX,y + FASCENT,numstr,3);
  1294. X        
  1295. X        ultoda(numstr,3,percent_kernel);
  1296. X        XDrawString(display,window,gc,
  1297. X            x + _CPUSCALE_KX,y + FASCENT,numstr,3);
  1298. X        
  1299. X        if(percent_break > res.breakAlarmThreshhold)
  1300. X            XSetForeground(display,gc,colorRed.pixel);
  1301. X        else if(percent_break > res.breakWarningThreshhold)
  1302. X            XSetForeground(display,gc,colorYellow.pixel);
  1303. X
  1304. X        ultoda(numstr,3,percent_break);
  1305. X        XDrawString(display,window,gc,
  1306. X            x + _CPUSCALE_BX,y + FASCENT,numstr,3);
  1307. X    
  1308. X        update_PctScale(x + _CPUSCALE_SX,y,PctScale_width,
  1309. X            "ukb",100,percent_user,percent_kernel,percent_break);
  1310. X    }
  1311. X
  1312. X    return(cpu_ticks_total);
  1313. X
  1314. X}    /* end of update_CpuScale */
  1315. X
  1316. X/*+-------------------------------------------------------------------------
  1317. X    update_WaitScale(x,y,per_state,total_ticks)
  1318. X
  1319. X000000000011111111112222222222333333333344444444445555555555666666
  1320. X012345678901234567890123456789012345678901234567890123456789012345
  1321. Xtot  io pio swp  
  1322. X### ### ### ### xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  1323. X--------------------------------------------------------------------------*/
  1324. X#define _WAITSCALE_TX    (FWIDTH * 0)
  1325. X#define _WAITSCALE_IX    (FWIDTH * 4)
  1326. X#define _WAITSCALE_PX    (FWIDTH * 8)
  1327. X#define _WAITSCALE_WX    (FWIDTH * 12)
  1328. X#define _WAITSCALE_SX    (FWIDTH * 16)
  1329. X
  1330. Xtime_t
  1331. Xupdate_WaitScale(x,y,per_state,total_ticks)
  1332. Xint x;
  1333. Xint y;
  1334. Xtime_t *per_state;
  1335. Xtime_t total_ticks;
  1336. X{
  1337. Xregister itmp;
  1338. Xint accum = 0;
  1339. Xtime_t percent_io = 0L;
  1340. Xtime_t percent_swap = 0L;
  1341. Xtime_t percent_pio = 0L;
  1342. Xtime_t percent_total_wait;
  1343. Xtime_t total_wait;
  1344. Xunsigned long pixel;
  1345. Xchar numstr[8];
  1346. X
  1347. X    x += PctScale_xoffset;
  1348. X
  1349. X    /* crock: because of latency, total_ticks < all wait ticks sometimes */
  1350. X    total_wait = per_state[W_IO] + per_state[W_SWAP] + per_state[W_PIO];
  1351. X    if(total_ticks < total_wait)
  1352. X        total_ticks = total_wait;
  1353. X
  1354. X    if(total_ticks)
  1355. X    {
  1356. X        percent_io    = (per_state[W_IO]   * 100) / total_ticks;
  1357. X        percent_pio   = (per_state[W_PIO]  * 100) / total_ticks;
  1358. X        percent_swap  = (per_state[W_SWAP] * 100) / total_ticks;
  1359. X    }
  1360. X    percent_total_wait = percent_io + percent_swap + percent_pio;
  1361. X
  1362. X    if(DrawAreaXYWH.width <= 200)
  1363. X    {
  1364. X        XClearArea(display,window,0,y,DrawAreaXYWH.width,FHEIGHT,0);
  1365. X        update_PctScale(0,y,DrawAreaXYWH.width,
  1366. X            "ips",100,percent_io,percent_pio,percent_swap);
  1367. X    }
  1368. X    else
  1369. X    {
  1370. X        XClearArea(display,window,x,y,FWIDTH * 16,FHEIGHT,0);
  1371. X
  1372. X        if(percent_total_wait > res.waitAlarmThreshhold)
  1373. X            pixel = colorRed.pixel;
  1374. X        else if(percent_total_wait > res.waitWarningThreshhold)
  1375. X            pixel = colorYellow.pixel;
  1376. X        else
  1377. X            pixel = colorGreen.pixel;
  1378. X
  1379. X        XSetForeground(display,gc,pixel);
  1380. X        ultoda(numstr,3,percent_total_wait);
  1381. X        XDrawString(display,window,gc,
  1382. X            x + _WAITSCALE_TX,y + FASCENT,numstr,3);
  1383. X
  1384. X        XSetForeground(display,gc,colorGreen.pixel);
  1385. X        ultoda(numstr,3,percent_io);
  1386. X        XDrawString(display,window,gc,
  1387. X            x + _WAITSCALE_IX,y + FASCENT,numstr,3);
  1388. X        
  1389. X        ultoda(numstr,3,percent_pio);
  1390. X        XDrawString(display,window,gc,
  1391. X            x + _WAITSCALE_PX,y + FASCENT,numstr,3);
  1392. X        
  1393. X        if(percent_swap > res.swapAlarmThreshhold)
  1394. X            XSetForeground(display,gc,colorRed.pixel);
  1395. X        else if(percent_swap > res.swapWarningThreshhold)
  1396. X            XSetForeground(display,gc,colorYellow.pixel);
  1397. X
  1398. X        ultoda(numstr,3,percent_swap);
  1399. X        XDrawString(display,window,gc,
  1400. X            x + _WAITSCALE_WX,y + FASCENT,numstr,3);
  1401. X        
  1402. X        update_PctScale(x + _WAITSCALE_SX,y,PctScale_width,
  1403. X            "ips",100,percent_io,percent_pio,percent_swap);
  1404. X    }
  1405. X
  1406. X}    /* end of update_WaitScale */
  1407. X
  1408. X/* vi: set tabstop=4 shiftwidth=4: */
  1409. X/* end of scales.c */
  1410. SHAR_EOF
  1411. chmod 0644 x386mon/scales.c ||
  1412. echo 'restore of x386mon/scales.c failed'
  1413. Wc_c="`wc -c < 'x386mon/scales.c'`"
  1414. test 12204 -eq "$Wc_c" ||
  1415.     echo 'x386mon/scales.c: original size 12204, current size' "$Wc_c"
  1416. fi
  1417. # ============= x386mon/scales.h ==============
  1418. if test -f 'x386mon/scales.h' -a X"$1" != X"-c"; then
  1419.     echo 'x - skipping x386mon/scales.h (File already exists)'
  1420. else
  1421. echo 'x - extracting x386mon/scales.h (Text)'
  1422. sed 's/^X//' << 'SHAR_EOF' > 'x386mon/scales.h' &&
  1423. X
  1424. X/*+-------------------------------------------------------------------------
  1425. X    scales.h
  1426. X    wht@n4hgf.Mt-Park.GA.US
  1427. X--------------------------------------------------------------------------*/
  1428. X/*+:EDITS:*/
  1429. X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */
  1430. X
  1431. Xvoid update_PctScale(int,int,int,char *,
  1432. X        unsigned long,unsigned long,unsigned long,unsigned long);
  1433. Xtime_t update_CpuScale(int,int,time_t *);
  1434. Xtime_t update_WaitScale(int,int,time_t *,time_t);
  1435. X
  1436. X/* vi: set tabstop=4 shiftwidth=4: */
  1437. X/* end of scales.h */
  1438. SHAR_EOF
  1439. chmod 0644 x386mon/scales.h ||
  1440. echo 'restore of x386mon/scales.h failed'
  1441. Wc_c="`wc -c < 'x386mon/scales.h'`"
  1442. test 520 -eq "$Wc_c" ||
  1443.     echo 'x386mon/scales.h: original size 520, current size' "$Wc_c"
  1444. fi
  1445. # ============= x386mon/sysinfo.c ==============
  1446. if test -f 'x386mon/sysinfo.c' -a X"$1" != X"-c"; then
  1447.     echo 'x - skipping x386mon/sysinfo.c (File already exists)'
  1448. else
  1449. echo 'x - extracting x386mon/sysinfo.c (Text)'
  1450. sed 's/^X//' << 'SHAR_EOF' > 'x386mon/sysinfo.c' &&
  1451. X/*+-------------------------------------------------------------------------
  1452. X    sysinfo.c - X386MON sysinfo/minfo display handler
  1453. X    wht@n4hgf.Mt-Park.GA.US
  1454. X
  1455. X  Defined functions:
  1456. X    draw_Sysinfo_literals(x,y)
  1457. X    update_Sysinfo()
  1458. X
  1459. X--------------------------------------------------------------------------*/
  1460. X/*+:EDITS:*/
  1461. X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */
  1462. X
  1463. X#include "unixincs.h"
  1464. X#define WANT_MON_EXTERNS
  1465. X#include "x386mon.h"
  1466. X#include "buttons.h"
  1467. X#include "disp_info.h"
  1468. X
  1469. Xint sysinfo_tlx;
  1470. Xint sysinfo_tly;
  1471. X
  1472. X/*+-------------------------------------------------------------------------
  1473. X    update_Sysinfo()
  1474. X--------------------------------------------------------------------------*/
  1475. Xvoid
  1476. Xupdate_Sysinfo()
  1477. X{
  1478. Xregister int x,y;
  1479. Xint fheight = FHEIGHT;
  1480. Xint itmp;
  1481. Xlong ltmp;
  1482. XPixel pixel;
  1483. X
  1484. X    switch(current_display_mode)
  1485. X    {
  1486. X        case BUTTON_main:
  1487. X        case BUTTON_ps:
  1488. X            break;
  1489. X        default:
  1490. X            return;
  1491. X    }
  1492. X
  1493. X    if(DrawAreaXYWH.height < (sysinfo_tly + (fheight * 2)))
  1494. X        return;
  1495. X
  1496. X    y = sysinfo_tly + fheight;
  1497. X    x = sysinfo_tlx + Sysinfo1_TLX;
  1498. X    disp_info_long(x,y,"bread    ",7,sysidelta(bread));
  1499. X    y += fheight;
  1500. X    disp_info_long(x,y,"bwrite   ",7,sysidelta(bwrite));
  1501. X    y += fheight;
  1502. X    if((ltmp = sysidelta(lread) - myreadcnt) < 0)
  1503. X        ltmp = 0;
  1504. X    disp_info_long(x,y,"lread    ",7,ltmp);
  1505. X    y += fheight;
  1506. X    myreadcnt = 0;    /* reset /dev/{mem,kmem,swap} read count */
  1507. X    disp_info_long(x,y,"lwrite   ",7,sysidelta(lwrite));
  1508. X    y += fheight;
  1509. X    disp_info_long(x,y,"phread   ",7,sysidelta(phread));
  1510. X    y += fheight;
  1511. X    disp_info_long(x,y,"phwrite  ",7,sysidelta(phwrite));
  1512. X    y += fheight;
  1513. X    disp_info_long(x,y,"swapin   ",7,sysidelta(swapin));
  1514. X    y += fheight;
  1515. X    disp_info_long(x,y,"swapout  ",7,sysidelta(swapout));
  1516. X    y += fheight;
  1517. X    disp_info_long(x,y,"bswapin  ",7,sysidelta(bswapin));
  1518. X    y += fheight;
  1519. X    disp_info_long(x,y,"bswapout ",7,sysidelta(bswapout));
  1520. X    y += fheight;
  1521. X    disp_info_long(x,y,"iget     ",7,sysidelta(iget));
  1522. X    y += fheight;
  1523. X    disp_info_long(x,y,"namei    ",7,sysidelta(namei));
  1524. X    y += fheight;
  1525. X    disp_info_long(x,y,"dirblk   ",7,sysidelta(dirblk));
  1526. X    y += fheight;
  1527. X
  1528. X    y = sysinfo_tly + fheight;
  1529. X    x = sysinfo_tlx + Sysinfo2_TLX;
  1530. X    if((ltmp = sysidelta(readch) - myreadlen) < 0)
  1531. X        ltmp = 0;
  1532. X    disp_info_long(x,y,"readch  ",7,ltmp);
  1533. X    y += fheight;
  1534. X    myreadlen = 0;    /* reset /dev/{mem,kmem,swap} read count */
  1535. X
  1536. X    disp_info_long(x,y,"writch  ",7,sysidelta(writech));
  1537. X    y += fheight;
  1538. X
  1539. X    disp_info_long(x,y,"rawch   ",7,sysidelta(rawch));
  1540. X    y += fheight;
  1541. X    disp_info_long(x,y,"canch   ",7,sysidelta(canch));
  1542. X    y += fheight;
  1543. X    disp_info_long(x,y,"outch   ",7,sysidelta(outch));
  1544. X    y += fheight;
  1545. X
  1546. X    disp_info_long(x,y,"msg     ",7,sysidelta(msg));
  1547. X    y += fheight;
  1548. X    disp_info_long(x,y,"sema    ",7,sysidelta(sema));
  1549. X    y += fheight;
  1550. X
  1551. X    disp_static_long_units(x,y, "maxmem  ",6,"k",(long)maxmem * NBPP / 1024);
  1552. X    y += fheight;
  1553. X    disp_info_long_units(x,y,   "frmem   ",6,"k",(long)freemem * NBPP / 1024);
  1554. X    y += fheight;
  1555. X    itmp = 100 - (int)((freemem * 100) / maxmem);
  1556. X    if(itmp >= 80)
  1557. X        pixel = colorRed.pixel;
  1558. X    else if(itmp >= 50)
  1559. X        pixel = colorYellow.pixel;
  1560. X    else
  1561. X        pixel = colorGreen.pixel;
  1562. X    disp_info_units_color(x,y,"mem used",6,"%",(unsigned long)itmp,pixel);
  1563. X    y += fheight;
  1564. X
  1565. X    disp_static_int_units(x,y, "nswap   ",6,"k",nswap * NBPSCTR / 1024);
  1566. X    y += fheight;
  1567. X    disp_info_long_units(x,y,  "frswp   ",6,"k",minfo.freeswap* NBPSCTR/1024);
  1568. X    y += fheight;
  1569. X    itmp = 100 - (int)((minfo.freeswap * 100) / nswap);
  1570. X    if(itmp >= 80)
  1571. X        pixel = colorRed.pixel;
  1572. X    else if(itmp >= 50)
  1573. X        pixel = colorYellow.pixel;
  1574. X    else
  1575. X        pixel = colorGreen.pixel;
  1576. X    disp_info_units_color(x,y,"swp used",6,"%",(unsigned long)itmp,pixel);
  1577. X    y += fheight;
  1578. X
  1579. X    y = sysinfo_tly + fheight;
  1580. X    x = sysinfo_tlx + Sysinfo3_TLX;
  1581. X    disp_info_long(x,y,"pswitch ",5,sysidelta(pswitch));
  1582. X    y += fheight;
  1583. X    disp_info_long(x,y,"syscall ",5,sysidelta(syscall));
  1584. X    y += fheight;
  1585. X    disp_info_long(x,y,"sysread ",5,sysidelta(sysread));
  1586. X    y += fheight;
  1587. X    disp_info_long(x,y,"syswrit ",5,sysidelta(syswrite));
  1588. X    y += fheight;
  1589. X    disp_info_long(x,y,"sysfork ",5,sysidelta(sysfork));
  1590. X    y += fheight;
  1591. X    disp_info_long(x,y,"sysexec ",5,sysidelta(sysexec));
  1592. X    y += fheight;
  1593. X
  1594. X    y += fheight;
  1595. X    disp_info_long(x,y,"runque  ",5,sysidelta(runque));
  1596. X    y += fheight;
  1597. X    disp_info_long(x,y,"runocc  ",5,sysidelta(runocc));
  1598. X    y += fheight;
  1599. X    disp_info_long(x,y,"swpque  ",5,sysidelta(swpque));
  1600. X    y += fheight;
  1601. X    disp_info_long(x,y,"swpocc  ",5,sysidelta(swpocc));
  1602. X    y += fheight;
  1603. X
  1604. X    y = sysinfo_tly + fheight;
  1605. X    x = sysinfo_tlx + Sysinfo4_TLX;
  1606. X    disp_info_long(x,y,"vfault  ",3,midelta(vfault));
  1607. X    y += fheight;
  1608. X    disp_info_long(x,y,"demand  ",3,midelta(demand));
  1609. X    y += fheight;
  1610. X    disp_info_long(x,y,"pfault  ",3,midelta(pfault));
  1611. X    y += fheight;
  1612. X    disp_info_long(x,y,"cw      ",3,midelta(cw));
  1613. X    y += fheight;
  1614. X    disp_info_long(x,y,"steal   ",3,midelta(steal));
  1615. X    y += fheight;
  1616. X    disp_info_long(x,y,"frdpgs  ",3,midelta(freedpgs));
  1617. X    y += fheight;
  1618. X#if defined(SVR32)
  1619. X    disp_info_long(x,y,"vfpg    ",3,midelta(vfpg));
  1620. X    y += fheight;
  1621. X    disp_info_long(x,y,"sfpg    ",3,midelta(sfpg));
  1622. X    y += fheight;
  1623. X    disp_info_long(x,y,"vspg    ",3,midelta(vspg));
  1624. X    y += fheight;
  1625. X    disp_info_long(x,y,"sspg    ",3,midelta(sspg));
  1626. X    y += fheight;
  1627. X    disp_info_long(x,y,"pnpfault",3,sysidelta(pnpfault));
  1628. X    y += fheight;
  1629. X    disp_info_long(x,y,"wrtfault",3,sysidelta(wrtfault));
  1630. X    y += fheight;
  1631. X#endif
  1632. X
  1633. X    y = sysinfo_tly + fheight;
  1634. X    x = sysinfo_tlx + Sysinfo5_TLX;
  1635. X    disp_info_long(x,y,"unmodsw ",3,midelta(unmodsw));
  1636. X    y += fheight;
  1637. X    disp_info_long(x,y,"unmodfl ",3,midelta(unmodfl));
  1638. X    y += fheight;
  1639. X#if defined(SVR32)
  1640. X    disp_info_long(x,y,"psoutok ",3,midelta(psoutok));
  1641. X    y += fheight;
  1642. X    disp_info_long(x,y,"psinfai ",3,midelta(psinfail));
  1643. X    y += fheight;
  1644. X    disp_info_long(x,y,"psinok  ",3,midelta(psinok));
  1645. X    y += fheight;
  1646. X    disp_info_long(x,y,"rsout   ",3,midelta(rsout));
  1647. X    y += fheight;
  1648. X    disp_info_long(x,y,"rsin    ",3,midelta(rsin));
  1649. X    y += fheight;
  1650. X#endif
  1651. X
  1652. X    y += fheight;
  1653. X    disp_info_int(x,y,"pages on   ",0,0);
  1654. X    y += fheight;
  1655. X    disp_info_long(x,y,"swap  ",5,midelta(swap));
  1656. X    y += fheight;
  1657. X    disp_info_long(x,y,"cache ",5,midelta(cache));
  1658. X    y += fheight;
  1659. X    disp_info_long(x,y,"file  ",5,midelta(file));
  1660. X    y += fheight;
  1661. X
  1662. X}    /* end of update_Sysinfo */
  1663. X
  1664. X/*+-------------------------------------------------------------------------
  1665. X    draw_Sysinfo_literals(x,y,scale_name,val1_name,val2_name,val3_name)
  1666. X--------------------------------------------------------------------------*/
  1667. Xvoid
  1668. Xdraw_Sysinfo_literals(x,y)
  1669. Xint x;
  1670. Xint y;
  1671. X{
  1672. Xint x2 = x;
  1673. Xint ys  = y + FASCENT;
  1674. Xint yl1 = y + (FASCENT / 2) + 1;
  1675. Xint yl2 = y + (FHEIGHT / 2);
  1676. Xint len;
  1677. Xchar *cptr;
  1678. Xchar s80[80];
  1679. Xint fheight = FHEIGHT;
  1680. Xint fwidth = FWIDTH;
  1681. Xint line_style = LineSolid;
  1682. Xint cap_style = CapButt;
  1683. Xint join_style = JoinMiter;
  1684. X
  1685. X    sysinfo_tlx = x;
  1686. X    sysinfo_tly = y;
  1687. X
  1688. X    /* the "background" color */
  1689. X    XSetForeground(display,gc,colorSlate.pixel);
  1690. X    XSetLineAttributes(display,gc,fheight,
  1691. X        line_style,cap_style,join_style);
  1692. X    XDrawLine(display,window,gc, x,yl2, x + (77 * fwidth),yl2);
  1693. X
  1694. X    /* "-----Sysinfo/Minfo-----------------" */
  1695. X    XSetForeground(display,gc,foreground);
  1696. X    XSetLineAttributes(display,gc,FASCENT / 2,
  1697. X        line_style,cap_style,join_style);
  1698. X    XDrawLine(display,window,gc,
  1699. X        x2,yl1,
  1700. X        x2 + (len = (fwidth * 5)) - FGAP,yl1);
  1701. X    x2 += len;
  1702. X
  1703. X    cptr = "Sysinfo/Minfo";
  1704. X    XDrawString(display,window,gc, x2,  ys, cptr,len = strlen(cptr));
  1705. X    XDrawString(display,window,gc, x2+1,ys, cptr,len);
  1706. X    x2 += (fwidth * len) + FGAP + 1;
  1707. X
  1708. X    XDrawLine(display,window,gc, x2,yl1, x + (77 * fwidth),yl1);
  1709. X
  1710. X}    /* end of draw_Sysinfo_literals */
  1711. X
  1712. X/* vi: set tabstop=4 shiftwidth=4: */
  1713. X/* end of sysinfo.c */
  1714. SHAR_EOF
  1715. chmod 0644 x386mon/sysinfo.c ||
  1716. echo 'restore of x386mon/sysinfo.c failed'
  1717. Wc_c="`wc -c < 'x386mon/sysinfo.c'`"
  1718. test 7424 -eq "$Wc_c" ||
  1719.     echo 'x386mon/sysinfo.c: original size 7424, current size' "$Wc_c"
  1720. fi
  1721. true || echo 'restore of x386mon/tune.c failed'
  1722. echo End of part 4, continue with part 5
  1723. exit 0
  1724.  
  1725. -----------------------------------------------------------------------
  1726. Warren Tucker, TuckerWare   gatech!n4hgf!wht or wht@n4hgf.Mt-Park.GA.US
  1727. Many [Nobel physics] prizes  have been given  to people for  telling us
  1728. the universe is not as simple as we thought it was. -Stephen Hawking in
  1729. A Brief History of Time     In computing, there are no such prizes. -me
  1730.