View | Details | Raw Unified | Return to bug 237664 | Differences between
and this patch

Collapse All | Expand All

(-)b/usr.bin/systat/Makefile (-1 / +1 lines)
Lines 4-10 Link Here
4
.include <src.opts.mk>
4
.include <src.opts.mk>
5
5
6
PROG=	systat
6
PROG=	systat
7
SRCS=	cmds.c cmdtab.c devs.c fetch.c iostat.c keyboard.c main.c \
7
SRCS=	cmds.c cmdtab.c devs.c fetch.c iostat.c keyboard.c main.c sysput.c \
8
	netcmds.c netstat.c pigs.c swap.c icmp.c \
8
	netcmds.c netstat.c pigs.c swap.c icmp.c \
9
	mode.c ip.c sctp.c tcp.c zarc.c \
9
	mode.c ip.c sctp.c tcp.c zarc.c \
10
	vmstat.c convtbl.c ifcmds.c ifstat.c
10
	vmstat.c convtbl.c ifcmds.c ifstat.c
(-)b/usr.bin/systat/main.c (-11 / +2 lines)
Lines 300-316 display(void) Link Here
300
		    GETSYSCTL("kstat.zfs.misc.arcstats.dbuf_size", arc_stat);
300
		    GETSYSCTL("kstat.zfs.misc.arcstats.dbuf_size", arc_stat);
301
		    arc[6] += arc_stat;
301
		    arc[6] += arc_stat;
302
		    wmove(wload, 0, 0); wclrtoeol(wload);
302
		    wmove(wload, 0, 0); wclrtoeol(wload);
303
		    for (i = 0 ; i < nitems(arc); i++) {
303
		    for (i = 0 ; i < nitems(arc); i++)
304
			if (arc[i] > 10llu * 1024 * 1024 * 1024 ) {
304
			sysputuint64(wload, 0, i*8+2, 6, arc[i], 0);
305
				wprintw(wload, "%7lluG", arc[i] >> 30);
306
			}
307
			else if (arc[i] > 10 * 1024 * 1024 ) {
308
				wprintw(wload, "%7lluM", arc[i] >> 20);
309
			}
310
			else {
311
				wprintw(wload, "%7lluK", arc[i] >> 10);
312
			}
313
		    }
314
	    }
305
	    }
315
	}
306
	}
316
	(*curcmd->c_refresh)();
307
	(*curcmd->c_refresh)();
(-)b/usr.bin/systat/sysput.c (+75 lines)
Added Link Here
1
/*-
2
 * Copyright (c) 2019 Yoshihiro Ota
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 * 3. Neither the name of the University nor the names of its contributors
13
 *    may be used to endorse or promote products derived from this software
14
 *    without specific prior written permission.
15
 *
16
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26
 * SUCH DAMAGE.
27
 */
28
29
#include <sys/cdefs.h>
30
__FBSDID("$FreeBSD$");
31
32
#include <sys/types.h>
33
#include <sys/sysctl.h>
34
35
#include <inttypes.h>
36
#include <string.h>
37
#include <err.h>
38
#include <libutil.h>
39
40
#include "systat.h"
41
42
void
43
sysputstrs(WINDOW *wnd, int row, int col, int width)
44
{
45
	static char str40[] = "****************************************";
46
	mvwaddstr(wnd, row, col, str40 + sizeof(str40) - width - 1 );
47
}
48
49
void
50
sysputuint64(WINDOW *wnd, int row, int col, int width, uint64_t val, int flags)
51
{
52
	char unit, *ptr, *start, wrtbuf[width+width+1];
53
	int len;
54
55
	unit = 0;
56
	start = wrtbuf;
57
	flags |= HN_NOSPACE;
58
59
	if(val > INT64_MAX)
60
		goto error;
61
	else
62
		len = humanize_number(&wrtbuf[width], width+1, val, "",
63
			HN_AUTOSCALE, flags );
64
	if(len < 0)
65
		goto error;
66
	else if(len < width)
67
		memset(wrtbuf+len, ' ', width-len);
68
	start += len;
69
70
	mvwaddstr(wnd, row, col, start);
71
	return;
72
73
error:
74
	sysputstrs(wnd, row, col, width);
75
}
(-)b/usr.bin/systat/systat.h (+4 lines)
Lines 32-37 Link Here
32
 * $FreeBSD$
32
 * $FreeBSD$
33
 */
33
 */
34
34
35
#include <sys/types.h>
35
#include <curses.h>
36
#include <curses.h>
36
37
37
struct  cmdtab {
38
struct  cmdtab {
Lines 72-74 extern int use_kvm; Link Here
72
extern void putint(int, int, int, int);
73
extern void putint(int, int, int, int);
73
extern void putfloat(double, int, int, int, int, int);
74
extern void putfloat(double, int, int, int, int, int);
74
extern void putlongdouble(long double, int, int, int, int, int);
75
extern void putlongdouble(long double, int, int, int, int, int);
76
77
extern void sysputstrs(WINDOW* , int, int, int);
78
extern void sysputuint64(WINDOW* , int, int, int, uint64_t, int);
(-)b/usr.bin/systat/zarc.c (-25 / +29 lines)
Lines 32-47 __FBSDID("$FreeBSD$"); Link Here
32
#include <sys/types.h>
32
#include <sys/types.h>
33
#include <sys/sysctl.h>
33
#include <sys/sysctl.h>
34
34
35
/* #include <stdlib.h> */
36
#include <inttypes.h>
35
#include <inttypes.h>
37
#include <string.h>
36
#include <string.h>
38
#include <err.h>
37
#include <err.h>
38
#include <libutil.h>
39
39
40
#include "systat.h"
40
#include "systat.h"
41
#include "extern.h"
41
#include "extern.h"
42
#include "devs.h"
42
#include "devs.h"
43
43
44
struct zfield{
44
struct zfield {
45
	uint64_t arcstats;
45
	uint64_t arcstats;
46
	uint64_t arcstats_demand_data;
46
	uint64_t arcstats_demand_data;
47
	uint64_t arcstats_demand_metadata;
47
	uint64_t arcstats_demand_metadata;
Lines 57-62 static struct zarcstats { Link Here
57
	struct zfield misses;
57
	struct zfield misses;
58
} curstat, initstat, oldstat;
58
} curstat, initstat, oldstat;
59
59
60
struct zarcrates {
61
	struct zfield current;
62
	struct zfield total;
63
};
64
60
static void
65
static void
61
getinfo(struct zarcstats *ls);
66
getinfo(struct zarcstats *ls);
62
67
Lines 81-91 labelzarc(void) Link Here
81
{
86
{
82
	int row = 1;
87
	int row = 1;
83
	wmove(wnd, 0, 0); wclrtoeol(wnd);
88
	wmove(wnd, 0, 0); wclrtoeol(wnd);
84
	mvwprintw(wnd, 0, 31+1, "%4.4s %7.7s %7.7s %12.12s %12.12s",
89
	mvwprintw(wnd, 0, 31+1, "%4.4s %6.6s %6.6s | Total %4.4s %6.6s %6.6s",
85
		"rate", "hits", "misses", "total hits", "total misses");
90
		"Rate", "Hits", "Misses", "Rate", "Hits", "Misses");
86
#define L(str) mvwprintw(wnd, row, 5, #str); \
91
#define L(str) mvwprintw(wnd, row++, 5, \
87
	mvwprintw(wnd, row, 31, ":"); \
92
		"%-26.26s:   %%               |          %%", #str)
88
	mvwprintw(wnd, row, 31+4, "%%"); ++row
89
	L(arcstats);
93
	L(arcstats);
90
	L(arcstats.demand_data);
94
	L(arcstats.demand_data);
91
	L(arcstats.demand_metadata);
95
	L(arcstats.demand_metadata);
Lines 98-104 labelzarc(void) Link Here
98
	dslabel(12, 0, 18);
102
	dslabel(12, 0, 18);
99
}
103
}
100
104
101
static int calc(uint64_t hits, uint64_t misses)
105
static int calc_rate(uint64_t hits, uint64_t misses)
102
{
106
{
103
    if( hits )
107
    if( hits )
104
	return 100 * hits / ( hits + misses );
108
	return 100 * hits / ( hits + misses );
Lines 107-118 static int calc(uint64_t hits, uint64_t misses) Link Here
107
}
111
}
108
112
109
static void
113
static void
110
domode(struct zarcstats *delta, struct zarcstats *rate)
114
domode(struct zarcstats *delta, struct zarcrates *rate)
111
{
115
{
112
#define DO(stat) \
116
#define DO(stat) \
113
	delta->hits.stat = (curstat.hits.stat - oldstat.hits.stat); \
117
	delta->hits.stat = (curstat.hits.stat - oldstat.hits.stat); \
114
	delta->misses.stat = (curstat.misses.stat - oldstat.misses.stat); \
118
	delta->misses.stat = (curstat.misses.stat - oldstat.misses.stat); \
115
	rate->hits.stat = calc(delta->hits.stat, delta->misses.stat)
119
	rate->current.stat = calc_rate(delta->hits.stat, delta->misses.stat); \
120
	rate->total.stat = calc_rate(curstat.hits.stat, curstat.misses.stat)
116
	DO(arcstats);
121
	DO(arcstats);
117
	DO(arcstats_demand_data);
122
	DO(arcstats_demand_data);
118
	DO(arcstats_demand_metadata);
123
	DO(arcstats_demand_metadata);
Lines 136-156 void Link Here
136
showzarc(void)
141
showzarc(void)
137
{
142
{
138
	int row = 1;
143
	int row = 1;
139
	struct zarcstats delta, rate;
144
	struct zarcstats delta = {};
140
145
	struct zarcrates rate = {};
141
	memset(&delta, 0, sizeof delta);
142
	memset(&rate, 0, sizeof rate);
143
146
144
	domode(&delta, &rate);
147
	domode(&delta, &rate);
145
148
146
#define DO(stat, col, fmt) \
149
#define DO(stat, col, width) \
147
	mvwprintw(wnd, row, col, fmt, stat)
150
	sysputuint64(wnd, row, col, width, stat, HN_DIVISOR_1000 )
148
#define	R(stat) DO(rate.hits.stat, 31+1, "%3"PRIu64)
151
#define	RATES(stat) mvwprintw(wnd, row, 31+1, "%3"PRIu64, rate.current.stat);\
149
#define	H(stat) DO(delta.hits.stat, 31+1+5, "%7"PRIu64); \
152
	mvwprintw(wnd, row, 31+1+5+7+7+8, "%3"PRIu64, rate.total.stat)
150
	DO(curstat.hits.stat, 31+1+5+8+8, "%12"PRIu64)
153
#define	HITS(stat) DO(delta.hits.stat, 31+1+5, 6); \
151
#define	M(stat) DO(delta.misses.stat, 31+1+5+8, "%7"PRIu64); \
154
	DO(curstat.hits.stat, 31+1+5+7+7+8+5, 6)
152
	DO(curstat.misses.stat, 31+1+5+8+8+13, "%12"PRIu64)
155
#define	MISSES(stat) DO(delta.misses.stat, 31+1+5+7, 6); \
153
#define	E(stat) R(stat); H(stat); M(stat); ++row
156
	DO(curstat.misses.stat, 31+1+5+7+7+8+5+7, 6)
157
#define	E(stat) RATES(stat); HITS(stat); MISSES(stat); ++row
154
	E(arcstats);
158
	E(arcstats);
155
	E(arcstats_demand_data);
159
	E(arcstats_demand_data);
156
	E(arcstats_demand_metadata);
160
	E(arcstats_demand_metadata);
Lines 161-169 showzarc(void) Link Here
161
	E(vdev_cache_stats);
165
	E(vdev_cache_stats);
162
#undef DO
166
#undef DO
163
#undef E
167
#undef E
164
#undef M
168
#undef MISSES
165
#undef H
169
#undef HITS
166
#undef R
170
#undef RATES
167
	dsshow(12, 0, 18, &cur_dev, &last_dev);
171
	dsshow(12, 0, 18, &cur_dev, &last_dev);
168
}
172
}
169
173

Return to bug 237664