Deleted Added
full compact
iostat.c (158160) iostat.c (158161)
1/*
2 * Copyright (c) 1998 Kenneth D. Merry.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 46 unchanged lines hidden (view full) ---

55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 */
60
61#include <sys/cdefs.h>
62
1/*
2 * Copyright (c) 1998 Kenneth D. Merry.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 46 unchanged lines hidden (view full) ---

55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 */
60
61#include <sys/cdefs.h>
62
63__FBSDID("$FreeBSD: head/usr.bin/systat/iostat.c 158160 2006-04-30 04:26:46Z bde $");
63__FBSDID("$FreeBSD: head/usr.bin/systat/iostat.c 158161 2006-04-30 04:47:23Z bde $");
64
65#ifdef lint
66static const char sccsid[] = "@(#)iostat.c 8.1 (Berkeley) 6/6/93";
67#endif
68
69#include <sys/param.h>
70#include <sys/sysctl.h>
71#include <sys/resource.h>

--- 44 unchanged lines hidden (view full) ---

116{
117 if ((num_devices = devstat_getnumdevs(NULL)) < 0)
118 return(0);
119
120 cur.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo));
121 last.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo));
122 bzero(cur.dinfo, sizeof(struct devinfo));
123 bzero(last.dinfo, sizeof(struct devinfo));
64
65#ifdef lint
66static const char sccsid[] = "@(#)iostat.c 8.1 (Berkeley) 6/6/93";
67#endif
68
69#include <sys/param.h>
70#include <sys/sysctl.h>
71#include <sys/resource.h>

--- 44 unchanged lines hidden (view full) ---

116{
117 if ((num_devices = devstat_getnumdevs(NULL)) < 0)
118 return(0);
119
120 cur.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo));
121 last.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo));
122 bzero(cur.dinfo, sizeof(struct devinfo));
123 bzero(last.dinfo, sizeof(struct devinfo));
124
124
125 /*
126 * This value for maxshowdevs (100) is bogus. I'm not sure exactly
127 * how to calculate it, though.
128 */
129 if (dsinit(100, &cur, &last, NULL) != 1)
130 return(0);
131
132 return(1);

--- 11 unchanged lines hidden (view full) ---

144 perror("kern.cp_time");
145 exit (1);
146 }
147 tmp_dinfo = last.dinfo;
148 last.dinfo = cur.dinfo;
149 cur.dinfo = tmp_dinfo;
150
151 last.snap_time = cur.snap_time;
125 /*
126 * This value for maxshowdevs (100) is bogus. I'm not sure exactly
127 * how to calculate it, though.
128 */
129 if (dsinit(100, &cur, &last, NULL) != 1)
130 return(0);
131
132 return(1);

--- 11 unchanged lines hidden (view full) ---

144 perror("kern.cp_time");
145 exit (1);
146 }
147 tmp_dinfo = last.dinfo;
148 last.dinfo = cur.dinfo;
149 cur.dinfo = tmp_dinfo;
150
151 last.snap_time = cur.snap_time;
152
152
153 /*
154 * Here what we want to do is refresh our device stats.
155 * getdevs() returns 1 when the device list has changed.
156 * If the device list has changed, we want to go through
157 * the selection process again, in case a device that we
158 * were previously displaying has gone away.
159 */
160 switch (devstat_getdevs(NULL, &cur)) {

--- 86 unchanged lines hidden (view full) ---

247 "/0 /10 /20 /30 /40 /50 /60 /70 /80 /90 /100");
248 linesperregion = 2 + kbpt;
249 for (i = 0; i < num_devices; i++)
250 if (dev_select[i].selected) {
251 if (row > wnd->_maxy - linesperregion)
252 break;
253 sprintf(tmpstr, "%s%d", dev_select[i].device_name,
254 dev_select[i].unit_number);
153 /*
154 * Here what we want to do is refresh our device stats.
155 * getdevs() returns 1 when the device list has changed.
156 * If the device list has changed, we want to go through
157 * the selection process again, in case a device that we
158 * were previously displaying has gone away.
159 */
160 switch (devstat_getdevs(NULL, &cur)) {

--- 86 unchanged lines hidden (view full) ---

247 "/0 /10 /20 /30 /40 /50 /60 /70 /80 /90 /100");
248 linesperregion = 2 + kbpt;
249 for (i = 0; i < num_devices; i++)
250 if (dev_select[i].selected) {
251 if (row > wnd->_maxy - linesperregion)
252 break;
253 sprintf(tmpstr, "%s%d", dev_select[i].device_name,
254 dev_select[i].unit_number);
255 mvwprintw(wnd, row++, 0, "%-5.5s MB/s|",
255 mvwprintw(wnd, row++, 0, "%-5.5s MB/s|",
256 tmpstr);
257 mvwaddstr(wnd, row++, 0, " tps|");
258 if (kbpt)
259 mvwaddstr(wnd, row++, 0, " KB/t|");
260 }
261 return (row);
262}
263

--- 50 unchanged lines hidden (view full) ---

314static int
315devstats(row, _col, dn)
316 int row, _col, dn;
317{
318 long double transfers_per_second;
319 long double kb_per_transfer, mb_per_second;
320 long double busy_seconds;
321 int di;
256 tmpstr);
257 mvwaddstr(wnd, row++, 0, " tps|");
258 if (kbpt)
259 mvwaddstr(wnd, row++, 0, " KB/t|");
260 }
261 return (row);
262}
263

--- 50 unchanged lines hidden (view full) ---

314static int
315devstats(row, _col, dn)
316 int row, _col, dn;
317{
318 long double transfers_per_second;
319 long double kb_per_transfer, mb_per_second;
320 long double busy_seconds;
321 int di;
322
322
323 di = dev_select[dn].position;
324
325 busy_seconds = cur.snap_time - last.snap_time;
326
327 if (devstat_compute_statistics(&cur.dinfo->devices[di],
328 &last.dinfo->devices[di], busy_seconds,
329 DSM_KB_PER_TRANSFER, &kb_per_transfer,
330 DSM_TRANSFERS_PER_SECOND, &transfers_per_second,

--- 81 unchanged lines hidden ---
323 di = dev_select[dn].position;
324
325 busy_seconds = cur.snap_time - last.snap_time;
326
327 if (devstat_compute_statistics(&cur.dinfo->devices[di],
328 &last.dinfo->devices[di], busy_seconds,
329 DSM_KB_PER_TRANSFER, &kb_per_transfer,
330 DSM_TRANSFERS_PER_SECOND, &transfers_per_second,

--- 81 unchanged lines hidden ---