Date: Sun, 27 Jun 1999 21:42:24 -0400 (EDT) From: sk-ports@yin.vegamuse.org To: FreeBSD-gnats-submit@freebsd.org Subject: ports/12425: Port update: sysutils/wmmon Message-ID: <199906280142.VAA00558@yang.vegamuse.org>
next in thread | raw e-mail | index | archive | help
>Number: 12425 >Category: ports >Synopsis: update to make port work on -CURRENT (missed one before) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Jun 27 18:50:00 PDT 1999 >Closed-Date: >Last-Modified: >Originator: Stephen Kiernan <sk-ports@vegamuse.org> >Release: FreeBSD 4.0-CURRENT i386 >Organization: n/a >Environment: >Description: -CURRENT no longer has sys/rlist.h but was still on my system. This patch changes wmmon.c so that sys/rlist.h is not included on a -CURRENT build of the port. This is an update of the patch-ad file. Thanks to Maxim Sobolev (sobomax@altavista.net) for spotting this oversight. >How-To-Repeat: >Fix: # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # ports/sysutils/wmmon/patches/patch-ad # echo x - ports/sysutils/wmmon/patches/patch-ad sed 's/^X//' >ports/sysutils/wmmon/patches/patch-ad << 'END-of-ports/sysutils/wmmon/patches/patch-ad' X*** wmmon/wmmon.c.orig Tue May 19 17:13:16 1998 X--- wmmon/wmmon.c Sun Jun 27 21:31:50 1999 X*************** X*** 28,33 **** X--- 28,40 ---- X Changes: X ---- X X+ 05/24/1999 (Stephen Kiernan, sk-ports@vegamuse.org) X+ * Ported to FreeBSD 4.0 X+ 12/11/1998 (Stephen Kiernan, sk-ports@vegamuse.org) X+ * Ported to FreeBSD 2.2, 3.0 X+ * Based on code from the FreeBSD 2.2 version of top X+ by Christos Zoulas, Steven Wallace, and X+ Wolfram Schneider X 18/05/1998 (Antoine Nulle, warp@xs4all.nl) X * MEM/SWAP/UPTIME only updated when visible X * Using global file descriptors to reduce file X*************** X*** 72,81 **** X--- 79,105 ---- X #include <fcntl.h> X #include <unistd.h> X X+ #include <errno.h> X+ X #include <sys/wait.h> X #include <sys/param.h> X #include <sys/types.h> X X+ #include <kvm.h> X+ #include <limits.h> X+ #include <osreldate.h> X+ #include <sys/conf.h> X+ #include <sys/dkstat.h> X+ #if __FreeBSD_version >= 300000 X+ #include <devstat.h> X+ #endif X+ #include <sys/sysctl.h> X+ #include <sys/time.h> X+ #if __FreeBSD_version < 400000 X+ #include <sys/rlist.h> X+ #endif X+ #include <sys/vmmeter.h> X+ X #include <X11/Xlib.h> X #include <X11/xpm.h> X #include <X11/extensions/shape.h> X*************** X*** 106,117 **** X--- 130,189 ---- X FILE *fp_stat; X FILE *fp_loadavg; X X+ kvm_t *kvmd = NULL; X+ struct nlist nl[] = { X+ #define N_CNT 0 X+ { "_cnt" }, X+ #define N_BUFSPACE 1 X+ { "_bufspace" }, X+ #define N_CP_TIME 2 X+ { "_cp_time" }, X+ #define N_AVERUN 3 X+ { "_averunnable" }, X+ #if __FreeBSD_version >= 300000 X+ #define N_TK_NIN 4 X+ { "_tk_nin" }, X+ #define N_TK_NOUT 5 X+ { "_tk_nout" }, X+ #else X+ #define N_DK_NDRIVE 4 X+ { "_dk_ndrive" }, X+ #define N_DK_WDS 5 X+ { "_dk_wds" }, X+ #endif X+ #if __FreeBSD_version < 400000 X+ #define VM_SWAPLIST 6 X+ { "_swaplist" }, X+ #define VM_SWDEVT 7 X+ { "_swdevt" }, X+ #define VM_NSWAP 8 X+ { "_nswap" }, X+ #define VM_NSWDEV 9 X+ { "_nswdev" }, X+ #define VM_DMMAX 10 X+ { "_dmmax" }, X+ #endif X+ { "" } X+ }; X+ int psize; X+ int pshift; X+ long *cur_dk_wds; X+ long *last_dk_wds; X+ int ndrives; X+ char errbuf[_POSIX2_LINE_MAX]; X+ static int swappgsin = -1; X+ static int swappgsout = -1; X+ X /* functions */ X void usage(void); X void printversion(void); X void DrawStats(int *, int, int, int, int); X void DrawStats_io(int *, int, int, int, int); X X+ #if defined(__FreeBSD__) || defined(__NetBSD__) X+ int swapmode( long *retavail, long *retfree); X+ #endif /* __FreeBSD__ || __NetBSD__ */ X+ X void wmmon_routine(int, char **); X X void main(int argc, char *argv[]) { X*************** X*** 154,159 **** X--- 226,237 ---- X } X } X X+ if( checkversion() < 0 ) X+ { X+ fprintf( stderr, devstat_errbuf ); X+ exit(1); X+ } X+ X wmmon_routine(argc, argv); X } X X*************** X*** 213,238 **** X long istat; X long idle; X X! FILE *fp; X! char temp[128]; X char *p; X X! int xpm_X = 0, xpm_Y = 0; X X long online_time = 0; X long ref_time = 0; X long cnt_time; X X! X! fp = fopen("/proc/uptime", "r"); X! fp_meminfo = fopen("/proc/meminfo", "r"); X! fp_loadavg = fopen("/proc/loadavg", "r"); X! fp_stat = fopen("/proc/stat", "r"); X! X! if (fp) { X! fscanf(fp, "%ld", &online_time); X ref_time = time(0); X! fclose(fp); X } X X for (i=0; i<MAX_STAT_DEVICES; i++) { X--- 291,351 ---- X long istat; X long idle; X X! int mib[2]; X! size_t size; X! struct timeval boottime; X char *p; X X! int xpm_X = 0, xpm_Y = 0; X X long online_time = 0; X long ref_time = 0; X long cnt_time; X X! mib[0] = CTL_KERN; X! mib[1] = KERN_BOOTTIME; X! size = sizeof(boottime); X! if ((sysctl(mib, 2, &boottime, &size, NULL, 0)!=-1) && X! (boottime.tv_sec != 0)) { X ref_time = time(0); X! online_time = ref_time - boottime.tv_sec + 30; X! } X! X! psize = getpagesize(); X! for (pshift = 0, psize = getpagesize(); psize>1; pshift++, psize>>=1); X! pshift -= 10; X! psize = getpagesize(); X! X! if (kvmd==NULL) kvmd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf); X! if (kvmd==NULL) { fprintf(stderr, "kvm_openfiles: %s\n", errbuf); exit(errno); } X! if (kvmd) { X! if (kvm_nlist(kvmd, nl) >= 0) { X! struct nlist *nlp; X! X! for( nlp = nl; *nlp->n_name != '\0'; nlp++ ) { X! if( nlp->n_type == 0 ) X! fprintf (stderr, "kvm_nlist: Symbol '%s' not found\n", nlp->n_name); X! } X! X! #if __FreeBSD_version >= 300000 X! ndrives = getnumdevs(); X! #else X! if (nl[0].n_type != 0) { X! (void) kvm_read(kvmd, nl[N_DK_NDRIVE].n_value, (char *)&ndrives, sizeof(ndrives)); X! if (ndrives > 0) { X! cur_dk_wds = calloc(ndrives, sizeof(long)); X! last_dk_wds = calloc(ndrives, sizeof(long)); X! bzero(last_dk_wds, sizeof(long) * ndrives); X! } X! #endif X! fprintf (stderr, "Monitoring %d devices for activity.\n", ndrives); X! #if __FreeBSD_version < 300000 X! } X! #endif X! } X! else { X! fprintf( stderr, "kvm_nlist: %s\n", kvm_geterr(kvmd) ); X! } X } X X for (i=0; i<MAX_STAT_DEVICES; i++) { X*************** X*** 246,261 **** X if (RIGHT_ACTION) right_action = strdup(RIGHT_ACTION); X if (MIDDLE_ACTION) middle_action = strdup(MIDDLE_ACTION); X X! strcpy(temp, "/etc/wmmonrc"); X! parse_rcfile(temp, wmmon_keys); X X! p = getenv("HOME"); X! strcpy(temp, p); X! strcat(temp, "/.wmmonrc"); X! parse_rcfile(temp, wmmon_keys); X X! strcpy(temp, "/etc/wmmonrc.fixed"); X! parse_rcfile(temp, wmmon_keys); X X stat_online = checksysdevs(); X X--- 359,378 ---- X if (RIGHT_ACTION) right_action = strdup(RIGHT_ACTION); X if (MIDDLE_ACTION) middle_action = strdup(MIDDLE_ACTION); X X! parse_rcfile("/etc/wmmonrc", wmmon_keys); X X! if ((p = getenv("HOME")) != NULL) { X! #define RCFILE "/.wmmonrc" X! int tmpsize = strlen(p) + sizeof(RCFILE) + 1; X! char *tmp = malloc(tmpsize); X! if (tmp != NULL) { X! snprintf(tmp, tmpsize, "%s" RCFILE, p); X! parse_rcfile(tmp, wmmon_keys); X! free(tmp); X! } X! } X X! parse_rcfile("/etc/wmmonrc.fixed", wmmon_keys); X X stat_online = checksysdevs(); X X*************** X*** 484,489 **** X--- 601,611 ---- X st->rt_idle = idle - st->idlelast; X st->idlelast = idle; X X+ /* There's a problem here with values crossing X+ the max long size barrier becoming negative -- X+ things restabilize after some time, but a X+ better solution needs to be designed X+ */ X st->rt_stat = istat - st->statlast; X st->statlast = istat; X X*************** X*** 499,543 **** X X void update_stat_mem(stat_dev *st, stat_dev *st2) { X X! char temp[128]; X! unsigned long free, shared, buffers, cached; X X! freopen("/proc/meminfo", "r", fp_meminfo); X! while (fgets(temp, 128, fp_meminfo)) { X! if (strstr(temp, "Mem:")) { X! sscanf(temp, "Mem: %ld %ld %ld %ld %ld %ld", X! &st->rt_idle, &st->rt_stat, X! &free, &shared, &buffers, &cached); X! st->rt_idle >>= 10; X! st->rt_stat -= buffers+cached; X! st->rt_stat >>= 10; X! // break; X! } X! if (strstr(temp, "Swap:")) { X! sscanf(temp, "Swap: %ld %ld", &st2->rt_idle, &st2->rt_stat); X! st2->rt_idle >>= 10; X! st2->rt_stat >>= 10; X! break; X } X } X } X X void update_stat_swp(stat_dev *st) { X X! char temp[128]; X X! fseek(fp_meminfo, 0, SEEK_SET); X! while (fgets(temp, 128, fp_meminfo)) { X! if (strstr(temp, "Swap:")) { X! sscanf(temp, "Swap: %ld %ld", &st->rt_idle, &st->rt_stat); X! st->rt_idle >>= 10; X! st->rt_stat >>= 10; X! break; X } X } X X } X X /*******************************************************************************\ X |* get_statistics *| X \*******************************************************************************/ X--- 621,875 ---- X X void update_stat_mem(stat_dev *st, stat_dev *st2) { X X! unsigned long buffers; X X! if (kvmd==NULL) kvmd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf); X! if (kvmd==NULL) { fprintf(stderr, "kvm_openfiles: %s\n", errbuf); exit(errno); } X! if (kvmd) { X! if (kvm_nlist(kvmd, nl) >= 0) { X! if (nl[0].n_type != 0) { X! static int first_time_done = 0; X! int dpagein, dpageout; X! struct vmmeter sum; X! X! if ((kvm_read(kvmd, nl[N_CNT].n_value, (char *)&sum, sizeof(sum))==sizeof(sum)) && X! (kvm_read(kvmd, nl[N_BUFSPACE].n_value, (char *)&buffers, sizeof(buffers))==sizeof(buffers))) { X! st->rt_idle = (sum.v_page_count - (buffers/psize) - sum.v_wire_count) << pshift; X! st->rt_stat = sum.v_active_count << pshift; X! X! if (swappgsin < 0) { X! dpagein = 0; X! dpageout = 0; X! } X! else { X! dpagein = (sum.v_swappgsin - swappgsin) << pshift; X! dpageout = (sum.v_swappgsout - swappgsout) << pshift; X! } X! swappgsin = sum.v_swappgsin; X! swappgsout = sum.v_swappgsout; X! X! if ((dpagein>0) || (dpageout>0) || (first_time_done==0)) { X! swapmode(&st2->rt_idle, &st2->rt_stat); X! st2->rt_stat = st2->rt_idle - st2->rt_stat; X! } X! first_time_done = 1; X! } X! } X } X } X } X X void update_stat_swp(stat_dev *st) { X X! if (kvmd==NULL) kvmd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf); X! if (kvmd==NULL) { fprintf(stderr, "kvm_openfiles: %s\n", errbuf); exit(errno); } X! if (kvmd) { X! if (kvm_nlist(kvmd, nl) >= 0) { X! if (nl[0].n_type != 0) { X! static int first_time_done = 0; X! int dpagein, dpageout; X! X! struct vmmeter sum; X! if (kvm_read(kvmd, nl[N_CNT].n_value, (char *)&sum, sizeof(sum))==sizeof(sum)) { X! if (swappgsin < 0) { X! dpagein = 0; X! dpageout = 0; X! } X! else { X! dpagein = (sum.v_swappgsin - swappgsin) << pshift; X! dpageout = (sum.v_swappgsout - swappgsout) << pshift; X! } X! swappgsin = sum.v_swappgsin; X! swappgsout = sum.v_swappgsout; X! X! if ((dpagein>0) || (dpageout>0) || (first_time_done==0)) { X! swapmode(&st->rt_idle, &st->rt_stat); X! st->rt_stat = st->rt_idle - st->rt_stat; X! } X! first_time_done = 1; X! } X! } X! } X! } X! } X! X! #if __FreeBSD_version < 400000 X! /* X! * swapmode for FreeBSD 2.x and 3.x is based on a program called swapinfo X! * written by Kevin Lahey <kml@rokkaku.atl.ga.us>. X! */ X! X! #define SVAR(var) __STRING(var) /* to force expansion */ X! #define KGET(idx, var) \ X! KGET1(idx, &var, sizeof(var), SVAR(var)) X! #define KGET1(idx, p, s, msg) \ X! KGET2(nl[idx].n_value, p, s, msg) X! #define KGET2(addr, p, s, msg) \ X! if (kvm_read(kvmd, (u_long)(addr), p, s) != s) { \ X! return (0); \ X! } X! #define KGETRET(addr, p, s, msg) \ X! if (kvm_read(kvmd, (u_long)(addr), p, s) != s) { \ X! return (0); \ X! } X! #endif X! X! X! int swapmode( long *retavail, long *retfree) X! { X! int used, avail; X! #if __FreeBSD_version >= 400000 X! struct kvm_swap kvmswap; X! #else X! char *header; X! int hlen, nswap, nswdev, dmmax; X! int i, div, nfree, npfree; X! struct swdevt *sw; X! long blocksize, *perdev; X! u_long ptr; X! struct rlist head; X! # if __FreeBSD_version >= 220000 X! struct rlisthdr swaplist; X! # else X! struct rlist *swaplist; X! # endif X! struct rlist *swapptr; X! #endif X! X! /* X! * Counter for error messages. If we reach the limit, X! * stop reading information from swap devices and X! * return zero. This prevent endless 'bad address' X! * messages. X! */ X! static int warning = 10; X! X! if (warning <= 0) { X! /* a single warning */ X! if (!warning) { X! warning--; X! fprintf(stderr, X! "Too much errors, stop reading swap devices ...\n"); X! (void)sleep(3); X! } X! return(0); X! } X! warning--; /* decrease counter, see end of function */ X! X! #if __FreeBSD_version >= 400000 X! if( kvm_getswapinfo( kvmd, &kvmswap, 1, 0 ) < 0 ) { X! fprintf(stderr, "kvm_getswapinfo failed\n"); X! return(0); X! } X! X! *retavail = avail = kvmswap.ksw_total; X! used = kvmswap.ksw_used; X! *retfree = kvmswap.ksw_total - used; X! #else X! KGET(VM_NSWAP, nswap); X! if (!nswap) { X! fprintf(stderr, "No swap space available\n"); X! return(0); X! } X! X! KGET(VM_NSWDEV, nswdev); X! KGET(VM_DMMAX, dmmax); X! KGET1(VM_SWAPLIST, &swaplist, sizeof(swaplist), "swaplist"); X! if ((sw = (struct swdevt *)malloc(nswdev * sizeof(*sw))) == NULL || X! (perdev = (long *)malloc(nswdev * sizeof(*perdev))) == NULL) X! { X! perror("malloc"); X! exit(1); X! } X! KGET1(VM_SWDEVT, &ptr, sizeof ptr, "swdevt"); X! KGET2(ptr, sw, nswdev * sizeof(*sw), "*swdevt"); X X! /* Count up swap space. */ X! nfree = 0; X! memset(perdev, 0, nswdev * sizeof(*perdev)); X! #if __FreeBSD_version >= 220000 X! swapptr = swaplist.rlh_list; X! while (swapptr) { X! #else X! while (swaplist) { X! #endif X! int top, bottom, next_block; X! #if __FreeBSD_version >= 220000 X! KGET2(swapptr, &head, sizeof(struct rlist), "swapptr"); X! #else X! KGET2(swaplist, &head, sizeof(struct rlist), "swaplist"); X! #endif X! X! top = head.rl_end; X! bottom = head.rl_start; X! X! nfree += top - bottom + 1; X! X! /* X! * Swap space is split up among the configured disks. X! * X! * For interleaved swap devices, the first dmmax blocks X! * of swap space some from the first disk, the next dmmax X! * blocks from the next, and so on up to nswap blocks. X! * X! * The list of free space joins adjacent free blocks, X! * ignoring device boundries. If we want to keep track X! * of this information per device, we'll just have to X! * extract it ourselves. X! */ X! X! while (top / dmmax != bottom / dmmax) { X! next_block = ((bottom + dmmax) / dmmax); X! perdev[(bottom / dmmax) % nswdev] += X! next_block * dmmax - bottom; X! bottom = next_block * dmmax; X } X+ perdev[(bottom / dmmax) % nswdev] += X+ top - bottom + 1; X+ X+ #if __FreeBSD_version >= 220000 X+ swapptr = head.rl_next; X+ #else X+ swaplist = head.rl_next; X+ #endif X+ } X+ X+ header = getbsize(&hlen, &blocksize); X+ div = blocksize / 512; X+ avail = npfree = 0; X+ for (i = 0; i < nswdev; i++) { X+ int xsize, xfree; X+ X+ /* X+ * Don't report statistics for partitions which have not X+ * yet been activated via swapon(8). X+ */ X+ X+ xsize = sw[i].sw_nblks; X+ xfree = perdev[i]; X+ used = xsize - xfree; X+ npfree++; X+ avail += xsize; X } X X+ /* X+ * If only one partition has been set up via swapon(8), we don't X+ * need to bother with totals. X+ */ X+ *retavail = avail / 2; X+ *retfree = nfree / 2; X+ used = avail - nfree; X+ free(sw); free(perdev); X+ #endif /* __FreeBSD_version >= 400000 */ X+ X+ /* increase counter, no errors occurs */ X+ warning++; X+ X+ return (int)(((double)used / (double)avail * 100.0) + 0.5); X } X X+ X+ X /*******************************************************************************\ X |* get_statistics *| X \*******************************************************************************/ X*************** X*** 545,554 **** X void get_statistics(char *devname, long *is, long *ds, long *idle) { X X int i; X! char temp[128]; X! char *p; X! char *tokens = " \t\n"; X! float f; X long maxdiskio=0; X X *is = 0; X--- 877,884 ---- X void get_statistics(char *devname, long *is, long *ds, long *idle) { X X int i; X! long averun[3]; X! long cp_time[CPUSTATES]; X long maxdiskio=0; X X *is = 0; X*************** X*** 556,592 **** X *idle = 0; X X if (!strncmp(devname, "cpu", 3)) { X! fseek(fp_stat, 0, SEEK_SET); X! while (fgets(temp, 128, fp_stat)) { X! if (strstr(temp, "cpu")) { X! p = strtok(temp, tokens); X! /* 1..3, 4 == idle, we don't want idle! */ X! for (i=0; i<3; i++) { X! p = strtok(NULL, tokens); X! *ds += atol(p); X! } X! p = strtok(NULL, tokens); X! *idle = atol(p); X! } X! } X! fp_loadavg = freopen("/proc/loadavg", "r", fp_loadavg); X! fscanf(fp_loadavg, "%f", &f); X! *is = (long) (100 * f); X } X X if (!strncmp(devname, "i/o", 3)) { X X! fseek(fp_stat, 0, SEEK_SET); X! while (fgets(temp, 128, fp_stat)) { X! if (strstr(temp, "disk_rio") || strstr(temp, "disk_wio")) { X! p = strtok(temp, tokens); X! /* 1..4 */ X! for (i=0; i<4; i++) { X! p = strtok(NULL, tokens); X! *ds += atol(p); X } X } X } X if (*ds > maxdiskio) maxdiskio = *ds; X } X } X--- 886,1090 ---- X *idle = 0; X X if (!strncmp(devname, "cpu", 3)) { X! if (kvmd==NULL) kvmd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf); X! if (kvmd==NULL) { fprintf(stderr, "kvm_openfiles: %s\n", errbuf); exit(errno); } X! if (kvmd) { X! if (kvm_nlist(kvmd, nl) >= 0) { X! if (nl[0].n_type != 0) { X! if ((kvm_read(kvmd, nl[N_CP_TIME].n_value, (char *)&cp_time, sizeof(cp_time))==sizeof(cp_time)) && X! (kvm_read(kvmd, nl[N_AVERUN].n_value, (char *)&averun, sizeof(averun))==sizeof(averun))) { X! *is = (long) (100 * ((double)averun[0] / FSCALE)); X! X! for (i = 0; i < CPUSTATES; i++) { X! if (i != CP_IDLE) *ds += cp_time[i]; X! } X! *idle = cp_time[CP_IDLE]; X! } X! } X! } X! } X } X X if (!strncmp(devname, "i/o", 3)) { X+ #if __FreeBSD_version < 300000 X+ if (kvmd==NULL) kvmd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf); X+ if (kvmd==NULL) { fprintf(stderr, "kvm_openfiles: %s\n", errbuf); exit(errno); } X+ if (kvmd) { X+ if (kvm_nlist(kvmd, nl) >= 0) { X+ if (nl[0].n_type != 0) { X+ if (kvm_read(kvmd, nl[N_DK_WDS].n_value, (char *)cur_dk_wds, ndrives * sizeof(long))==(ndrives*sizeof(long))) { X+ for (i = 0; i < ndrives; i++) { X+ *ds += cur_dk_wds[i]; X+ } X+ } X+ } X+ } X+ } X+ #else X+ static int initted = 0; X+ static struct statinfo last; X+ static struct statinfo cur; X+ int ndevs = getnumdevs(); X+ int gotdevs = 0; X+ long generation; X+ int num_devices_specified = 0; X+ int num_selected; X+ int num_selections; X+ int maxshowdevs = 10; X+ int num_matches = 0; X+ struct devstat_match *matches = NULL; X+ struct device_selection *dev_select = NULL; X+ char **specified_devices; X+ long select_generation; X+ X+ if( !initted ) X+ { X+ bzero( &cur, sizeof(cur) ); X+ bzero( &last, sizeof(cur) ); X+ X+ cur.dinfo = (struct devinfo *)malloc( sizeof(struct devinfo) ); X+ last.dinfo = (struct devinfo *)malloc( sizeof(struct devinfo) ); X X! bzero( cur.dinfo, sizeof(struct devinfo) ); X! bzero( last.dinfo, sizeof(struct devinfo) ); X! X! specified_devices = (char **)malloc(sizeof(char *)); X! } X! else X! { X! struct devinfo *tmp; X! X! if (kvmd==NULL) kvmd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf); X! if (kvmd==NULL) X! { X! fprintf(stderr, "kvm_openfiles: %s\n", errbuf); X! exit(errno); X! } X! else X! { X! (void)kvm_read( kvmd, nl[N_TK_NIN].n_value, &cur.tk_nin, X! sizeof(cur.tk_nin) ); X! (void)kvm_read( kvmd, nl[N_TK_NOUT].n_value, &cur.tk_nout, X! sizeof(cur.tk_nout) ); X! (void)kvm_read( kvmd, nl[N_CP_TIME].n_value, X! cur.cp_time, sizeof(cur.cp_time) ); X! } X! X! tmp = last.dinfo; X! memcpy( &last, &cur, sizeof(cur) ); X! cur.dinfo = tmp; X! X! last.busy_time = cur.busy_time; X! } X! X! if( !gotdevs && ( getdevs( &cur ) >= 0 ) ) X! gotdevs = 1; X! X! if( gotdevs ) X! { X! generation = cur.dinfo->generation; X! ndevs = cur.dinfo->numdevs; X! X! if( !initted ) X! { X! selectdevs( &dev_select, &num_selected, &num_selections, X! &select_generation, generation, cur.dinfo->devices, X! ndevs, matches, num_matches, specified_devices, X! num_devices_specified, DS_SELECT_ONLY, maxshowdevs, X! 1 ); X! } X! else X! { X! struct devinfo *tmpinfo; X! long tmp; X! X! switch( getdevs( &cur ) ) X! { X! case 1: X! selectdevs( &dev_select, &num_selected, X! &num_selections, &select_generation, X! generation, cur.dinfo->devices, X! ndevs, matches, num_matches, X! specified_devices, X! num_devices_specified, X! DS_SELECT_ONLY, X! maxshowdevs, 1 ); X! X! if (kvmd==NULL) X! { X! fprintf(stderr, "kvm_openfiles: %s\n", errbuf); X! exit(errno); X! } X! else X! { X! (void)kvm_read( kvmd, nl[N_TK_NIN].n_value, &cur.tk_nin, X! sizeof(cur.tk_nin) ); X! (void)kvm_read( kvmd, nl[N_TK_NOUT].n_value, &cur.tk_nout, X! sizeof(cur.tk_nout) ); X! (void)kvm_read( kvmd, nl[N_CP_TIME].n_value, X! cur.cp_time, sizeof(cur.cp_time) ); X! } X! X! tmpinfo = last.dinfo; X! memcpy( &last, &cur, sizeof(cur) ); X! cur.dinfo = tmpinfo; X! X! last.busy_time = cur.busy_time; X! break; X! default: X! break; X! } X! X! selectdevs( &dev_select, &num_selected, &num_selections, X! &select_generation, generation, cur.dinfo->devices, X! ndevs, matches, num_matches, specified_devices, X! num_devices_specified, DS_SELECT_ONLY, maxshowdevs, X! 1 ); X! X! tmp = cur.tk_nin; X! cur.tk_nin -= last.tk_nin; X! last.tk_nin = tmp; X! tmp = cur.tk_nout; X! cur.tk_nout -= last.tk_nout; X! last.tk_nout = tmp; X! X! { X! register int dn; X! long double transfers_per_second; X! long double kb_per_transfer, mb_per_second; X! u_int64_t total_bytes, total_transfers, total_blocks; X! long double busy_seconds; X! long double blocks_per_second, ms_per_transaction; X! X! busy_seconds = compute_etime( cur.busy_time, last.busy_time ); X! X! for( dn = 0; dn < ndevs; dn++ ) X! { X! int di = dev_select[dn].position; X! X! if( compute_stats( &cur.dinfo->devices[di], X! &last.dinfo->devices[di], X! busy_seconds, X! &total_bytes, X! &total_transfers, X! &total_blocks, X! &kb_per_transfer, X! &transfers_per_second, X! &mb_per_second, X! &blocks_per_second, X! &ms_per_transaction ) == 0 ) X! { X! *ds += total_blocks; X! } X! } X } X } X+ initted = 1; X } X+ X+ if( dev_select ) X+ free( dev_select ); X+ #endif X if (*ds > maxdiskio) maxdiskio = *ds; X } X } X*************** X*** 597,605 **** X X int checksysdevs(void) { X X! strcpy(stat_device[0].name, "cpu0"); X! strcpy(stat_device[1].name, "i/o"); X! strcpy(stat_device[2].name, "sys"); X X return 3; X } X--- 1095,1103 ---- X X int checksysdevs(void) { X X! strncpy(stat_device[0].name, "cpu0", 5); X! strncpy(stat_device[1].name, "i/o", 5); X! strncpy(stat_device[2].name, "sys", 5); X X return 3; X } X*************** X*** 638,643 **** X--- 1136,1142 ---- X int *p; X int d; X X+ /* printf ("size = %d, num = %d\n", size, num); */ X pixels_per_byte = 100; X p = his; X for (j=0; j<num; j++) { END-of-ports/sysutils/wmmon/patches/patch-ad exit >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199906280142.VAA00558>