[Midnightbsd-cvs] src [11258] trunk/usr.bin/systat: sync with freebsd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Tue Jul 3 19:45:37 EDT 2018


Revision: 11258
          http://svnweb.midnightbsd.org/src/?rev=11258
Author:   laffer1
Date:     2018-07-03 19:45:37 -0400 (Tue, 03 Jul 2018)
Log Message:
-----------
sync with freebsd

Modified Paths:
--------------
    trunk/usr.bin/systat/Makefile
    trunk/usr.bin/systat/cmds.c
    trunk/usr.bin/systat/cmdtab.c
    trunk/usr.bin/systat/convtbl.c
    trunk/usr.bin/systat/convtbl.h
    trunk/usr.bin/systat/devs.c
    trunk/usr.bin/systat/devs.h
    trunk/usr.bin/systat/extern.h
    trunk/usr.bin/systat/fetch.c
    trunk/usr.bin/systat/icmp.c
    trunk/usr.bin/systat/icmp6.c
    trunk/usr.bin/systat/ifcmds.c
    trunk/usr.bin/systat/ifstat.c
    trunk/usr.bin/systat/iostat.c
    trunk/usr.bin/systat/ip.c
    trunk/usr.bin/systat/ip6.c
    trunk/usr.bin/systat/keyboard.c
    trunk/usr.bin/systat/main.c
    trunk/usr.bin/systat/mode.c
    trunk/usr.bin/systat/mode.h
    trunk/usr.bin/systat/netcmds.c
    trunk/usr.bin/systat/netstat.c
    trunk/usr.bin/systat/pigs.c
    trunk/usr.bin/systat/swap.c
    trunk/usr.bin/systat/systat.1
    trunk/usr.bin/systat/systat.h
    trunk/usr.bin/systat/tcp.c
    trunk/usr.bin/systat/vmstat.c

Added Paths:
-----------
    trunk/usr.bin/systat/sctp.c
    trunk/usr.bin/systat/zarc.c

Property Changed:
----------------
    trunk/usr.bin/systat/systat.1

Modified: trunk/usr.bin/systat/Makefile
===================================================================
--- trunk/usr.bin/systat/Makefile	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/Makefile	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,12 +1,13 @@
+# $MidnightBSD$
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
-# $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/systat/Makefile 303684 2016-08-02 22:33:29Z mr $
 
 .include <bsd.own.mk>
 
 PROG=	systat
 SRCS=	cmds.c cmdtab.c devs.c fetch.c iostat.c keyboard.c main.c \
-	mbufs.c netcmds.c netstat.c pigs.c swap.c icmp.c \
-	mode.c ip.c sensors.c tcp.c \
+	netcmds.c netstat.c pigs.c swap.c icmp.c \
+	mode.c ip.c sctp.c tcp.c zarc.c \
 	vmstat.c convtbl.c ifcmds.c ifstat.c
 
 .if ${MK_INET6_SUPPORT} != "no"
@@ -16,7 +17,16 @@
 
 WARNS?=	0
 
-DPADD=	${LIBNCURSESW} ${LIBM} ${LIBDEVSTAT} ${LIBKVM}
-LDADD=	-lncursesw -lm -ldevstat -lkvm
+DPADD=	${LIBM} ${LIBDEVSTAT} ${LIBKVM}
+LDADD=	-lm -ldevstat -lkvm
 
+.if ${MK_NCURSESW} == "no"
+DPADD+=		${LIBNCURSES}
+LDADD+=		-lncurses
+.else
+CFLAGS+=	-DUSE_WIDECHAR
+DPADD+=		${LIBNCURSESW}
+LDADD+=		-lncursesw
+.endif
+
 .include <bsd.prog.mk>

Modified: trunk/usr.bin/systat/cmds.c
===================================================================
--- trunk/usr.bin/systat/cmds.c	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/cmds.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1980, 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -29,7 +30,7 @@
 
 #include <sys/cdefs.h>
 
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/systat/cmds.c 240605 2012-09-17 13:36:47Z melifaro $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)cmds.c	8.2 (Berkeley) 4/29/95";

Modified: trunk/usr.bin/systat/cmdtab.c
===================================================================
--- trunk/usr.bin/systat/cmdtab.c	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/cmdtab.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1980, 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -29,7 +30,7 @@
 
 #include <sys/cdefs.h>
 
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/systat/cmdtab.c 303684 2016-08-02 22:33:29Z mr $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)cmdtab.c	8.1 (Berkeley) 6/6/93";
@@ -46,9 +47,6 @@
 	{ "swap",	showswap,	fetchswap,	labelswap,
 	  initswap,	openswap,	closeswap,	0,
 	  0,		CF_LOADAV },
-	{ "mbufs",	showmbufs,	fetchmbufs,	labelmbufs,
-	  initmbufs,	openmbufs,	closembufs,	0,
-	  0,		CF_LOADAV },
 	{ "iostat",	showiostat,	fetchiostat,	labeliostat,
 	  initiostat,	openiostat,	closeiostat,	cmdiostat,
 	  0,		CF_LOADAV },
@@ -72,6 +70,9 @@
 	  initip6,	openip6,	closeip6,	cmdmode,
 	  resetip6,	CF_LOADAV },
 #endif
+	{ "sctp",	showsctp,	fetchsctp,	labelsctp,
+	  initsctp,	opensctp,	closesctp,	cmdmode,
+	  resetsctp,	CF_LOADAV },
 	{ "tcp",	showtcp,	fetchtcp,	labeltcp,
 	  inittcp,	opentcp,	closetcp,	cmdmode,
 	  resettcp,	CF_LOADAV },
@@ -78,9 +79,9 @@
 	{ "ifstat",	showifstat,	fetchifstat,	labelifstat,
 	  initifstat,	openifstat,	closeifstat,	cmdifstat,
 	  0,		CF_LOADAV },
-	{ "sensors",	showsensors,	fetchsensors,	labelsensors,
-	  initsensors,	opensensors,	closesensors,	0,
-	  0,		CF_LOADAV },
+	{ "zarc",	showzarc,	fetchzarc,	labelzarc,
+	  initzarc,	openzarc,	closezarc,	0,
+	  resetzarc,	CF_ZFSARC },
 	{ NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0 }
 };
 struct  cmdtab *curcmd = &cmdtab[0];

Modified: trunk/usr.bin/systat/convtbl.c
===================================================================
--- trunk/usr.bin/systat/convtbl.c	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/convtbl.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2003, Trent Nelson, <trent at arpa.com>.
  * All rights reserved.
@@ -25,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/systat/convtbl.c 175387 2008-01-16 19:27:43Z delphij $
  */
 
 #include <sys/types.h>

Modified: trunk/usr.bin/systat/convtbl.h
===================================================================
--- trunk/usr.bin/systat/convtbl.h	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/convtbl.h	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2003, Trent Nelson, <trent at arpa.com>.
  * All rights reserved.
@@ -25,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/systat/convtbl.h 164675 2006-11-27 16:33:44Z yar $
  */
 
 #ifndef _CONVTBL_H_

Modified: trunk/usr.bin/systat/devs.c
===================================================================
--- trunk/usr.bin/systat/devs.c	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/devs.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 1998 Kenneth D. Merry.
  * All rights reserved.
@@ -56,7 +57,7 @@
 
 #include <sys/cdefs.h>
 
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/systat/devs.c 229403 2012-01-03 18:51:58Z ed $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)disks.c	8.1 (Berkeley) 6/6/93";
@@ -265,7 +266,7 @@
 	specified_devices = (char **)malloc(sizeof(char *));
 
 	tmpstr = tmpstr1 = strdup(args);
-	cp = index(tmpstr1, '\n');
+	cp = strchr(tmpstr1, '\n');
 	if (cp)
 		*cp = '\0';
 	for (;;) {

Modified: trunk/usr.bin/systat/devs.h
===================================================================
--- trunk/usr.bin/systat/devs.h	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/devs.h	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1998 David E. O'Brien
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/systat/devs.h 87715 2001-12-12 00:13:37Z markm $
  */
 
 int dsinit(int, struct statinfo *, struct statinfo *, struct statinfo *);

Modified: trunk/usr.bin/systat/extern.h
===================================================================
--- trunk/usr.bin/systat/extern.h	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/extern.h	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1991, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -27,7 +28,7 @@
  * SUCH DAMAGE.
  *
  *      @(#)extern.h	8.1 (Berkeley) 6/6/93
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/systat/extern.h 303684 2016-08-02 22:33:29Z mr $
  */
 
 #include <sys/cdefs.h>
@@ -76,10 +77,8 @@
 void	 closeip(WINDOW *);
 void	 closeip6(WINDOW *);
 void	 closekre(WINDOW *);
-void	 closembufs(WINDOW *);
 void	 closenetstat(WINDOW *);
 void	 closepigs(WINDOW *);
-void	 closesensors(WINDOW *);
 void	 closeswap(WINDOW *);
 void	 closetcp(WINDOW *);
 int	 cmdifstat(const char *, const char *);
@@ -100,10 +99,8 @@
 void	 fetchip6(void);
 void	 fetchiostat(void);
 void	 fetchkre(void);
-void	 fetchmbufs(void);
 void	 fetchnetstat(void);
 void	 fetchpigs(void);
-void	 fetchsensors(void);
 void	 fetchswap(void);
 void	 fetchtcp(void);
 void	 getsysctl(const char *, void *, size_t);
@@ -115,10 +112,8 @@
 int	 initip6(void);
 int	 initiostat(void);
 int	 initkre(void);
-int	 initmbufs(void);
 int	 initnetstat(void);
 int	 initpigs(void);
-int	 initsensors(void);
 int	 initswap(void);
 int	 inittcp(void);
 int	 keyboard(void);
@@ -130,11 +125,9 @@
 void	 labelip6(void);
 void	 labeliostat(void);
 void	 labelkre(void);
-void	 labelmbufs(void);
 void	 labelnetstat(void);
 void	 labelpigs(void);
 void	 labels(void);
-void	 labelsensors(void);
 void	 labelswap(void);
 void	 labeltcp(void);
 void	 load(void);
@@ -147,10 +140,8 @@
 WINDOW	*openip6(void);
 WINDOW	*openiostat(void);
 WINDOW	*openkre(void);
-WINDOW	*openmbufs(void);
 WINDOW	*opennetstat(void);
 WINDOW	*openpigs(void);
-WINDOW	*opensensors(void);
 WINDOW	*openswap(void);
 WINDOW	*opentcp(void);
 int	 prefix(const char *, const char *);
@@ -166,12 +157,22 @@
 void	 showip6(void);
 void	 showiostat(void);
 void	 showkre(void);
-void	 showmbufs(void);
 void	 shownetstat(void);
 void	 showpigs(void);
-void	 showsensors(void);
 void	 showswap(void);
 void	 showtcp(void);
 void	 status(void);
 void	 suspend(int);
 char	*sysctl_dynread(const char *, size_t *);
+
+#define SYSTAT_CMD(name)	\
+	void	 close ## name(WINDOW *); \
+	void	 fetch ## name(void); \
+	int	 init ## name(void); \
+	void	 label ## name(void); \
+	WINDOW	*open ## name(void); \
+	void	 reset ## name(void); \
+	void	 show ## name(void)
+
+SYSTAT_CMD( zarc );
+SYSTAT_CMD ( sctp );

Modified: trunk/usr.bin/systat/fetch.c
===================================================================
--- trunk/usr.bin/systat/fetch.c	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/fetch.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1980, 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -29,7 +30,7 @@
 
 #include <sys/cdefs.h>
 
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/systat/fetch.c 226396 2011-10-15 13:20:36Z ed $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)fetch.c	8.1 (Berkeley) 6/6/93";

Modified: trunk/usr.bin/systat/icmp.c
===================================================================
--- trunk/usr.bin/systat/icmp.c	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/icmp.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1980, 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -29,7 +30,7 @@
 
 #include <sys/cdefs.h>
 
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/systat/icmp.c 240605 2012-09-17 13:36:47Z melifaro $");
 
 #ifdef lint
 static char sccsid[] = "@(#)mbufs.c	8.1 (Berkeley) 6/6/93";
@@ -277,4 +278,3 @@
 	if (sysctl(name, 4, &icmpstat, &len, 0, 0) < 0)
 		return;
 }
-

Modified: trunk/usr.bin/systat/icmp6.c
===================================================================
--- trunk/usr.bin/systat/icmp6.c	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/icmp6.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1980, 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -29,7 +30,7 @@
 
 #include <sys/cdefs.h>
 
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/systat/icmp6.c 240605 2012-09-17 13:36:47Z melifaro $");
 
 #ifdef lint
 static char sccsid[] = "@(#)mbufs.c	8.1 (Berkeley) 6/6/93";
@@ -75,7 +76,7 @@
 12999999999 time-to-live exceeded    999999999 time-to-line exceeded
 13999999999 parameter problem        999999999 parameter problem
 14999999999 neighbor solicitation    999999999 neighbor solicitation
-15999999999 neighbor advertisment    999999999 neighbor advertisment
+15999999999 neighbor advertisement   999999999 neighbor advertisement
 16999999999 router advertisement     999999999 router solicitation
 17
 18
@@ -121,7 +122,7 @@
 	B(12, "time-to-live exceeded");
 	B(13, "parameter problem");
 	B(14, "neighbor solicitation");
-	B(15, "neighbor advertisment");
+	B(15, "neighbor advertisement");
 	L(16, "router advertisement");	R(16, "router solicitation");
 #undef L
 #undef R

Modified: trunk/usr.bin/systat/ifcmds.c
===================================================================
--- trunk/usr.bin/systat/ifcmds.c	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/ifcmds.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2003, Trent Nelson, <trent at arpa.com>.
  * All rights reserved.
@@ -25,14 +26,22 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/systat/ifcmds.c 247037 2013-02-20 14:19:09Z melifaro $
  */
 
+#include <sys/types.h>
+
 #include "systat.h"
 #include "extern.h"
 #include "convtbl.h"
 
+#include <stdlib.h>
+#include <string.h>
+
 int curscale = SC_AUTO;
+char *matchline = NULL;
+int showpps = 0;
+int needsort = 0;
 
 int
 ifcmd(const char *cmd, const char *args)
@@ -48,6 +57,22 @@
 			addstr("what scale? ");
 			addstr(get_helplist());
 		}
-	}
+	} else if (prefix(cmd, "match")) {
+		if (args != NULL && *args != '\0' && memcmp(args, "*", 2) != 0) {
+			/* We got a valid match line */
+			if (matchline != NULL)
+				free(matchline);
+			needsort = 1;
+			matchline = strdup(args);
+		} else {
+			/* Empty or * pattern, turn filtering off */
+			if (matchline != NULL)
+				free(matchline);
+			needsort = 1;
+			matchline = NULL;
+		}
+	} else if (prefix(cmd, "pps"))
+		showpps = !showpps;
+
 	return (1);
 }

Modified: trunk/usr.bin/systat/ifstat.c
===================================================================
--- trunk/usr.bin/systat/ifstat.c	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/ifstat.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2003, Trent Nelson, <trent at arpa.com>.
  * All rights reserved.
@@ -25,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/systat/ifstat.c 279473 2015-03-01 04:36:20Z rstone $
  */
 
 #include <sys/types.h>
@@ -38,6 +39,7 @@
 #include <string.h>
 #include <err.h>
 #include <errno.h>
+#include <fnmatch.h>
 
 #include "systat.h"
 #include "extern.h"
@@ -58,7 +60,6 @@
 static const int col4 = C4;
 static const int col5 = C5;
 
-
 SLIST_HEAD(, if_stat)		curlist;
 SLIST_HEAD(, if_stat_disp)	displist;
 
@@ -68,17 +69,27 @@
 	struct	ifmibdata if_mib;
 	struct	timeval tv;
 	struct	timeval tv_lastchanged;
-	u_long	if_in_curtraffic;
-	u_long	if_out_curtraffic;
-	u_long	if_in_traffic_peak;
-	u_long	if_out_traffic_peak;
+	uint64_t if_in_curtraffic;
+	uint64_t if_out_curtraffic;
+	uint64_t if_in_traffic_peak;
+	uint64_t if_out_traffic_peak;
+	uint64_t if_in_curpps;
+	uint64_t if_out_curpps;
+	uint64_t if_in_pps_peak;
+	uint64_t if_out_pps_peak;
 	u_int	if_row;			/* Index into ifmib sysctl */
 	u_int	if_ypos;		/* 0 if not being displayed */
 	u_int	display;
+	u_int	match;
 };
 
-extern	 u_int curscale;
+extern	 int curscale;
+extern	 char *matchline;
+extern	 int showpps;
+extern	 int needsort;
 
+static	 int needclear = 0;
+
 static	 void  right_align_string(struct if_stat *);
 static	 void  getifmibdata(const int, struct ifmibdata *);
 static	 void  sort_interface_list(void);
@@ -85,7 +96,7 @@
 static	 u_int getifnum(void);
 
 #define IFSTAT_ERR(n, s)	do {					\
-	putchar('
');							\
+	putchar('\014');						\
 	closeifstat(wnd);						\
 	err((n), (s));							\
 } while (0)
@@ -97,34 +108,48 @@
 #define STARTING_ROW	(TOPLINE + 1)
 #define ROW_SPACING	(3)
 
-#define CLEAR_LINE(y, x)	do {					\
-	wmove(wnd, y, x);						\
-	wclrtoeol(wnd);							\
-} while (0)
+#define IN_col2		(showpps ? ifp->if_in_curpps : ifp->if_in_curtraffic)
+#define OUT_col2	(showpps ? ifp->if_out_curpps : ifp->if_out_curtraffic)
+#define IN_col3		(showpps ? \
+		ifp->if_in_pps_peak : ifp->if_in_traffic_peak)
+#define OUT_col3	(showpps ? \
+		ifp->if_out_pps_peak : ifp->if_out_traffic_peak)
+#define IN_col4		(showpps ? \
+	ifp->if_mib.ifmd_data.ifi_ipackets : ifp->if_mib.ifmd_data.ifi_ibytes)
+#define OUT_col4	(showpps ? \
+	ifp->if_mib.ifmd_data.ifi_opackets : ifp->if_mib.ifmd_data.ifi_obytes)
 
-#define IN_col2		(ifp->if_in_curtraffic)
-#define OUT_col2	(ifp->if_out_curtraffic)
-#define IN_col3		(ifp->if_in_traffic_peak)
-#define OUT_col3	(ifp->if_out_traffic_peak)
-#define IN_col4		(ifp->if_mib.ifmd_data.ifi_ibytes)
-#define OUT_col4	(ifp->if_mib.ifmd_data.ifi_obytes)
-
 #define EMPTY_COLUMN 	"                    "
 #define CLEAR_COLUMN(y, x)	mvprintw((y), (x), "%20s", EMPTY_COLUMN);
 
 #define DOPUTRATE(c, r, d)	do {					\
 	CLEAR_COLUMN(r, c);						\
-	mvprintw(r, (c), "%10.3f %s%s  ",				\
-		 convert(d##_##c, curscale),				\
-		 get_string(d##_##c, curscale),				\
-		 "/s");							\
+	if (showpps) {							\
+		mvprintw(r, (c), "%10.3f %cp%s  ",			\
+			 convert(d##_##c, curscale),			\
+			 *get_string(d##_##c, curscale),		\
+			 "/s");						\
+	}								\
+	else {								\
+		mvprintw(r, (c), "%10.3f %s%s  ",			\
+			 convert(d##_##c, curscale),			\
+			 get_string(d##_##c, curscale),			\
+			 "/s");						\
+	}								\
 } while (0)
 
 #define DOPUTTOTAL(c, r, d)	do {					\
 	CLEAR_COLUMN((r), (c));						\
-	mvprintw((r), (c), "%12.3f %s  ",				\
-		 convert(d##_##c, SC_AUTO),				\
-		 get_string(d##_##c, SC_AUTO));				\
+	if (showpps) {							\
+		mvprintw((r), (c), "%12.3f %cp  ",			\
+			 convert(d##_##c, SC_AUTO),			\
+			 *get_string(d##_##c, SC_AUTO));		\
+	}								\
+	else {								\
+		mvprintw((r), (c), "%12.3f %s  ",			\
+			 convert(d##_##c, SC_AUTO),			\
+			 get_string(d##_##c, SC_AUTO));			\
+	}								\
 } while (0)
 
 #define PUTRATE(c, r)	do {						\
@@ -143,7 +168,6 @@
 	mvprintw(p->if_ypos+1, col2-3, "%s", (const char *)"out");	\
 } while (0)
 
-
 WINDOW *
 openifstat(void)
 {
@@ -170,7 +194,6 @@
 	return;
 }
 
-
 void
 labelifstat(void)
 {
@@ -186,8 +209,10 @@
 showifstat(void)
 {
 	struct	if_stat *ifp = NULL;
+	
 	SLIST_FOREACH(ifp, &curlist, link) {
-		if (ifp->display == 0)
+		if (ifp->display == 0 || (ifp->match == 0) ||
+			ifp->if_ypos > LINES - 3 - 1)
 			continue;
 		PUTNAME(ifp);
 		PUTRATE(col2, ifp->if_ypos);
@@ -206,7 +231,7 @@
 
 	n = getifnum();
 	if (n <= 0)
-		return -1;
+		return (-1);
 
 	SLIST_INIT(&curlist);
 
@@ -218,6 +243,7 @@
 		p->if_row = i+1;
 		getifmibdata(p->if_row, &p->if_mib);
 		right_align_string(p);
+		p->match = 1;
 
 		/*
 		 * Initially, we only display interfaces that have
@@ -229,7 +255,7 @@
 
 	sort_interface_list();
 
-	return 1;
+	return (1);
 }
 
 void
@@ -238,8 +264,8 @@
 	struct	if_stat *ifp = NULL;
 	struct	timeval tv, new_tv, old_tv;
 	double	elapsed = 0.0;
-	u_int	new_inb, new_outb, old_inb, old_outb = 0;
-	u_int	we_need_to_sort_interface_list = 0;
+	uint64_t new_inb, new_outb, old_inb, old_outb = 0;
+	uint64_t new_inp, new_outp, old_inp, old_outp = 0;
 
 	SLIST_FOREACH(ifp, &curlist, link) {
 		/*
@@ -248,20 +274,22 @@
 		 */
 		old_inb = ifp->if_mib.ifmd_data.ifi_ibytes;
 		old_outb = ifp->if_mib.ifmd_data.ifi_obytes;
+		old_inp = ifp->if_mib.ifmd_data.ifi_ipackets;
+		old_outp = ifp->if_mib.ifmd_data.ifi_opackets;
 		ifp->tv_lastchanged = ifp->if_mib.ifmd_data.ifi_lastchange;
 
-		if (gettimeofday(&new_tv, (struct timezone *)0) != 0)
-			IFSTAT_ERR(2, "error getting time of day");
+		(void)gettimeofday(&new_tv, NULL);
 		(void)getifmibdata(ifp->if_row, &ifp->if_mib);
 
-
 		new_inb = ifp->if_mib.ifmd_data.ifi_ibytes;
 		new_outb = ifp->if_mib.ifmd_data.ifi_obytes;
+		new_inp = ifp->if_mib.ifmd_data.ifi_ipackets;
+		new_outp = ifp->if_mib.ifmd_data.ifi_opackets;
 
 		/* Display interface if it's received some traffic. */
 		if (new_inb > 0 && old_inb == 0) {
 			ifp->display = 1;
-			we_need_to_sort_interface_list++;
+			needsort = 1;
 		}
 
 		/*
@@ -276,6 +304,9 @@
 		ifp->if_in_curtraffic = new_inb - old_inb;
 		ifp->if_out_curtraffic = new_outb - old_outb;
 
+		ifp->if_in_curpps = new_inp - old_inp;
+		ifp->if_out_curpps = new_outp - old_outp;
+
 		/*
 		 * Rather than divide by the time specified on the comm-
 		 * and line, we divide by ``elapsed'' as this is likely
@@ -283,6 +314,8 @@
 		 */
 		ifp->if_in_curtraffic /= elapsed;
 		ifp->if_out_curtraffic /= elapsed;
+		ifp->if_in_curpps /= elapsed;
+		ifp->if_out_curpps /= elapsed;
 
 		if (ifp->if_in_curtraffic > ifp->if_in_traffic_peak)
 			ifp->if_in_traffic_peak = ifp->if_in_curtraffic;
@@ -290,12 +323,18 @@
 		if (ifp->if_out_curtraffic > ifp->if_out_traffic_peak)
 			ifp->if_out_traffic_peak = ifp->if_out_curtraffic;
 
+		if (ifp->if_in_curpps > ifp->if_in_pps_peak)
+			ifp->if_in_pps_peak = ifp->if_in_curpps;
+
+		if (ifp->if_out_curpps > ifp->if_out_pps_peak)
+			ifp->if_out_pps_peak = ifp->if_out_curpps;
+
 		ifp->tv.tv_sec = new_tv.tv_sec;
 		ifp->tv.tv_usec = new_tv.tv_usec;
 
 	}
 
-	if (we_need_to_sort_interface_list)
+	if (needsort)
 		sort_interface_list();
 
 	return;
@@ -328,6 +367,40 @@
 	return;
 }
 
+static int
+check_match(const char *ifname) 
+{
+	char *p = matchline, *c, t;
+	int match = 0, mlen;
+	
+	if (matchline == NULL)
+		return (0);
+
+	/* Strip leading whitespaces */
+	while (*p == ' ')
+		p ++;
+
+	c = p;
+	while ((mlen = strcspn(c, " ;,")) != 0) {
+		p = c + mlen;
+		t = *p;
+		if (p - c > 0) {
+			*p = '\0';
+			if (fnmatch(c, ifname, FNM_CASEFOLD) == 0) {
+				*p = t;
+				return (1);
+			}
+			*p = t;
+			c = p + strspn(p, " ;,");
+		}
+		else {
+			c = p + strspn(p, " ;,");
+		}
+	}
+
+	return (match);
+}
+
 /*
  * This function iterates through our list of interfaces, identifying
  * those that are to be displayed (ifp->display = 1).  For each interf-
@@ -345,11 +418,18 @@
 
 	y = STARTING_ROW;
 	SLIST_FOREACH(ifp, &curlist, link) {
-		if (ifp->display) {
+		if (matchline && !check_match(ifp->if_mib.ifmd_name))
+			ifp->match = 0;
+		else
+			ifp->match = 1;
+		if (ifp->display && ifp->match) {
 			ifp->if_ypos = y;
 			y += ROW_SPACING;
 		}
 	}
+	
+	needsort = 0;
+	needclear = 1;
 }
 
 static
@@ -368,7 +448,7 @@
 	if (sysctl(name, 5, (void *)&data, (size_t *)&datalen, (void *)NULL,
 	    (size_t)0) != 0)
 		IFSTAT_ERR(1, "sysctl error");
-	return data;
+	return (data);
 }
 
 static void
@@ -399,7 +479,12 @@
 	if (retval == 1) {
 		showifstat();
 		refresh();
+		if (needclear) {
+			werase(wnd);
+			labelifstat();
+			needclear = 0;
+		}
 	}
 
-	return retval;
+	return (retval);
 }

Modified: trunk/usr.bin/systat/iostat.c
===================================================================
--- trunk/usr.bin/systat/iostat.c	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/iostat.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 1998 Kenneth D. Merry.
  * All rights reserved.
@@ -56,7 +57,7 @@
 
 #include <sys/cdefs.h>
 
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/systat/iostat.c 288163 2015-09-24 00:50:17Z delphij $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)iostat.c	8.1 (Berkeley) 6/6/93";
@@ -112,10 +113,8 @@
 	if ((num_devices = devstat_getnumdevs(NULL)) < 0)
 		return(0);
 
-	cur.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo));
-	last.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo));
-	bzero(cur.dinfo, sizeof(struct devinfo));
-	bzero(last.dinfo, sizeof(struct devinfo));
+	cur.dinfo = calloc(1, sizeof(struct devinfo));
+	last.dinfo = calloc(1, sizeof(struct devinfo));
 
 	/*
 	 * This value for maxshowdevs (100) is bogus.  I'm not sure exactly
@@ -196,7 +195,7 @@
 	char tmpstr[10];
 
 #define COLWIDTH	17
-#define DRIVESPERLINE	((wnd->_maxx - INSET) / COLWIDTH)
+#define DRIVESPERLINE	((getmaxx(wnd) - 1 - INSET) / COLWIDTH)
 	for (ndrives = 0, i = 0; i < num_devices; i++)
 		if (dev_select[i].selected)
 			ndrives++;
@@ -204,7 +203,7 @@
 	/*
 	 * Deduct -regions for blank line after each scrolling region.
 	 */
-	linesperregion = (wnd->_maxy - row - regions) / regions;
+	linesperregion = (getmaxy(wnd) - 1 - row - regions) / regions;
 	/*
 	 * Minimum region contains space for two
 	 * label lines and one line of statistics.
@@ -214,9 +213,9 @@
 	_col = INSET;
 	for (i = 0; i < num_devices; i++)
 		if (dev_select[i].selected) {
-			if (_col + COLWIDTH >= wnd->_maxx - INSET) {
+			if (_col + COLWIDTH >= getmaxx(wnd) - 1 - INSET) {
 				_col = INSET, row += linesperregion + 1;
-				if (row > wnd->_maxy - (linesperregion + 1))
+				if (row > getmaxy(wnd) - 1 - (linesperregion + 1))
 					break;
 			}
 			sprintf(tmpstr, "%s%d", dev_select[i].device_name,
@@ -241,7 +240,7 @@
 	linesperregion = 2 + kbpt;
 	for (i = 0; i < num_devices; i++)
 		if (dev_select[i].selected) {
-			if (row > wnd->_maxy - linesperregion)
+			if (row > getmaxy(wnd) - 1 - linesperregion)
 				break;
 			sprintf(tmpstr, "%s%d", dev_select[i].device_name,
 				dev_select[i].unit_number);
@@ -254,7 +253,6 @@
 	return (row);
 }
 
-
 void
 showiostat(void)
 {
@@ -277,7 +275,7 @@
 		row += 2;
 		for (i = 0; i < num_devices; i++)
 			if (dev_select[i].selected) {
-				if (row > wnd->_maxy - linesperregion)
+				if (row > getmaxy(wnd) - linesperregion)
 					break;
 				row = devstats(row, INSET, i);
 			}
@@ -290,9 +288,9 @@
 	winsertln(wnd);
 	for (i = 0; i < num_devices; i++)
 		if (dev_select[i].selected) {
-			if (_col + COLWIDTH >= wnd->_maxx - INSET) {
+			if (_col + COLWIDTH >= getmaxx(wnd) - 1 - INSET) {
 				_col = INSET, row += linesperregion + 1;
-				if (row > wnd->_maxy - (linesperregion + 1))
+				if (row > getmaxy(wnd) - 1 - (linesperregion + 1))
 					break;
 				wmove(wnd, row + linesperregion, 0);
 				wdeleteln(wnd);

Modified: trunk/usr.bin/systat/ip.c
===================================================================
--- trunk/usr.bin/systat/ip.c	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/ip.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1980, 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -29,7 +30,7 @@
 
 #include <sys/cdefs.h>
 
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/systat/ip.c 240605 2012-09-17 13:36:47Z melifaro $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)mbufs.c	8.1 (Berkeley) 6/6/93";
@@ -337,4 +338,3 @@
 	if (sysctl(name, 4, &curstat.u, &len, 0, 0) < 0)
 		return;
 }
-

Modified: trunk/usr.bin/systat/ip6.c
===================================================================
--- trunk/usr.bin/systat/ip6.c	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/ip6.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1980, 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -29,7 +30,7 @@
 
 #include <sys/cdefs.h>
 
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/systat/ip6.c 240605 2012-09-17 13:36:47Z melifaro $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)mbufs.c	8.1 (Berkeley) 6/6/93";

Modified: trunk/usr.bin/systat/keyboard.c
===================================================================
--- trunk/usr.bin/systat/keyboard.c	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/keyboard.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1980, 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -29,7 +30,7 @@
 
 #include <sys/cdefs.h>
 
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/systat/keyboard.c 240605 2012-09-17 13:36:47Z melifaro $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)keyboard.c	8.1 (Berkeley) 6/6/93";

Modified: trunk/usr.bin/systat/main.c
===================================================================
--- trunk/usr.bin/systat/main.c	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/main.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1980, 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -29,7 +30,7 @@
 
 #include <sys/cdefs.h>
 
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/systat/main.c 303684 2016-08-02 22:33:29Z mr $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)main.c	8.1 (Berkeley) 6/6/93";
@@ -84,7 +85,11 @@
 	size_t	size;
 	double t;
 
+#ifdef USE_WIDECHAR
 	(void) setlocale(LC_ALL, "");
+#else
+	(void) setlocale(LC_TIME, "");
+#endif
 
 	argc--, argv++;
 	while (argc > 0) {
@@ -184,6 +189,11 @@
 		    "/0   /1   /2   /3   /4   /5   /6   /7   /8   /9   /10");
 		mvaddstr(1, 5, "Load Average");
 	}
+	if (curcmd->c_flags & CF_ZFSARC) {
+		mvaddstr(0, 20,
+		    "   Total     MFU     MRU    Anon     Hdr   L2Hdr   Other");
+		mvaddstr(1, 5, "ZFS ARC     ");
+	}
 	(*curcmd->c_label)();
 #ifdef notdef
 	mvprintw(21, 25, "CPU usage on %s", hostname);
@@ -192,7 +202,7 @@
 }
 
 void
-display()
+display(void)
 {
 	int i, j;
 
@@ -217,8 +227,33 @@
 		if (j > 50)
 			wprintw(wload, " %4.1f", avenrun[0]);
 	}
+	if (curcmd->c_flags & CF_ZFSARC) {
+	    uint64_t arc[7] = {};
+	    size_t size = sizeof(arc[0]);
+	    if (sysctlbyname("kstat.zfs.misc.arcstats.size",
+		&arc[0], &size, NULL, 0) == 0 ) {
+		    GETSYSCTL("vfs.zfs.mfu_size", arc[1]);
+		    GETSYSCTL("vfs.zfs.mru_size", arc[2]);
+		    GETSYSCTL("vfs.zfs.anon_size", arc[3]);
+		    GETSYSCTL("kstat.zfs.misc.arcstats.hdr_size", arc[4]);
+		    GETSYSCTL("kstat.zfs.misc.arcstats.l2_hdr_size", arc[5]);
+		    GETSYSCTL("kstat.zfs.misc.arcstats.other_size", arc[6]);
+		    wmove(wload, 0, 0); wclrtoeol(wload);
+		    for (i = 0 ; i < sizeof(arc) / sizeof(arc[0]) ; i++) {
+			if (arc[i] > 10llu * 1024 * 1024 * 1024 ) {
+				wprintw(wload, "%7lluG", arc[i] >> 30);
+			}
+			else if (arc[i] > 10 * 1024 * 1024 ) {
+				wprintw(wload, "%7lluM", arc[i] >> 20);
+			}
+			else {
+				wprintw(wload, "%7lluK", arc[i] >> 10);
+			}
+		    }
+	    }
+	}
 	(*curcmd->c_refresh)();
-	if (curcmd->c_flags & CF_LOADAV)
+	if (curcmd->c_flags & (CF_LOADAV |CF_ZFSARC))
 		wrefresh(wload);
 	wrefresh(wnd);
 	move(CMDLINE, col);

Modified: trunk/usr.bin/systat/mode.c
===================================================================
--- trunk/usr.bin/systat/mode.c	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/mode.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright 1997 Massachusetts Institute of Technology
  *
@@ -58,7 +59,7 @@
 
 #include <sys/cdefs.h>
 
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/systat/mode.c 226396 2011-10-15 13:20:36Z ed $");
 
 #include <sys/types.h>
 

Modified: trunk/usr.bin/systat/mode.h
===================================================================
--- trunk/usr.bin/systat/mode.h	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/mode.h	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright 1997 Massachusetts Institute of Technology
  *
@@ -26,7 +27,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/systat/mode.h 226396 2011-10-15 13:20:36Z ed $
  */
 
 /*

Modified: trunk/usr.bin/systat/netcmds.c
===================================================================
--- trunk/usr.bin/systat/netcmds.c	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/netcmds.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1980, 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -29,7 +30,7 @@
 
 #include <sys/cdefs.h>
 
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/systat/netcmds.c 231011 2012-02-05 09:17:49Z ed $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)netcmds.c	8.1 (Berkeley) 6/6/93";
@@ -121,7 +122,6 @@
 	return (0);
 }
 
-
 static void
 changeitems(const char *args, int onoff)
 {
@@ -131,7 +131,7 @@
 	struct in_addr in;
 
 	tmpstr = tmpstr1 = strdup(args);
-	cp = index(tmpstr1, '\n');
+	cp = strchr(tmpstr1, '\n');
 	if (cp)
 		*cp = '\0';
 	for (;;tmpstr1 = cp) {

Modified: trunk/usr.bin/systat/netstat.c
===================================================================
--- trunk/usr.bin/systat/netstat.c	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/netstat.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1980, 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -29,7 +30,7 @@
 
 #include <sys/cdefs.h>
 
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/systat/netstat.c 288163 2015-09-24 00:50:17Z delphij $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)netstat.c	8.1 (Berkeley) 6/6/93";
@@ -85,7 +86,7 @@
 static void inetprint(struct sockaddr *, const char *);
 
 #define	streq(a,b)	(strcmp(a,b)==0)
-#define	YMAX(w)		((w)->_maxy-1)
+#define	YMAX(w)		(getmaxy(w)-2)
 
 WINDOW *
 opennetstat(void)
@@ -349,7 +350,6 @@
 	}
 }
 
-
 static struct netinfo *
 enter(struct inpcb *inp, int state, const char *proto)
 {
@@ -437,7 +437,6 @@
 #define	SNDCC	RCVCC+7
 #define	STATE	SNDCC+7
 
-
 void
 labelnetstat(void)
 {
@@ -554,7 +553,7 @@
 		break;
 	}
 	snprintf(line, sizeof(line), "%.*s.", 16, inetname(sa));
-	cp = index(line, '\0');
+	cp = strchr(line, '\0');
 	if (!nflag && port)
 		sp = getservbyport(port, proto);
 	if (sp || port == 0)
@@ -564,7 +563,7 @@
 		snprintf(cp, sizeof(line) - (cp - line), "%d",
 		    ntohs((u_short)port));
 	/* pad to full column to clear any garbage */
-	cp = index(line, '\0');
+	cp = strchr(line, '\0');
 	while (cp - line < 22)
 		*cp++ = ' ';
 	line[22] = '\0';

Modified: trunk/usr.bin/systat/pigs.c
===================================================================
--- trunk/usr.bin/systat/pigs.c	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/pigs.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1980, 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -34,7 +35,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/systat/pigs.c 288163 2015-09-24 00:50:17Z delphij $");
 
 /*
  * Pigs display from Bill Reeves at Lucasfilm
@@ -81,7 +82,6 @@
 	delwin(w);
 }
 
-
 void
 showpigs(void)
 {
@@ -95,8 +95,8 @@
 	qsort(pt, nproc, sizeof (struct p_times), compar);
 	y = 1;
 	i = nproc;
-	if (i > wnd->_maxy-1)
-		i = wnd->_maxy-1;
+	if (i > getmaxy(wnd)-2)
+		i = getmaxy(wnd)-2;
 	for (k = 0; i > 0 && pt[k].pt_pctcpu > 0.01; i--, y++, k++) {
 		uname = user_from_uid(pt[k].pt_kp->ki_uid, 0);
 		pname = pt[k].pt_kp->ki_comm;

Added: trunk/usr.bin/systat/sctp.c
===================================================================
--- trunk/usr.bin/systat/sctp.c	                        (rev 0)
+++ trunk/usr.bin/systat/sctp.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -0,0 +1,363 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2015
+ * The Regents of the University of California.  All rights reserved.
+ * Michael Tuexen.  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.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/usr.bin/systat/sctp.c 294285 2016-01-18 18:50:26Z tuexen $");
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/sysctl.h>
+
+#include <netinet/sctp.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "systat.h"
+#include "extern.h"
+#include "mode.h"
+
+static struct sctpstat curstat, initstat, oldstat;
+
+/*-
+--0         1         2         3         4         5         6         7
+--0123456789012345678901234567890123456789012345678901234567890123456789012345
+00             SCTP Associations                     SCTP Packets
+01999999999999 associations initiated   999999999999 packets sent
+02999999999999 associations accepted    999999999999 packets received
+03999999999999 associations established 999999999999 - out of the blue
+04999999999999 associations restarted   999999999999 - bad vtag
+05999999999999 associations terminated  999999999999 - bad crc32c
+06999999999999 associations aborted
+07
+08             SCTP Timers                           SCTP Chunks
+09999999999999 init timeouts            999999999999 control chunks sent
+10999999999999 cookie timeouts          999999999999 data chunks sent
+11999999999999 data timeouts            999999999999 - ordered
+12999999999999 delayed sack timeouts    999999999999 - unordered
+13999999999999 shutdown timeouts        999999999999 control chunks received
+14999999999999 shutdown-ack timeouts    999999999999 data chunks received
+15999999999999 shutdown guard timeouts  999999999999 - ordered
+16999999999999 heartbeat timeouts       999999999999 - unordered
+17999999999999 path MTU timeouts
+18999999999999 autoclose timeouts                    SCTP user messages
+19999999999999 asconf timeouts          999999999999 fragmented
+20999999999999 stream reset timeouts    999999999999 reassembled
+--0123456789012345678901234567890123456789012345678901234567890123456789012345
+--0         1         2         3         4         5         6         7
+*/
+
+WINDOW *
+opensctp(void)
+{
+	return (subwin(stdscr, LINES-3-1, 0, MAINWIN_ROW, 0));
+}
+
+void
+closesctp(WINDOW *w)
+{
+	if (w != NULL) {
+		wclear(w);
+		wrefresh(w);
+		delwin(w);
+	}
+}
+
+void
+labelsctp(void)
+{
+	wmove(wnd, 0, 0); wclrtoeol(wnd);
+#define L(row, str) mvwprintw(wnd, row, 13, str)
+#define R(row, str) mvwprintw(wnd, row, 51, str);
+	L(0, "SCTP Associations");		R(0, "SCTP Packets");
+	L(1, "associations initiated");		R(1, "packets sent");
+	L(2, "associations accepted");		R(2, "packets received");
+	L(3, "associations established");	R(3, "- out of the blue");
+	L(4, "associations restarted");		R(4, "- bad vtag");
+	L(5, "associations terminated");	R(5, "- bad crc32c");
+	L(6, "associations aborted");
+
+	L(8, "SCTP Timers");			R(8, "SCTP Chunks");
+	L(9, "init timeouts");			R(9, "control chunks sent");
+	L(10, "cookie timeouts");		R(10, "data chunks sent");
+	L(11, "data timeouts");			R(11, "- ordered");
+	L(12, "delayed sack timeouts");		R(12, "- unordered");
+	L(13, "shutdown timeouts");		R(13, "control chunks received");
+	L(14, "shutdown-ack timeouts");		R(14, "data chunks received");
+	L(15, "shutdown guard timeouts");	R(15, "- ordered");
+	L(16, "heartbeat timeouts");		R(16, "- unordered");
+	L(17, "path MTU timeouts");
+	L(18, "autoclose timeouts");		R(18, "SCTP User Messages");
+	L(19, "asconf timeouts");		R(19, "fragmented");
+	L(20, "stream reset timeouts");		R(20, "reassembled");
+#undef L
+#undef R
+}
+
+static void
+domode(struct sctpstat *ret)
+{
+	const struct sctpstat *sub;
+	int divisor = 1;
+
+	switch(currentmode) {
+	case display_RATE:
+		sub = &oldstat;
+		divisor = (delay > 1000000) ? delay / 1000000 : 1;
+		break;
+	case display_DELTA:
+		sub = &oldstat;
+		break;
+	case display_SINCE:
+		sub = &initstat;
+		break;
+	default:
+		*ret = curstat;
+		return;
+	}
+#define DO(stat) ret->stat = (curstat.stat - sub->stat) / divisor
+	DO(sctps_currestab);
+	DO(sctps_activeestab);
+	DO(sctps_restartestab);
+	DO(sctps_collisionestab);
+	DO(sctps_passiveestab);
+	DO(sctps_aborted);
+	DO(sctps_shutdown);
+	DO(sctps_outoftheblue);
+	DO(sctps_checksumerrors);
+	DO(sctps_outcontrolchunks);
+	DO(sctps_outorderchunks);
+	DO(sctps_outunorderchunks);
+	DO(sctps_incontrolchunks);
+	DO(sctps_inorderchunks);
+	DO(sctps_inunorderchunks);
+	DO(sctps_fragusrmsgs);
+	DO(sctps_reasmusrmsgs);
+	DO(sctps_outpackets);
+	DO(sctps_inpackets);
+
+	DO(sctps_recvpackets);
+	DO(sctps_recvdatagrams);
+	DO(sctps_recvpktwithdata);
+	DO(sctps_recvsacks);
+	DO(sctps_recvdata);
+	DO(sctps_recvdupdata);
+	DO(sctps_recvheartbeat);
+	DO(sctps_recvheartbeatack);
+	DO(sctps_recvecne);
+	DO(sctps_recvauth);
+	DO(sctps_recvauthmissing);
+	DO(sctps_recvivalhmacid);
+	DO(sctps_recvivalkeyid);
+	DO(sctps_recvauthfailed);
+	DO(sctps_recvexpress);
+	DO(sctps_recvexpressm);
+	DO(sctps_recvnocrc);
+	DO(sctps_recvswcrc);
+	DO(sctps_recvhwcrc);
+
+	DO(sctps_sendpackets);
+	DO(sctps_sendsacks);
+	DO(sctps_senddata);
+	DO(sctps_sendretransdata);
+	DO(sctps_sendfastretrans);
+	DO(sctps_sendmultfastretrans);
+	DO(sctps_sendheartbeat);
+	DO(sctps_sendecne);
+	DO(sctps_sendauth);
+	DO(sctps_senderrors);
+	DO(sctps_sendnocrc);
+	DO(sctps_sendswcrc);
+	DO(sctps_sendhwcrc);
+
+	DO(sctps_pdrpfmbox);
+	DO(sctps_pdrpfehos);
+	DO(sctps_pdrpmbda);
+	DO(sctps_pdrpmbct);
+	DO(sctps_pdrpbwrpt);
+	DO(sctps_pdrpcrupt);
+	DO(sctps_pdrpnedat);
+	DO(sctps_pdrppdbrk);
+	DO(sctps_pdrptsnnf);
+	DO(sctps_pdrpdnfnd);
+	DO(sctps_pdrpdiwnp);
+	DO(sctps_pdrpdizrw);
+	DO(sctps_pdrpbadd);
+	DO(sctps_pdrpmark);
+
+	DO(sctps_timoiterator);
+	DO(sctps_timodata);
+	DO(sctps_timowindowprobe);
+	DO(sctps_timoinit);
+	DO(sctps_timosack);
+	DO(sctps_timoshutdown);
+	DO(sctps_timoheartbeat);
+	DO(sctps_timocookie);
+	DO(sctps_timosecret);
+	DO(sctps_timopathmtu);
+	DO(sctps_timoshutdownack);
+	DO(sctps_timoshutdownguard);
+	DO(sctps_timostrmrst);
+	DO(sctps_timoearlyfr);
+	DO(sctps_timoasconf);
+	DO(sctps_timodelprim);
+	DO(sctps_timoautoclose);
+	DO(sctps_timoassockill);
+	DO(sctps_timoinpkill);
+
+	DO(sctps_hdrops);
+	DO(sctps_badsum);
+	DO(sctps_noport);
+	DO(sctps_badvtag);
+	DO(sctps_badsid);
+	DO(sctps_nomem);
+	DO(sctps_fastretransinrtt);
+	DO(sctps_markedretrans);
+	DO(sctps_naglesent);
+	DO(sctps_naglequeued);
+	DO(sctps_maxburstqueued);
+	DO(sctps_ifnomemqueued);
+	DO(sctps_windowprobed);
+	DO(sctps_lowlevelerr);
+	DO(sctps_lowlevelerrusr);
+	DO(sctps_datadropchklmt);
+	DO(sctps_datadroprwnd);
+	DO(sctps_ecnereducedcwnd);
+	DO(sctps_vtagexpress);
+	DO(sctps_vtagbogus);
+	DO(sctps_primary_randry);
+	DO(sctps_cmt_randry);
+	DO(sctps_slowpath_sack);
+	DO(sctps_wu_sacks_sent);
+	DO(sctps_sends_with_flags);
+	DO(sctps_sends_with_unord);
+	DO(sctps_sends_with_eof);
+	DO(sctps_sends_with_abort);
+	DO(sctps_protocol_drain_calls);
+	DO(sctps_protocol_drains_done);
+	DO(sctps_read_peeks);
+	DO(sctps_cached_chk);
+	DO(sctps_cached_strmoq);
+	DO(sctps_left_abandon);
+	DO(sctps_send_burst_avoid);
+	DO(sctps_send_cwnd_avoid);
+	DO(sctps_fwdtsn_map_over);
+	DO(sctps_queue_upd_ecne);
+#undef DO
+}
+
+void
+showsctp(void)
+{
+	struct sctpstat stats;
+
+	memset(&stats, 0, sizeof stats);
+	domode(&stats);
+
+#define DO(stat, row, col) \
+	mvwprintw(wnd, row, col, "%12lu", stats.stat)
+#define	L(row, stat) DO(stat, row, 0)
+#define	R(row, stat) DO(stat, row, 38)
+	L(1, sctps_activeestab);	R(1, sctps_outpackets);
+	L(2, sctps_passiveestab);	R(2, sctps_inpackets);
+	L(3, sctps_currestab);		R(3, sctps_outoftheblue);
+	L(4, sctps_restartestab);	R(4, sctps_badvtag);
+	L(5, sctps_shutdown);		R(5, sctps_checksumerrors);
+	L(6, sctps_aborted);
+
+
+	L(9, sctps_timoinit);		R(9, sctps_outcontrolchunks);
+	L(10, sctps_timocookie);	R(10, sctps_senddata);
+	L(11, sctps_timodata);		R(11, sctps_outorderchunks);
+	L(12, sctps_timosack);		R(12, sctps_outunorderchunks);
+	L(13, sctps_timoshutdown);	R(13, sctps_incontrolchunks);
+	L(14, sctps_timoshutdownack);	R(14, sctps_recvdata);
+	L(15, sctps_timoshutdownguard);	R(15, sctps_inorderchunks);
+	L(16, sctps_timoheartbeat);	R(16, sctps_inunorderchunks);
+	L(17, sctps_timopathmtu);
+	L(18, sctps_timoautoclose);
+	L(19, sctps_timoasconf);	R(19, sctps_fragusrmsgs);
+	L(20, sctps_timostrmrst);	R(20, sctps_reasmusrmsgs);
+#undef DO
+#undef L
+#undef R
+}
+
+int
+initsctp(void)
+{
+	size_t len;
+	const char *name = "net.inet.sctp.stats";
+
+	len = 0;
+	if (sysctlbyname(name, NULL, &len, NULL, 0) < 0) {
+		error("sysctl getting sctpstat size failed");
+		return 0;
+	}
+	if (len > sizeof curstat) {
+		error("sctpstat structure has grown--recompile systat!");
+		return 0;
+	}
+	if (sysctlbyname(name, &initstat, &len, NULL, 0) < 0) {
+		error("sysctl getting sctpstat failed");
+		return 0;
+	}
+	oldstat = initstat;
+	return 1;
+}
+
+void
+resetsctp(void)
+{
+	size_t len;
+	const char *name = "net.inet.sctp.stats";
+
+	len = sizeof initstat;
+	if (sysctlbyname(name, &initstat, &len, NULL, 0) < 0) {
+		error("sysctl getting sctpstat failed");
+	}
+	oldstat = initstat;
+}
+
+void
+fetchsctp(void)
+{
+	size_t len;
+	const char *name = "net.inet.sctp.stats";
+
+	oldstat = curstat;
+	len = sizeof curstat;
+	if (sysctlbyname(name, &curstat, &len, NULL, 0) < 0) {
+		error("sysctl getting sctpstat failed");
+	}
+	return;
+}


Property changes on: trunk/usr.bin/systat/sctp.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/usr.bin/systat/swap.c
===================================================================
--- trunk/usr.bin/systat/swap.c	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/swap.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1980, 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -29,7 +30,7 @@
 
 #include <sys/cdefs.h>
 
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/systat/swap.c 216370 2010-12-11 08:32:16Z joel $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)swap.c	8.3 (Berkeley) 4/29/95";

Modified: trunk/usr.bin/systat/systat.1
===================================================================
--- trunk/usr.bin/systat/systat.1	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/systat.1	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 1985, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
 .\"
@@ -26,9 +27,9 @@
 .\" SUCH DAMAGE.
 .\"
 .\"	@(#)systat.1	8.2 (Berkeley) 12/30/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.bin/systat/systat.1 316194 2017-03-30 01:48:36Z sevan $
 .\"
-.Dd September 17, 2012
+.Dd December 5, 2016
 .Dt SYSTAT 1
 .Os
 .Sh NAME
@@ -67,7 +68,6 @@
 .Xr iostat 8 ) ,
 virtual memory statistics (a la
 .Xr vmstat 8 ) ,
-network ``mbuf'' utilization,
 .Tn TCP/IP
 statistics,
 and network connections (a la
@@ -94,14 +94,14 @@
 .Ic iostat ,
 .Ic ip ,
 .Ic ip6 ,
-.Ic mbufs ,
 .Ic netstat ,
 .Ic pigs ,
-.Ic sensors ,
+.Ic sctp ,
 .Ic swap ,
 .Ic tcp ,
+.Ic vmstat ,
 or
-.Ic vmstat .
+.Ic zarc ,
 These displays can also be requested interactively (without the
 .Dq Fl )
 and are described in
@@ -111,6 +111,26 @@
 .Ar refresh-value
 specifies the screen refresh time interval in seconds.
 Time interval can be fractional.
+.It Ar display-commands
+A list of commands specific to this display.
+These commands can also be entered interactively and are described for
+each display separately below.
+If the command requires arguments, they can be specified as separate
+command line arguments.
+A command line argument
+.Fl -
+will finish display commands.
+For example:
+.Pp
+.Dl Nm Fl ifstat Fl match Ar bge0,em1 Fl pps
+.Pp
+This will display statistics of packets per second for network interfaces
+named as bge0 and em1.
+.Pp
+.Dl Nm Fl iostat Fl numbers Fl - Ar 2.1
+.Pp
+This will display all IO statistics in a numeric format and the information
+will be refreshed each 2.1 seconds.
 .El
 .Pp
 Certain characters cause immediate action by
@@ -226,6 +246,12 @@
 statistics.
 It does not display
 .Tn UDP statistics.
+.It Ic sctp
+Like
+.Ic icmp ,
+but with
+.Tn SCTP
+statistics.
 .It Ic tcp
 Like
 .Ic icmp ,
@@ -281,14 +307,6 @@
 If there are more than one swap partition in use,
 a total line is also shown.
 Areas known to the kernel, but not in use are shown as not available.
-.It Ic mbufs
-Display, in the lower window, the number of mbufs allocated
-for particular uses, i.e., data, socket structures, etc.
-.It Ic sensors
-Display, in the lower window,
-the current values of available hardware sensors,
-in a format similar to that of
-.Xr sysctl 8 .
 .It Ic vmstat
 Take over the entire display and show a (rather crowded) compendium
 of statistics related to virtual memory usage, process scheduling,
@@ -434,6 +452,8 @@
 .It Cm zero
 Reset running statistics to zero.
 .El
+.It Ic zarc
+display arc cache usage and hit/miss statistics.
 .It Ic netstat
 Display, in the lower window, network connections.
 By default,
@@ -517,6 +537,28 @@
 interfaces.
 The following units are recognised: kbit, kbyte, mbit,
 mbyte, gbit, gbyte and auto.
+.It Cm pps
+Show statistics in packets per second instead of bytes/bits per second.
+A subsequent call of
+.Ic pps
+switches this mode off.
+.It Cm match Op Ar patterns
+Display only interfaces that match pattern provided as an argument.
+Patterns should be in shell syntax separated by whitespaces or commas.
+If this command is called without arguments then all interfaces are displayed.
+For example:
+.Pp
+.Dl match em0, bge1
+.Pp
+This will display em0 and bge1 interfaces.
+.Pp
+.Dl match em*, bge*, lo0
+.Pp
+This will display all
+.Ic em
+interfaces, all
+.Ic bge
+interfaces and the loopback interface.
 .El
 .El
 .Pp
@@ -610,7 +652,6 @@
 .Xr udp 4 ,
 .Xr gstat 8 ,
 .Xr iostat 8 ,
-.Xr sysctl 8 ,
 .Xr vmstat 8
 .Sh HISTORY
 The


Property changes on: trunk/usr.bin/systat/systat.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/systat/systat.h
===================================================================
--- trunk/usr.bin/systat/systat.h	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/systat.h	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1980, 1989, 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -27,7 +28,7 @@
  * SUCH DAMAGE.
  *
  *	From: @(#)systat.h	8.1 (Berkeley) 6/6/93
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.bin/systat/systat.h 303684 2016-08-02 22:33:29Z mr $
  */
 
 #include <curses.h>
@@ -54,6 +55,7 @@
 
 #define	CF_INIT		0x1		/* been initialized */
 #define	CF_LOADAV	0x2		/* display w/ load average */
+#define	CF_ZFSARC	0x4		/* display w/ ZFS cache usage */
 
 #define	TCP	0x1
 #define	UDP	0x2

Modified: trunk/usr.bin/systat/tcp.c
===================================================================
--- trunk/usr.bin/systat/tcp.c	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/tcp.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1980, 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -37,7 +38,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/systat/tcp.c 240605 2012-09-17 13:36:47Z melifaro $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -324,4 +325,3 @@
 	if (sysctl(name, 4, &curstat, &len, 0, 0) < 0)
 		return;
 }
-

Modified: trunk/usr.bin/systat/vmstat.c
===================================================================
--- trunk/usr.bin/systat/vmstat.c	2018-07-03 19:35:23 UTC (rev 11257)
+++ trunk/usr.bin/systat/vmstat.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1983, 1989, 1992, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -29,7 +30,7 @@
 
 #include <sys/cdefs.h>
 
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/systat/vmstat.c 288163 2015-09-24 00:50:17Z delphij $");
 
 #ifdef lint
 static const char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 1/12/94";
@@ -79,6 +80,7 @@
 	 * Virtual memory activity.
 	 */
 	u_int v_vm_faults;	/* number of address memory faults */
+	u_int v_io_faults;	/* page faults requiring I/O */
 	u_int v_cow_faults;	/* number of copy-on-writes */
 	u_int v_zfod;		/* pages zero filled on demand */
 	u_int v_ozfod;		/* optimized zero fill pages */
@@ -204,12 +206,9 @@
 		return(0);
 	}
 
-	cur.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo));
-	last.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo));
-	run.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo));
-	bzero(cur.dinfo, sizeof(struct devinfo));
-	bzero(last.dinfo, sizeof(struct devinfo));
-	bzero(run.dinfo, sizeof(struct devinfo));
+	cur.dinfo = calloc(1, sizeof(struct devinfo));
+	last.dinfo = calloc(1, sizeof(struct devinfo));
+	run.dinfo = calloc(1, sizeof(struct devinfo));
 
 	if (dsinit(MAXDRIVES, &cur, &last, &run) != 1)
 		return(0);
@@ -324,24 +323,25 @@
 	mvprintw(INTSROW, INTSCOL + 1, "Interrupts");
 	mvprintw(INTSROW + 1, INTSCOL + 6, "total");
 
-	mvprintw(VMSTATROW, VMSTATCOL + 9, "cow");
-	mvprintw(VMSTATROW + 1, VMSTATCOL + 9, "zfod");
-	mvprintw(VMSTATROW + 2, VMSTATCOL + 9, "ozfod");
-	mvprintw(VMSTATROW + 3, VMSTATCOL + 9 - 1, "%%ozfod");
-	mvprintw(VMSTATROW + 4, VMSTATCOL + 9, "daefr");
-	mvprintw(VMSTATROW + 5, VMSTATCOL + 9, "prcfr");
-	mvprintw(VMSTATROW + 6, VMSTATCOL + 9, "totfr");
-	mvprintw(VMSTATROW + 7, VMSTATCOL + 9, "react");
-	mvprintw(VMSTATROW + 8, VMSTATCOL + 9, "pdwak");
-	mvprintw(VMSTATROW + 9, VMSTATCOL + 9, "pdpgs");
-	mvprintw(VMSTATROW + 10, VMSTATCOL + 9, "intrn");
-	mvprintw(VMSTATROW + 11, VMSTATCOL + 9, "wire");
-	mvprintw(VMSTATROW + 12, VMSTATCOL + 9, "act");
-	mvprintw(VMSTATROW + 13, VMSTATCOL + 9, "inact");
-	mvprintw(VMSTATROW + 14, VMSTATCOL + 9, "cache");
-	mvprintw(VMSTATROW + 15, VMSTATCOL + 9, "free");
-	if (LINES - 1 > VMSTATROW + 16)
-		mvprintw(VMSTATROW + 16, VMSTATCOL + 9, "buf");
+	mvprintw(VMSTATROW, VMSTATCOL + 9, "ioflt");
+	mvprintw(VMSTATROW + 1, VMSTATCOL + 9, "cow");
+	mvprintw(VMSTATROW + 2, VMSTATCOL + 9, "zfod");
+	mvprintw(VMSTATROW + 3, VMSTATCOL + 9, "ozfod");
+	mvprintw(VMSTATROW + 4, VMSTATCOL + 9 - 1, "%%ozfod");
+	mvprintw(VMSTATROW + 5, VMSTATCOL + 9, "daefr");
+	mvprintw(VMSTATROW + 6, VMSTATCOL + 9, "prcfr");
+	mvprintw(VMSTATROW + 7, VMSTATCOL + 9, "totfr");
+	mvprintw(VMSTATROW + 8, VMSTATCOL + 9, "react");
+	mvprintw(VMSTATROW + 9, VMSTATCOL + 9, "pdwak");
+	mvprintw(VMSTATROW + 10, VMSTATCOL + 9, "pdpgs");
+	mvprintw(VMSTATROW + 11, VMSTATCOL + 9, "intrn");
+	mvprintw(VMSTATROW + 12, VMSTATCOL + 9, "wire");
+	mvprintw(VMSTATROW + 13, VMSTATCOL + 9, "act");
+	mvprintw(VMSTATROW + 14, VMSTATCOL + 9, "inact");
+	mvprintw(VMSTATROW + 15, VMSTATCOL + 9, "cache");
+	mvprintw(VMSTATROW + 16, VMSTATCOL + 9, "free");
+	if (LINES - 1 > VMSTATROW + 17)
+		mvprintw(VMSTATROW + 17, VMSTATCOL + 9, "buf");
 
 	mvprintw(GENSTATROW, GENSTATCOL, " Csw  Trp  Sys  Int  Sof  Flt");
 
@@ -493,25 +493,26 @@
 	putint(total.t_dw, PROCSROW + 2, PROCSCOL + 8, 3);
 	putint(total.t_sl, PROCSROW + 2, PROCSCOL + 12, 3);
 	putint(total.t_sw, PROCSROW + 2, PROCSCOL + 16, 3);
-	PUTRATE(v_cow_faults, VMSTATROW, VMSTATCOL + 2, 8 - 2);
-	PUTRATE(v_zfod, VMSTATROW + 1, VMSTATCOL + 2, 8 - 2);
-	PUTRATE(v_ozfod, VMSTATROW + 2, VMSTATCOL, 8);
+	PUTRATE(v_io_faults, VMSTATROW, VMSTATCOL + 2, 8 - 2);
+	PUTRATE(v_cow_faults, VMSTATROW + 1, VMSTATCOL + 2, 8 - 2);
+	PUTRATE(v_zfod, VMSTATROW + 2, VMSTATCOL + 2, 8 - 2);
+	PUTRATE(v_ozfod, VMSTATROW + 3, VMSTATCOL, 8);
 	putint(s.v_zfod != 0 ? (int)(s.v_ozfod * 100.0 / s.v_zfod) : 0,
-	    VMSTATROW + 3, VMSTATCOL + 1, 8 - 1);
-	PUTRATE(v_dfree, VMSTATROW + 4, VMSTATCOL + 2, 8 - 2);
-	PUTRATE(v_pfree, VMSTATROW + 5, VMSTATCOL + 2, 8 - 2);
-	PUTRATE(v_tfree, VMSTATROW + 6, VMSTATCOL, 8);
-	PUTRATE(v_reactivated, VMSTATROW + 7, VMSTATCOL, 8);
-	PUTRATE(v_pdwakeups, VMSTATROW + 8, VMSTATCOL, 8);
-	PUTRATE(v_pdpages, VMSTATROW + 9, VMSTATCOL, 8);
-	PUTRATE(v_intrans, VMSTATROW + 10, VMSTATCOL, 8);
-	putint(pgtokb(s.v_wire_count), VMSTATROW + 11, VMSTATCOL, 8);
-	putint(pgtokb(s.v_active_count), VMSTATROW + 12, VMSTATCOL, 8);
-	putint(pgtokb(s.v_inactive_count), VMSTATROW + 13, VMSTATCOL, 8);
-	putint(pgtokb(s.v_cache_count), VMSTATROW + 14, VMSTATCOL, 8);
-	putint(pgtokb(s.v_free_count), VMSTATROW + 15, VMSTATCOL, 8);
-	if (LINES - 1 > VMSTATROW + 16)
-		putint(s.bufspace / 1024, VMSTATROW + 16, VMSTATCOL, 8);
+	    VMSTATROW + 4, VMSTATCOL + 1, 8 - 1);
+	PUTRATE(v_dfree, VMSTATROW + 5, VMSTATCOL + 2, 8 - 2);
+	PUTRATE(v_pfree, VMSTATROW + 6, VMSTATCOL + 2, 8 - 2);
+	PUTRATE(v_tfree, VMSTATROW + 7, VMSTATCOL, 8);
+	PUTRATE(v_reactivated, VMSTATROW + 8, VMSTATCOL, 8);
+	PUTRATE(v_pdwakeups, VMSTATROW + 9, VMSTATCOL, 8);
+	PUTRATE(v_pdpages, VMSTATROW + 10, VMSTATCOL, 8);
+	PUTRATE(v_intrans, VMSTATROW + 11, VMSTATCOL, 8);
+	putint(pgtokb(s.v_wire_count), VMSTATROW + 12, VMSTATCOL, 8);
+	putint(pgtokb(s.v_active_count), VMSTATROW + 13, VMSTATCOL, 8);
+	putint(pgtokb(s.v_inactive_count), VMSTATROW + 14, VMSTATCOL, 8);
+	putint(pgtokb(s.v_cache_count), VMSTATROW + 15, VMSTATCOL, 8);
+	putint(pgtokb(s.v_free_count), VMSTATROW + 16, VMSTATCOL, 8);
+	if (LINES - 1 > VMSTATROW + 17)
+		putint(s.bufspace / 1024, VMSTATROW + 17, VMSTATCOL, 8);
 	PUTRATE(v_vnodein, PAGEROW + 2, PAGECOL + 6, 5);
 	PUTRATE(v_vnodeout, PAGEROW + 2, PAGECOL + 12, 5);
 	PUTRATE(v_swapin, PAGEROW + 2, PAGECOL + 19, 5);
@@ -700,6 +701,10 @@
 	snr = snprintf(b, sizeof(b), "%*.*f", w, d, f);
 	if (snr != w)
 		snr = snprintf(b, sizeof(b), "%*.0f", w, f);
+	if (snr != w)
+		snr = snprintf(b, sizeof(b), "%*.0fk", w - 1, f / 1000);
+	if (snr != w)
+		snr = snprintf(b, sizeof(b), "%*.0fM", w - 1, f / 1000000);
 	if (snr != w) {
 		while (--w >= 0)
 			addch('*');
@@ -728,6 +733,10 @@
 	snr = snprintf(b, sizeof(b), "%*.*Lf", w, d, f);
 	if (snr != w)
 		snr = snprintf(b, sizeof(b), "%*.0Lf", w, f);
+	if (snr != w)
+		snr = snprintf(b, sizeof(b), "%*.0Lfk", w - 1, f / 1000);
+	if (snr != w)
+		snr = snprintf(b, sizeof(b), "%*.0LfM", w - 1, f / 1000000);
 	if (snr != w) {
 		while (--w >= 0)
 			addch('*');
@@ -751,6 +760,7 @@
 	GETSYSCTL("vm.stats.sys.v_intr", ls->v_intr);
 	GETSYSCTL("vm.stats.sys.v_soft", ls->v_soft);
 	GETSYSCTL("vm.stats.vm.v_vm_faults", ls->v_vm_faults);
+	GETSYSCTL("vm.stats.vm.v_io_faults", ls->v_io_faults);
 	GETSYSCTL("vm.stats.vm.v_cow_faults", ls->v_cow_faults);
 	GETSYSCTL("vm.stats.vm.v_zfod", ls->v_zfod);
 	GETSYSCTL("vm.stats.vm.v_ozfod", ls->v_ozfod);

Added: trunk/usr.bin/systat/zarc.c
===================================================================
--- trunk/usr.bin/systat/zarc.c	                        (rev 0)
+++ trunk/usr.bin/systat/zarc.c	2018-07-03 23:45:37 UTC (rev 11258)
@@ -0,0 +1,222 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2014
+ *	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.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/usr.bin/systat/zarc.c 303684 2016-08-02 22:33:29Z mr $");
+
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+#include <string.h>
+
+#include "systat.h"
+#include "extern.h"
+
+struct zfield{
+	uint64_t arcstats;
+	uint64_t arcstats_demand_data;
+	uint64_t arcstats_demand_metadata;
+	uint64_t arcstats_prefetch_data;
+	uint64_t arcstats_prefetch_metadata;
+	uint64_t zfetchstats;
+	uint64_t arcstats_l2;
+	uint64_t vdev_cache_stats;
+};
+
+static struct zarcstats {
+	struct zfield hits;
+	struct zfield misses;
+} curstat, initstat, oldstat;
+
+static void
+getinfo(struct zarcstats *ls);
+
+WINDOW *
+openzarc(void)
+{
+	return (subwin(stdscr, LINES-3-1, 0, MAINWIN_ROW, 0));
+}
+
+void
+closezarc(WINDOW *w)
+{
+	if (w == NULL)
+		return;
+	wclear(w);
+	wrefresh(w);
+	delwin(w);
+}
+
+void
+labelzarc(void)
+{
+	wmove(wnd, 0, 0); wclrtoeol(wnd);
+	mvwprintw(wnd, 0, 31+1, "%4.4s %7.7s %7.7s %12.12s %12.12s",
+		"rate", "hits", "misses", "total hits", "total misses");
+#define L(row, str) mvwprintw(wnd, row, 5, str); \
+	mvwprintw(wnd, row, 31, ":"); \
+	mvwprintw(wnd, row, 31+4, "%%")
+	L(1, "arcstats");
+	L(2, "arcstats.demand_data");
+	L(3, "arcstats.demand_metadata");
+	L(4, "arcstats.prefetch_data");
+	L(5, "arcstats.prefetch_metadata");
+	L(6, "zfetchstats");
+	L(7, "arcstats.l2");
+	L(8, "vdev_cache_stats");
+#undef L
+}
+
+static int calc(uint64_t hits, uint64_t misses)
+{
+    if( hits )
+	return 100 * hits / ( hits + misses );
+    else
+	return 0;
+}
+
+static void
+domode(struct zarcstats *delta, struct zarcstats *rate)
+{
+#define DO(stat) \
+	delta->hits.stat = (curstat.hits.stat - oldstat.hits.stat); \
+	delta->misses.stat = (curstat.misses.stat - oldstat.misses.stat); \
+	rate->hits.stat = calc(delta->hits.stat, delta->misses.stat)
+	DO(arcstats);
+	DO(arcstats_demand_data);
+	DO(arcstats_demand_metadata);
+	DO(arcstats_prefetch_data);
+	DO(arcstats_prefetch_metadata);
+	DO(zfetchstats);
+	DO(arcstats_l2);
+	DO(vdev_cache_stats);
+	DO(arcstats);
+	DO(arcstats_demand_data);
+	DO(arcstats_demand_metadata);
+	DO(arcstats_prefetch_data);
+	DO(arcstats_prefetch_metadata);
+	DO(zfetchstats);
+	DO(arcstats_l2);
+	DO(vdev_cache_stats);
+#undef DO
+}
+
+void
+showzarc(void)
+{
+	struct zarcstats delta, rate;
+
+	memset(&delta, 0, sizeof delta);
+	memset(&rate, 0, sizeof rate);
+
+	domode(&delta, &rate);
+
+#define DO(stat, row, col, fmt) \
+	mvwprintw(wnd, row, col, fmt, stat)
+#define	R(row, stat) DO(rate.hits.stat, row, 31+1, "%3lu")
+#define	H(row, stat) DO(delta.hits.stat, row, 31+1+5, "%7lu"); \
+	DO(curstat.hits.stat, row, 31+1+5+8+8, "%12lu")
+#define	M(row, stat) DO(delta.misses.stat, row, 31+1+5+8, "%7lu"); \
+	DO(curstat.misses.stat, row, 31+1+5+8+8+13, "%12lu")
+#define	E(row, stat) R(row, stat); H(row, stat); M(row, stat); 
+	E(1, arcstats);
+	E(2, arcstats_demand_data);
+	E(3, arcstats_demand_metadata);
+	E(4, arcstats_prefetch_data);
+	E(5, arcstats_prefetch_metadata);
+	E(6, zfetchstats);
+	E(7, arcstats_l2);
+	E(8, vdev_cache_stats);
+#undef DO
+#undef E
+#undef M
+#undef H
+#undef R
+}
+
+int
+initzarc(void)
+{
+	getinfo(&initstat);
+	curstat = oldstat = initstat;
+	return 1;
+}
+
+void
+resetzarc(void)
+{
+	initzarc();
+}
+
+static void
+getinfo(struct zarcstats *ls)
+{
+	size_t size = sizeof( ls->hits.arcstats );
+	if ( sysctlbyname("kstat.zfs.misc.arcstats.hits",
+		&ls->hits.arcstats, &size, NULL, 0 ) != 0 )
+		return;
+	GETSYSCTL("kstat.zfs.misc.arcstats.misses",
+		ls->misses.arcstats);
+	GETSYSCTL("kstat.zfs.misc.arcstats.demand_data_hits",
+		ls->hits.arcstats_demand_data);
+	GETSYSCTL("kstat.zfs.misc.arcstats.demand_data_misses",
+		ls->misses.arcstats_demand_data);
+	GETSYSCTL("kstat.zfs.misc.arcstats.demand_metadata_hits",
+		ls->hits.arcstats_demand_metadata);
+	GETSYSCTL("kstat.zfs.misc.arcstats.demand_metadata_misses",
+		ls->misses.arcstats_demand_metadata);
+	GETSYSCTL("kstat.zfs.misc.arcstats.prefetch_data_hits",
+		ls->hits.arcstats_prefetch_data);
+	GETSYSCTL("kstat.zfs.misc.arcstats.prefetch_data_misses",
+		ls->misses.arcstats_prefetch_data);
+	GETSYSCTL("kstat.zfs.misc.arcstats.prefetch_metadata_hits",
+		ls->hits.arcstats_prefetch_metadata);
+	GETSYSCTL("kstat.zfs.misc.arcstats.prefetch_metadata_misses",
+		ls->misses.arcstats_prefetch_metadata);
+	GETSYSCTL("kstat.zfs.misc.zfetchstats.hits",
+		ls->hits.zfetchstats);
+	GETSYSCTL("kstat.zfs.misc.zfetchstats.misses",
+		ls->misses.zfetchstats);
+	GETSYSCTL("kstat.zfs.misc.arcstats.l2_hits",
+		ls->hits.arcstats_l2);
+	GETSYSCTL("kstat.zfs.misc.arcstats.l2_misses",
+		ls->misses.arcstats_l2);
+	GETSYSCTL("kstat.zfs.misc.vdev_cache_stats.hits",
+		ls->hits.vdev_cache_stats);
+	GETSYSCTL("kstat.zfs.misc.vdev_cache_stats.misses",
+		ls->misses.vdev_cache_stats);
+}
+
+void
+fetchzarc(void)
+{
+	oldstat = curstat;
+	getinfo(&curstat);
+}


Property changes on: trunk/usr.bin/systat/zarc.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property


More information about the Midnightbsd-cvs mailing list