1998-09-15 08:16:45 +00:00
|
|
|
/*
|
2017-11-20 19:49:47 +00:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*
|
1998-09-15 08:16:45 +00:00
|
|
|
* Copyright (c) 1998 Kenneth D. Merry.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
1994-05-27 12:33:43 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1980, 1992, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2017-02-28 23:42:47 +00:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1994-05-27 12:33:43 +00:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2001-12-12 00:13:37 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
#ifdef lint
|
|
|
|
static const char sccsid[] = "@(#)iostat.c 8.1 (Berkeley) 6/6/93";
|
|
|
|
#endif
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
2001-03-23 03:58:25 +00:00
|
|
|
#include <sys/sysctl.h>
|
2003-02-16 15:46:25 +00:00
|
|
|
#include <sys/resource.h>
|
1994-05-27 12:33:43 +00:00
|
|
|
|
1998-09-15 08:16:45 +00:00
|
|
|
#include <devstat.h>
|
1998-10-08 09:56:10 +00:00
|
|
|
#include <err.h>
|
2001-12-12 00:13:37 +00:00
|
|
|
#include <nlist.h>
|
2009-12-13 03:14:06 +00:00
|
|
|
#include <paths.h>
|
2001-12-12 00:13:37 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
#include "systat.h"
|
|
|
|
#include "extern.h"
|
1998-10-08 09:56:10 +00:00
|
|
|
#include "devs.h"
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
static int linesperregion;
|
|
|
|
static double etime;
|
|
|
|
static int numbers = 0; /* default display bar graphs */
|
1998-09-15 08:16:45 +00:00
|
|
|
static int kbpt = 0; /* default ms/seek shown */
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2002-03-22 01:42:45 +00:00
|
|
|
static int barlabels(int);
|
|
|
|
static void histogram(long double, int, double);
|
|
|
|
static int numlabels(int);
|
|
|
|
static int devstats(int, int, int);
|
|
|
|
static void stat1(int, int);
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
WINDOW *
|
2008-01-16 19:27:43 +00:00
|
|
|
openiostat(void)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2006-04-30 04:26:46 +00:00
|
|
|
return (subwin(stdscr, LINES-3-1, 0, MAINWIN_ROW, 0));
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-01-16 19:27:43 +00:00
|
|
|
closeiostat(WINDOW *w)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
|
|
|
if (w == NULL)
|
|
|
|
return;
|
|
|
|
wclear(w);
|
|
|
|
wrefresh(w);
|
|
|
|
delwin(w);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2008-01-16 19:27:43 +00:00
|
|
|
initiostat(void)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
1998-09-15 08:16:45 +00:00
|
|
|
/*
|
|
|
|
* This value for maxshowdevs (100) is bogus. I'm not sure exactly
|
|
|
|
* how to calculate it, though.
|
|
|
|
*/
|
2019-04-02 14:01:03 +00:00
|
|
|
if (dsinit(7) != 1)
|
1998-09-15 08:16:45 +00:00
|
|
|
return(0);
|
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-01-16 19:27:43 +00:00
|
|
|
fetchiostat(void)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
1998-09-15 08:16:45 +00:00
|
|
|
struct devinfo *tmp_dinfo;
|
2000-11-25 03:47:36 +00:00
|
|
|
size_t len;
|
|
|
|
|
2019-04-02 14:01:03 +00:00
|
|
|
len = sizeof(cur_dev.cp_time);
|
|
|
|
if (sysctlbyname("kern.cp_time", &cur_dev.cp_time, &len, NULL, 0)
|
|
|
|
|| len != sizeof(cur_dev.cp_time)) {
|
2000-11-25 03:47:36 +00:00
|
|
|
perror("kern.cp_time");
|
|
|
|
exit (1);
|
|
|
|
}
|
2019-04-02 14:01:03 +00:00
|
|
|
tmp_dinfo = last_dev.dinfo;
|
|
|
|
last_dev.dinfo = cur_dev.dinfo;
|
|
|
|
cur_dev.dinfo = tmp_dinfo;
|
2003-11-01 02:06:02 +00:00
|
|
|
|
2019-04-02 14:01:03 +00:00
|
|
|
last_dev.snap_time = cur_dev.snap_time;
|
2006-04-30 04:47:23 +00:00
|
|
|
|
1998-09-15 08:16:45 +00:00
|
|
|
/*
|
|
|
|
* Here what we want to do is refresh our device stats.
|
|
|
|
* getdevs() returns 1 when the device list has changed.
|
|
|
|
* If the device list has changed, we want to go through
|
|
|
|
* the selection process again, in case a device that we
|
|
|
|
* were previously displaying has gone away.
|
|
|
|
*/
|
2019-04-02 14:01:03 +00:00
|
|
|
switch (devstat_getdevs(NULL, &cur_dev)) {
|
1998-09-15 08:16:45 +00:00
|
|
|
case -1:
|
|
|
|
errx(1, "%s", devstat_errbuf);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
cmdiostat("refresh", NULL);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2019-04-02 14:01:03 +00:00
|
|
|
num_devices = cur_dev.dinfo->numdevs;
|
|
|
|
generation = cur_dev.dinfo->generation;
|
1998-09-15 08:16:45 +00:00
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define INSET 10
|
|
|
|
|
|
|
|
void
|
2008-01-16 19:27:43 +00:00
|
|
|
labeliostat(void)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
|
|
|
int row;
|
|
|
|
|
|
|
|
row = 0;
|
|
|
|
wmove(wnd, row, 0); wclrtobot(wnd);
|
|
|
|
mvwaddstr(wnd, row++, INSET,
|
2006-11-27 20:19:05 +00:00
|
|
|
"/0% /10 /20 /30 /40 /50 /60 /70 /80 /90 /100");
|
1994-05-27 12:33:43 +00:00
|
|
|
mvwaddstr(wnd, row++, 0, "cpu user|");
|
|
|
|
mvwaddstr(wnd, row++, 0, " nice|");
|
|
|
|
mvwaddstr(wnd, row++, 0, " system|");
|
1994-12-03 10:06:40 +00:00
|
|
|
mvwaddstr(wnd, row++, 0, "interrupt|");
|
1994-05-27 12:33:43 +00:00
|
|
|
mvwaddstr(wnd, row++, 0, " idle|");
|
|
|
|
if (numbers)
|
|
|
|
row = numlabels(row + 1);
|
|
|
|
else
|
|
|
|
row = barlabels(row + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2008-01-16 19:27:43 +00:00
|
|
|
numlabels(int row)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2001-12-12 00:13:37 +00:00
|
|
|
int i, _col, regions, ndrives;
|
1998-09-15 08:16:45 +00:00
|
|
|
char tmpstr[10];
|
1994-05-27 12:33:43 +00:00
|
|
|
|
1998-09-15 08:16:45 +00:00
|
|
|
#define COLWIDTH 17
|
2015-09-10 22:07:52 +00:00
|
|
|
#define DRIVESPERLINE ((getmaxx(wnd) - 1 - INSET) / COLWIDTH)
|
1998-09-15 08:16:45 +00:00
|
|
|
for (ndrives = 0, i = 0; i < num_devices; i++)
|
|
|
|
if (dev_select[i].selected)
|
1994-05-27 12:33:43 +00:00
|
|
|
ndrives++;
|
|
|
|
regions = howmany(ndrives, DRIVESPERLINE);
|
|
|
|
/*
|
|
|
|
* Deduct -regions for blank line after each scrolling region.
|
|
|
|
*/
|
2015-09-10 22:07:52 +00:00
|
|
|
linesperregion = (getmaxy(wnd) - 1 - row - regions) / regions;
|
1994-05-27 12:33:43 +00:00
|
|
|
/*
|
|
|
|
* Minimum region contains space for two
|
|
|
|
* label lines and one line of statistics.
|
|
|
|
*/
|
|
|
|
if (linesperregion < 3)
|
|
|
|
linesperregion = 3;
|
2001-12-12 00:13:37 +00:00
|
|
|
_col = INSET;
|
1998-09-15 08:16:45 +00:00
|
|
|
for (i = 0; i < num_devices; i++)
|
|
|
|
if (dev_select[i].selected) {
|
2015-09-10 22:07:52 +00:00
|
|
|
if (_col + COLWIDTH >= getmaxx(wnd) - 1 - INSET) {
|
2001-12-12 00:13:37 +00:00
|
|
|
_col = INSET, row += linesperregion + 1;
|
2015-09-10 22:07:52 +00:00
|
|
|
if (row > getmaxy(wnd) - 1 - (linesperregion + 1))
|
1994-05-27 12:33:43 +00:00
|
|
|
break;
|
|
|
|
}
|
1998-09-15 08:16:45 +00:00
|
|
|
sprintf(tmpstr, "%s%d", dev_select[i].device_name,
|
|
|
|
dev_select[i].unit_number);
|
2001-12-12 00:13:37 +00:00
|
|
|
mvwaddstr(wnd, row, _col + 4, tmpstr);
|
|
|
|
mvwaddstr(wnd, row + 1, _col, " KB/t tps MB/s ");
|
|
|
|
_col += COLWIDTH;
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
2001-12-12 00:13:37 +00:00
|
|
|
if (_col)
|
1994-05-27 12:33:43 +00:00
|
|
|
row += linesperregion + 1;
|
|
|
|
return (row);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2008-01-16 19:27:43 +00:00
|
|
|
barlabels(int row)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
|
|
|
int i;
|
1998-09-15 08:16:45 +00:00
|
|
|
char tmpstr[10];
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
mvwaddstr(wnd, row++, INSET,
|
2006-11-27 20:19:05 +00:00
|
|
|
"/0% /10 /20 /30 /40 /50 /60 /70 /80 /90 /100");
|
1998-09-15 08:16:45 +00:00
|
|
|
linesperregion = 2 + kbpt;
|
|
|
|
for (i = 0; i < num_devices; i++)
|
|
|
|
if (dev_select[i].selected) {
|
2015-09-10 22:07:52 +00:00
|
|
|
if (row > getmaxy(wnd) - 1 - linesperregion)
|
1994-05-27 12:33:43 +00:00
|
|
|
break;
|
1998-09-15 08:16:45 +00:00
|
|
|
sprintf(tmpstr, "%s%d", dev_select[i].device_name,
|
|
|
|
dev_select[i].unit_number);
|
2006-04-30 04:47:23 +00:00
|
|
|
mvwprintw(wnd, row++, 0, "%-5.5s MB/s|",
|
1998-09-15 08:16:45 +00:00
|
|
|
tmpstr);
|
1994-05-27 12:33:43 +00:00
|
|
|
mvwaddstr(wnd, row++, 0, " tps|");
|
1998-09-15 08:16:45 +00:00
|
|
|
if (kbpt)
|
|
|
|
mvwaddstr(wnd, row++, 0, " KB/t|");
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
return (row);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-01-16 19:27:43 +00:00
|
|
|
showiostat(void)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2001-12-12 00:13:37 +00:00
|
|
|
long t;
|
|
|
|
int i, row, _col;
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2019-04-02 14:01:03 +00:00
|
|
|
#define X(fld) t = cur_dev.fld[i]; cur_dev.fld[i] -= last_dev.fld[i]; last_dev.fld[i] = t
|
1994-05-27 12:33:43 +00:00
|
|
|
etime = 0;
|
|
|
|
for(i = 0; i < CPUSTATES; i++) {
|
|
|
|
X(cp_time);
|
2019-04-02 14:01:03 +00:00
|
|
|
etime += cur_dev.cp_time[i];
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
if (etime == 0.0)
|
|
|
|
etime = 1.0;
|
1994-12-03 10:06:40 +00:00
|
|
|
etime /= hertz;
|
1994-05-27 12:33:43 +00:00
|
|
|
row = 1;
|
1994-12-03 10:06:40 +00:00
|
|
|
for (i = 0; i < CPUSTATES; i++)
|
1994-05-27 12:33:43 +00:00
|
|
|
stat1(row++, i);
|
|
|
|
if (!numbers) {
|
|
|
|
row += 2;
|
1998-09-15 08:16:45 +00:00
|
|
|
for (i = 0; i < num_devices; i++)
|
|
|
|
if (dev_select[i].selected) {
|
2015-09-10 22:07:52 +00:00
|
|
|
if (row > getmaxy(wnd) - linesperregion)
|
1994-05-27 12:33:43 +00:00
|
|
|
break;
|
1998-09-15 08:16:45 +00:00
|
|
|
row = devstats(row, INSET, i);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2001-12-12 00:13:37 +00:00
|
|
|
_col = INSET;
|
1994-05-27 12:33:43 +00:00
|
|
|
wmove(wnd, row + linesperregion, 0);
|
|
|
|
wdeleteln(wnd);
|
|
|
|
wmove(wnd, row + 3, 0);
|
|
|
|
winsertln(wnd);
|
1998-09-15 08:16:45 +00:00
|
|
|
for (i = 0; i < num_devices; i++)
|
|
|
|
if (dev_select[i].selected) {
|
2015-09-10 22:07:52 +00:00
|
|
|
if (_col + COLWIDTH >= getmaxx(wnd) - 1 - INSET) {
|
2001-12-12 00:13:37 +00:00
|
|
|
_col = INSET, row += linesperregion + 1;
|
2015-09-10 22:07:52 +00:00
|
|
|
if (row > getmaxy(wnd) - 1 - (linesperregion + 1))
|
1994-05-27 12:33:43 +00:00
|
|
|
break;
|
|
|
|
wmove(wnd, row + linesperregion, 0);
|
|
|
|
wdeleteln(wnd);
|
|
|
|
wmove(wnd, row + 3, 0);
|
|
|
|
winsertln(wnd);
|
|
|
|
}
|
2001-12-12 00:13:37 +00:00
|
|
|
(void) devstats(row + 3, _col, i);
|
|
|
|
_col += COLWIDTH;
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2008-01-16 19:27:43 +00:00
|
|
|
devstats(int row, int _col, int dn)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
1998-09-15 08:16:45 +00:00
|
|
|
long double transfers_per_second;
|
|
|
|
long double kb_per_transfer, mb_per_second;
|
|
|
|
long double busy_seconds;
|
|
|
|
int di;
|
2006-04-30 04:47:23 +00:00
|
|
|
|
1998-09-15 08:16:45 +00:00
|
|
|
di = dev_select[dn].position;
|
|
|
|
|
2019-04-02 14:01:03 +00:00
|
|
|
busy_seconds = cur_dev.snap_time - last_dev.snap_time;
|
1998-09-15 08:16:45 +00:00
|
|
|
|
2019-04-02 14:01:03 +00:00
|
|
|
if (devstat_compute_statistics(&cur_dev.dinfo->devices[di],
|
|
|
|
&last_dev.dinfo->devices[di], busy_seconds,
|
2001-09-06 04:06:12 +00:00
|
|
|
DSM_KB_PER_TRANSFER, &kb_per_transfer,
|
|
|
|
DSM_TRANSFERS_PER_SECOND, &transfers_per_second,
|
|
|
|
DSM_MB_PER_SECOND, &mb_per_second, DSM_NONE) != 0)
|
1998-09-15 08:16:45 +00:00
|
|
|
errx(1, "%s", devstat_errbuf);
|
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
if (numbers) {
|
2001-12-12 00:13:37 +00:00
|
|
|
mvwprintw(wnd, row, _col, " %5.2Lf %3.0Lf %5.2Lf ",
|
1998-09-15 08:16:45 +00:00
|
|
|
kb_per_transfer, transfers_per_second,
|
|
|
|
mb_per_second);
|
|
|
|
return(row);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
2001-12-12 00:13:37 +00:00
|
|
|
wmove(wnd, row++, _col);
|
2000-06-01 08:49:46 +00:00
|
|
|
histogram(mb_per_second, 50, .5);
|
2001-12-12 00:13:37 +00:00
|
|
|
wmove(wnd, row++, _col);
|
2000-06-01 08:49:46 +00:00
|
|
|
histogram(transfers_per_second, 50, .5);
|
1998-09-15 08:16:45 +00:00
|
|
|
if (kbpt) {
|
2001-12-12 00:13:37 +00:00
|
|
|
wmove(wnd, row++, _col);
|
2000-06-01 08:49:46 +00:00
|
|
|
histogram(kb_per_transfer, 50, .5);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
1998-09-15 08:16:45 +00:00
|
|
|
|
|
|
|
return(row);
|
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-01-16 19:27:43 +00:00
|
|
|
stat1(int row, int o)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2001-12-12 00:13:37 +00:00
|
|
|
int i;
|
|
|
|
double dtime;
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2001-12-12 00:13:37 +00:00
|
|
|
dtime = 0.0;
|
1994-05-27 12:33:43 +00:00
|
|
|
for (i = 0; i < CPUSTATES; i++)
|
2019-04-02 14:01:03 +00:00
|
|
|
dtime += cur_dev.cp_time[i];
|
2001-12-12 00:13:37 +00:00
|
|
|
if (dtime == 0.0)
|
|
|
|
dtime = 1.0;
|
1994-05-27 12:33:43 +00:00
|
|
|
wmove(wnd, row, INSET);
|
|
|
|
#define CPUSCALE 0.5
|
2019-04-02 14:01:03 +00:00
|
|
|
histogram(100.0 * cur_dev.cp_time[o] / dtime, 50, CPUSCALE);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-01-16 19:27:43 +00:00
|
|
|
histogram(long double val, int colwidth, double scale)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
|
|
|
char buf[10];
|
2001-12-12 00:13:37 +00:00
|
|
|
int k;
|
|
|
|
int v = (int)(val * scale) + 0.5;
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
k = MIN(v, colwidth);
|
|
|
|
if (v > colwidth) {
|
1998-09-15 08:16:45 +00:00
|
|
|
snprintf(buf, sizeof(buf), "%5.2Lf", val);
|
1994-05-27 12:33:43 +00:00
|
|
|
k -= strlen(buf);
|
|
|
|
while (k--)
|
|
|
|
waddch(wnd, 'X');
|
|
|
|
waddstr(wnd, buf);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
while (k--)
|
|
|
|
waddch(wnd, 'X');
|
|
|
|
wclrtoeol(wnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2008-01-16 19:27:43 +00:00
|
|
|
cmdiostat(const char *cmd, const char *args)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
|
|
|
|
1998-09-15 08:16:45 +00:00
|
|
|
if (prefix(cmd, "kbpt"))
|
|
|
|
kbpt = !kbpt;
|
1994-05-27 12:33:43 +00:00
|
|
|
else if (prefix(cmd, "numbers"))
|
|
|
|
numbers = 1;
|
|
|
|
else if (prefix(cmd, "bars"))
|
|
|
|
numbers = 0;
|
2019-04-02 14:01:03 +00:00
|
|
|
else if (!dscmd(cmd, args, 100, &cur_dev))
|
1994-05-27 12:33:43 +00:00
|
|
|
return (0);
|
|
|
|
wclear(wnd);
|
|
|
|
labeliostat();
|
|
|
|
refresh();
|
|
|
|
return (1);
|
|
|
|
}
|