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

Collapse All | Expand All

(-)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
(-)usr.bin/systat/extern.h (-1 / +3 lines)
Lines 165-170 Link Here
165
void	 status(void);
165
void	 status(void);
166
void	 suspend(int);
166
void	 suspend(int);
167
char	*sysctl_dynread(const char *, size_t *);
167
char	*sysctl_dynread(const char *, size_t *);
168
void	 sysputstrs(WINDOW* , int, int, int);
169
void	 sysputuint64(WINDOW* , int, int, int, uint64_t, int);
168
170
169
#define SYSTAT_CMD(name)	\
171
#define SYSTAT_CMD(name)	\
170
	void	 close ## name(WINDOW *); \
172
	void	 close ## name(WINDOW *); \
Lines 176-179 Link Here
176
	void	 show ## name(void)
178
	void	 show ## name(void)
177
179
178
SYSTAT_CMD( zarc );
180
SYSTAT_CMD( zarc );
179
SYSTAT_CMD ( sctp );
181
SYSTAT_CMD( sctp );
(-)usr.bin/systat/main.c (-11 / +2 lines)
Lines 300-316 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)();
(-)usr.bin/systat/sysput.c (+77 lines)
Line 0 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
#include "extern.h"
42
43
void
44
sysputstrs(WINDOW *wnd, int row, int col, int width)
45
{
46
	static char str40[] = "****************************************";
47
48
	mvwaddstr(wnd, row, col, str40 + sizeof(str40) - width - 1 );
49
}
50
51
void
52
sysputuint64(WINDOW *wnd, int row, int col, int width, uint64_t val, int flags)
53
{
54
	char unit, *ptr, *start, wrtbuf[width+width+1];
55
	int len;
56
57
	unit = 0;
58
	start = wrtbuf;
59
	flags |= HN_NOSPACE;
60
61
	if (val > INT64_MAX)
62
		goto error;
63
	else
64
		len = humanize_number(&wrtbuf[width], width+1, val, "",
65
			HN_AUTOSCALE, flags );
66
	if (len < 0)
67
		goto error;
68
	else if (len < width)
69
		memset(wrtbuf+len, ' ', width-len);
70
	start += len;
71
72
	mvwaddstr(wnd, row, col, start);
73
	return;
74
75
error:
76
	sysputstrs(wnd, row, col, width);
77
}
(-)usr.bin/systat/zarc.c (-26 / +30 lines)
Lines 1-5 Link Here
1
/*-
1
/*-
2
 * Copyright (c) 2014 - 2017 Yoshihiro Ota
2
 * Copyright (c) 2014 - 2017, 2019 Yoshihiro Ota
3
 *
3
 *
4
 * Redistribution and use in source and binary forms, with or without
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
5
 * modification, are permitted provided that the following conditions
Lines 32-47 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 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 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 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 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 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 = {};
145
	struct zarcrates rate = {};
140
146
141
	memset(&delta, 0, sizeof delta);
142
	memset(&rate, 0, sizeof rate);
143
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 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