source: trunk/athena/bin/mon/io.c @ 2

Revision 2, 3.7 KB checked in by dgg, 37 years ago (diff)
Initial revision
Line 
1/*
2 *      $Source: /afs/dev.mit.edu/source/repository/athena/bin/mon/io.c,v $
3 *      $Author: dgg $
4 *      $Locker:  $
5 *      $Header: /afs/dev.mit.edu/source/repository/athena/bin/mon/io.c,v 1.1 1984-12-13 12:00:44 dgg Exp $
6 */
7
8#ifndef lint
9static char *rcsid_io_c = "$Header: /afs/dev.mit.edu/source/repository/athena/bin/mon/io.c,v 1.1 1984-12-13 12:00:44 dgg Exp $";
10#endif  lint
11
12/*
13 *      I O
14 *
15 * Purpose: Read the kernel's I/O statistics and display selected
16 *      parameters about terminals and disks.
17 *
18 */
19
20#include "mon.h"
21
22double  kbps, tps;      /* Kbytes/sec and xfers/sec */
23int     lasty;          /* Last disk y location */
24
25/* Temporary Defines - All output should be moved to dispinfo */
26#include <curses.h>
27#define CHARX   37
28#define CHARY   5
29#define DISKX   55
30#define DISKY   2
31#define DISKOFF 6
32#define DISKWDS DISKOFF
33#define DISKXFER DISKOFF+4
34#define DISKSEEK DISKOFF+8
35
36io()
37{
38        int y;
39        register i;
40        long    t;
41        double  tkbps, ttps;    /* Totals for all drives */
42
43        lseek(kmem, (long)namelist[X_DK_TIME].n_value, 0);
44        read(kmem, s.dk_time, sizeof s.dk_time);
45        lseek(kmem, (long)namelist[X_DK_XFER].n_value, 0);
46        read(kmem, s.dk_xfer, sizeof s.dk_xfer);
47        lseek(kmem, (long)namelist[X_DK_WDS].n_value, 0);
48        read(kmem, s.dk_wds, sizeof s.dk_wds);
49        lseek(kmem, (long)namelist[X_TK_NIN].n_value, 0);
50        read(kmem, &s.tk_nin, sizeof s.tk_nin);
51        lseek(kmem, (long)namelist[X_TK_NOUT].n_value, 0);
52        read(kmem, &s.tk_nout, sizeof s.tk_nout);
53        lseek(kmem, (long)namelist[X_DK_SEEK].n_value, 0);
54        read(kmem, s.dk_seek, sizeof s.dk_seek);
55        lseek(kmem, (long)namelist[X_DK_MSPW].n_value, 0);
56        read(kmem, s.dk_mspw, sizeof s.dk_mspw);
57        lseek(kmem, (long)namelist[X_HZ].n_value, 0);
58        read(kmem, &hz, sizeof hz);
59        for (i = 0; i < DK_NDRIVE; i++) {
60#define X(fld)  t = s.fld[i]; s.fld[i] -= s1.fld[i]; s1.fld[i] = t
61                X(dk_xfer); X(dk_seek); X(dk_wds); X(dk_time);
62        }
63        t = s.tk_nin; s.tk_nin -= s1.tk_nin; s1.tk_nin = t;
64        t = s.tk_nout; s.tk_nout -= s1.tk_nout; s1.tk_nout = t;
65
66        /* output character I/O counts */
67        mvprintw(CHARY+1,CHARX+4,"%4.0f %5.0f", s.tk_nin/etime, s.tk_nout/etime);
68
69        /* Display Drive statistics */
70        tkbps = ttps = 0;
71        for (i=0; i<DK_NDRIVE; i++) {
72                if (stats(i)) {
73                        tkbps += kbps;
74                        ttps += tps;
75                }
76        }
77        /* Display Totals */
78        mvprintw(lasty+2, DISKX+DISKOFF, "%4.0f%4.0f", tkbps, ttps);
79}
80
81/*
82 * Display statistics for dk drive number dn.
83 *  Returns 1 if totals should be updated.
84 */
85stats(dn)
86{
87        int y;
88        register i;
89        double atime, words, xtime, itime;
90
91        /* only display info for named (real) devices */
92        if (!*dr_name[dn])
93                return(0);
94
95        y = dn + DISKY+1;
96        lasty = y;
97        if (s.dk_mspw[dn] == 0.0) {
98                mvprintw(y,DISKX+DISKOFF,"%4.0f%4.0f%6.1f ", 0.0, 0.0, 0.0);
99                return(0);
100        }
101        atime = s.dk_time[dn];
102        atime /= (float) hz;
103        words = s.dk_wds[dn]*32.0;      /* number of 16 bit words transferred */
104        xtime = s.dk_mspw[dn]*words;    /* transfer time */
105        itime = atime - xtime;          /* time not transferring (seek time) */
106
107        if (xtime < 0)
108                itime += xtime, xtime = 0;
109        if (itime < 0)
110                xtime += itime, itime = 0;
111
112        /* Avg Kbps, transfers/sec, avg seek time (in msec) */
113        kbps = words/512/etime;
114        tps = s.dk_xfer[dn]/etime;
115        mvprintw(y,DISKX+DISKWDS,"%4.0f", kbps);
116        mvprintw(y,DISKX+DISKXFER,"%4.0f", tps);
117        mvprintw(y,DISKX+DISKSEEK,"%6.1f ",
118            s.dk_seek[dn] ? itime*1000./s.dk_seek[dn] : 0.0);
119
120        return(1);      /* Update totals */
121}
122
123
Note: See TracBrowser for help on using the repository browser.