summaryrefslogtreecommitdiffstats
path: root/usr.bin/systat
diff options
context:
space:
mode:
authorken <ken@FreeBSD.org>2001-09-06 04:06:12 +0000
committerken <ken@FreeBSD.org>2001-09-06 04:06:12 +0000
commitbbe705923488b97d69baddbb4282e83ecc07b587 (patch)
tree9770eb2bb465edd2523b9ce799dff2334316382c /usr.bin/systat
parentf729fe0a4a07f77cf2a60a88614a01b6bd649256 (diff)
downloadFreeBSD-src-bbe705923488b97d69baddbb4282e83ecc07b587.zip
FreeBSD-src-bbe705923488b97d69baddbb4282e83ecc07b587.tar.gz
Convert systat(1) to use the new devstat interface.
Submitted by: "Sergey A. Osokin" <osa@freebsd.org.ru>
Diffstat (limited to 'usr.bin/systat')
-rw-r--r--usr.bin/systat/devs.c55
-rw-r--r--usr.bin/systat/iostat.c15
-rw-r--r--usr.bin/systat/vmstat.c29
3 files changed, 46 insertions, 53 deletions
diff --git a/usr.bin/systat/devs.c b/usr.bin/systat/devs.c
index 6f9c811..1f2ee87 100644
--- a/usr.bin/systat/devs.c
+++ b/usr.bin/systat/devs.c
@@ -109,7 +109,7 @@ dsinit(int maxshowdevs, struct statinfo *s1, struct statinfo *s2,
* devstat version. If not, exit and print a message informing
* the user of his mistake.
*/
- if (checkversion() < 0)
+ if (devstat_checkversion(NULL) < 0)
errx(1, "%s", devstat_errbuf);
generation = 0;
@@ -119,7 +119,7 @@ dsinit(int maxshowdevs, struct statinfo *s1, struct statinfo *s2,
select_generation = 0;
last_type = DS_MATCHTYPE_NONE;
- if (getdevs(s1) == -1)
+ if (devstat_getdevs(NULL, s1) == -1)
errx(1, "%s", devstat_errbuf);
num_devices = s1->dinfo->numdevs;
@@ -132,10 +132,9 @@ dsinit(int maxshowdevs, struct statinfo *s1, struct statinfo *s2,
* device list has changed, so we don't look for return values of 0
* or 1. If we get back -1, though, there is an error.
*/
- if (selectdevs(&dev_select, &num_selected, &num_selections,
- &select_generation, generation, s1->dinfo->devices,
- num_devices, NULL, 0, NULL, 0, DS_SELECT_ADD,
- maxshowdevs, 0) == -1)
+ if (devstat_selectdevs(&dev_select, &num_selected, &num_selections,
+ &select_generation, generation, s1->dinfo->devices, num_devices,
+ NULL, 0, NULL, 0, DS_SELECT_ADD, maxshowdevs, 0) == -1)
errx(1, "%s", devstat_errbuf);
return(1);
@@ -155,20 +154,15 @@ dscmd(char *cmd, char *args, int maxshowdevs, struct statinfo *s1)
if (prefix(cmd, "type") || prefix(cmd, "match"))
return(dsmatchselect(args, DS_SELECT_ONLY, maxshowdevs, s1));
if (prefix(cmd, "refresh")) {
- retval = selectdevs(&dev_select, &num_selected, &num_selections,
- &select_generation, generation,
- s1->dinfo->devices, num_devices,
- (last_type == DS_MATCHTYPE_PATTERN) ?
- matches : NULL,
- (last_type == DS_MATCHTYPE_PATTERN) ?
- num_matches : 0,
- (last_type == DS_MATCHTYPE_SPEC) ?
- specified_devices : NULL,
- (last_type == DS_MATCHTYPE_SPEC) ?
- num_devices_specified : 0,
- (last_type == DS_MATCHTYPE_NONE) ?
- DS_SELECT_ADD : DS_SELECT_ADDONLY,
- maxshowdevs, 0);
+ retval = devstat_selectdevs(&dev_select, &num_selected,
+ &num_selections, &select_generation, generation,
+ s1->dinfo->devices, num_devices,
+ (last_type ==DS_MATCHTYPE_PATTERN) ? matches : NULL,
+ (last_type ==DS_MATCHTYPE_PATTERN) ? num_matches : 0,
+ (last_type == DS_MATCHTYPE_SPEC) ?specified_devices : NULL,
+ (last_type == DS_MATCHTYPE_SPEC) ?num_devices_specified : 0,
+ (last_type == DS_MATCHTYPE_NONE) ? DS_SELECT_ADD :
+ DS_SELECT_ADDONLY, maxshowdevs, 0);
if (retval == -1) {
warnx("%s", devstat_errbuf);
return(0);
@@ -225,7 +219,7 @@ dsmatchselect(char *args, devstat_select_mode select_mode, int maxshowdevs,
}
for (i = 0; i < num_args; i++) {
- if (buildmatch(tstr[i], &matches, &num_matches) != 0) {
+ if (devstat_buildmatch(tstr[i], &matches, &num_matches) != 0) {
warnx("%s", devstat_errbuf);
return(0);
}
@@ -234,11 +228,10 @@ dsmatchselect(char *args, devstat_select_mode select_mode, int maxshowdevs,
last_type = DS_MATCHTYPE_PATTERN;
- retval = selectdevs(&dev_select, &num_selected, &num_selections,
- &select_generation, generation,
- s1->dinfo->devices, num_devices, matches,
- num_matches, NULL, 0, select_mode,
- maxshowdevs, 0);
+ retval = devstat_selectdevs(&dev_select, &num_selected,
+ &num_selections, &select_generation, generation,
+ s1->dinfo->devices, num_devices, matches, num_matches,
+ NULL, 0, select_mode, maxshowdevs, 0);
if (retval == -1)
err(1, "device selection error");
else if (retval == 1)
@@ -311,11 +304,11 @@ dsselect(char *args, devstat_select_mode select_mode, int maxshowdevs,
if (num_devices_specified > 0) {
last_type = DS_MATCHTYPE_SPEC;
- retval = selectdevs(&dev_select, &num_selected, &num_selections,
- &select_generation, generation,
- s1->dinfo->devices, num_devices, NULL, 0,
- specified_devices, num_devices_specified,
- select_mode, maxshowdevs, 0);
+ retval = devstat_selectdevs(&dev_select, &num_selected,
+ &num_selections, &select_generation, generation,
+ s1->dinfo->devices, num_devices, NULL, 0,
+ specified_devices, num_devices_specified,
+ select_mode, maxshowdevs, 0);
if (retval == -1)
err(1, "%s", devstat_errbuf);
else if (retval == 1)
diff --git a/usr.bin/systat/iostat.c b/usr.bin/systat/iostat.c
index 44e3b0c..0e3c1d6 100644
--- a/usr.bin/systat/iostat.c
+++ b/usr.bin/systat/iostat.c
@@ -111,7 +111,7 @@ closeiostat(w)
int
initiostat()
{
- if ((num_devices = getnumdevs()) < 0)
+ if ((num_devices = devstat_getnumdevs(NULL)) < 0)
return(0);
cur.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo));
@@ -155,7 +155,7 @@ fetchiostat()
* the selection process again, in case a device that we
* were previously displaying has gone away.
*/
- switch (getdevs(&cur)) {
+ switch (devstat_getdevs(NULL, &cur)) {
case -1:
errx(1, "%s", devstat_errbuf);
break;
@@ -320,12 +320,13 @@ devstats(row, col, dn)
di = dev_select[dn].position;
- busy_seconds = compute_etime(cur.busy_time, last.busy_time);
+ busy_seconds = devstat_compute_etime(cur.busy_time, last.busy_time);
- if (compute_stats(&cur.dinfo->devices[di], &last.dinfo->devices[di],
- busy_seconds, NULL, NULL, NULL,
- &kb_per_transfer, &transfers_per_second,
- &mb_per_second, NULL, NULL) != 0)
+ if (devstat_compute_statistics(&cur.dinfo->devices[di],
+ &last.dinfo->devices[di], busy_seconds,
+ DSM_KB_PER_TRANSFER, &kb_per_transfer,
+ DSM_TRANSFERS_PER_SECOND, &transfers_per_second,
+ DSM_MB_PER_SECOND, &mb_per_second, DSM_NONE) != 0)
errx(1, "%s", devstat_errbuf);
if (numbers) {
diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c
index 9a3fc02..d45e2b8 100644
--- a/usr.bin/systat/vmstat.c
+++ b/usr.bin/systat/vmstat.c
@@ -211,7 +211,7 @@ initkre()
int i;
size_t sz;
- if ((num_devices = getnumdevs()) < 0) {
+ if ((num_devices = devstat_getnumdevs(NULL)) < 0) {
warnx("%s", devstat_errbuf);
return(0);
}
@@ -571,7 +571,7 @@ cmdkre(cmd, args)
if (prefix(cmd, "run")) {
retval = 1;
copyinfo(&s2, &s1);
- switch (getdevs(&run)) {
+ switch (devstat_getdevs(NULL, &run)) {
case -1:
errx(1, "%s", devstat_errbuf);
break;
@@ -601,7 +601,7 @@ cmdkre(cmd, args)
retval = 1;
if (state == RUN) {
getinfo(&s1, RUN);
- switch (getdevs(&run)) {
+ switch (devstat_getdevs(NULL, &run)) {
case -1:
errx(1, "%s", devstat_errbuf);
break;
@@ -792,7 +792,7 @@ getinfo(s, st)
cur.dinfo = tmp_dinfo;
last.busy_time = cur.busy_time;
- switch (getdevs(&cur)) {
+ switch (devstat_getdevs(NULL, &cur)) {
case -1:
errx(1, "%s", devstat_errbuf);
break;
@@ -845,19 +845,18 @@ dinfo(dn, c, now, then)
di = dev_select[dn].position;
- elapsed_time = compute_etime(now->busy_time, then ?
- then->busy_time :
- now->dinfo->devices[di].dev_creation_time);
+ elapsed_time = devstat_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);
+ device_busy = devstat_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, &transfers_per_second,
- &mb_per_second, NULL, NULL) != 0)
+ 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_NONE) != 0)
errx(1, "%s", devstat_errbuf);
if ((device_busy == 0) && (transfers_per_second > 5))
OpenPOWER on IntegriCloud