示例#1
0
static void
dinfo(int dn, int lc, struct statinfo *now, struct statinfo *then)
{
	long double transfers_per_second;
	long double kb_per_transfer, mb_per_second;
	long double elapsed_time, device_busy;
	int di;

	di = dev_select[dn].position;

	if (then != NULL) {
		/* Calculate relative to previous sample */
		elapsed_time = now->snap_time - then->snap_time;
	} else {
		/* Calculate relative to device creation */
		elapsed_time = now->snap_time - devstat_compute_etime(
		    &now->dinfo->devices[di].creation_time, NULL);
	}

	if (devstat_compute_statistics(&now->dinfo->devices[di], then ?
	    &then->dinfo->devices[di] : NULL, elapsed_time,
	    DSM_KB_PER_TRANSFER, &kb_per_transfer,
	    DSM_TRANSFERS_PER_SECOND, &transfers_per_second,
	    DSM_MB_PER_SECOND, &mb_per_second,
	    DSM_BUSY_PCT, &device_busy,
	    DSM_NONE) != 0)
		errx(1, "%s", devstat_errbuf);

	lc = DISKCOL + lc * 6;
	putlongdouble(kb_per_transfer, DISKROW + 1, lc, 5, 2, 0);
	putlongdouble(transfers_per_second, DISKROW + 2, lc, 5, 0, 0);
	putlongdouble(mb_per_second, DISKROW + 3, lc, 5, 2, 0);
	putlongdouble(device_busy, DISKROW + 4, lc, 5, 0, 0);
}
示例#2
0
static void
putlongdoublez(long double f, int l, int lc, int w, int d, int nz)
{
	char b[128];

	if (f == 0.0) {
		move(l, lc);
		sprintf(b, "%*.*s", w, w, "");
		addstr(b);
	} else {
		putlongdouble(f, l, lc, w, d, nz);
	}
}
示例#3
0
static void
dinfo(int dn, int lc, struct statinfo *now, struct statinfo *then)
{
	long double kb_per_transfer;
	long double transfers_per_secondr;
	long double transfers_per_secondw;
	long double mb_per_secondr;
	long double mb_per_secondw;
	long double elapsed_time, device_busy;
	int di;

	di = dev_select[dn].position;

	elapsed_time = compute_etime(now->busy_time, then ?
				     then->busy_time :
				     now->dinfo->devices[di].dev_creation_time);

	device_busy =  compute_etime(now->dinfo->devices[di].busy_time, then ?
				     then->dinfo->devices[di].busy_time :
				     now->dinfo->devices[di].dev_creation_time);

	if (compute_stats(
			  &now->dinfo->devices[di],
			  (then ? &then->dinfo->devices[di] : NULL),
			  elapsed_time,
			  NULL, NULL, NULL,
			  &kb_per_transfer,
			  NULL,
			  NULL,
			  NULL, NULL) != 0)
		errx(1, "%s", devstat_errbuf);

	if (compute_stats_read(
			  &now->dinfo->devices[di],
			  (then ? &then->dinfo->devices[di] : NULL),
			  elapsed_time,
			  NULL, NULL, NULL,
			  NULL,
			  &transfers_per_secondr,
			  &mb_per_secondr,
			  NULL, NULL) != 0)
		errx(1, "%s", devstat_errbuf);

	if (compute_stats_write(
			  &now->dinfo->devices[di],
			  (then ? &then->dinfo->devices[di] : NULL),
			  elapsed_time,
			  NULL, NULL, NULL,
			  NULL,
			  &transfers_per_secondw,
			  &mb_per_secondw,
			  NULL, NULL) != 0)
		errx(1, "%s", devstat_errbuf);

	if ((device_busy == 0) &&
	    (transfers_per_secondr > 5 || transfers_per_secondw > 5)) {
		/* the device has been 100% busy, fake it because
		 * as long as the device is 100% busy the busy_time
		 * field in the devstat struct is not updated */
		device_busy = elapsed_time;
	}
	if (device_busy > elapsed_time) {
		/* this normally happens after one or more periods
		 * where the device has been 100% busy, correct it */
		device_busy = elapsed_time;
	}

	lc = DISKCOL + lc * 6;
	putlongdoublez(kb_per_transfer, DISKROW + 1, lc, 5, 2, 0);
	putlongdoublez(transfers_per_secondr, DISKROW + 2, lc, 5, 0, 0);
	putlongdoublez(mb_per_secondr, DISKROW + 3, lc, 5, 2, 0);
	putlongdoublez(transfers_per_secondw, DISKROW + 4, lc, 5, 0, 0);
	putlongdoublez(mb_per_secondw, DISKROW + 5, lc, 5, 2, 0);
	putlongdouble(device_busy * 100 / elapsed_time,
				      DISKROW + 6, lc, 5, 0, 0);
}