svn commit: r291090 - head/usr.bin/vmstat

Oliver Pinter oliver.pinter at hardenedbsd.org
Fri Nov 20 11:01:39 UTC 2015


On 11/20/15, Craig Rodrigues <rodrigc at freebsd.org> wrote:
> Author: rodrigc
> Date: Fri Nov 20 05:15:34 2015
> New Revision: 291090
> URL: https://svnweb.freebsd.org/changeset/base/291090
>
> Log:
>   Convert vmstat to use libxo.
>
>   This patch was based on this patch:
>   https://github.com/Juniper/libxo/blob/master/patches/vmstat.patch
>
>   by Phil Shafer at Juniper Networks, but updated to the latest
>   vmstat code.
>
>   Reviewed by:           allanjude
>   Differential Revision: https://reviews.freebsd.org/D3935
>
> Modified:
>   head/usr.bin/vmstat/Makefile
>   head/usr.bin/vmstat/vmstat.8
>   head/usr.bin/vmstat/vmstat.c
>
> Modified: head/usr.bin/vmstat/Makefile
> ==============================================================================
> --- head/usr.bin/vmstat/Makefile	Fri Nov 20 03:24:04 2015	(r291089)
> +++ head/usr.bin/vmstat/Makefile	Fri Nov 20 05:15:34 2015	(r291090)
> @@ -3,7 +3,7 @@
>
>  PROG=	vmstat
>  MAN=	vmstat.8
> -LIBADD=	devstat kvm memstat util
> +LIBADD=	devstat kvm memstat xo util
>
>  WARNS?=	1
>
>
> Modified: head/usr.bin/vmstat/vmstat.8
> ==============================================================================
> --- head/usr.bin/vmstat/vmstat.8	Fri Nov 20 03:24:04 2015	(r291089)
> +++ head/usr.bin/vmstat/vmstat.8	Fri Nov 20 05:15:34 2015	(r291090)
> @@ -28,7 +28,7 @@
>  .\"	@(#)vmstat.8	8.1 (Berkeley) 6/6/93
>  .\" $FreeBSD$
>  .\"
> -.Dd August 8, 2014
> +.Dd November 19, 2015
>  .Dt VMSTAT 8
>  .Os
>  .Sh NAME
> @@ -37,6 +37,7 @@
>  .Sh SYNOPSIS
>  .Nm
>  .\" .Op Fl fimst
> +.Op Fl -libxo
>  .Op Fl afHhimoPsz
>  .Op Fl M Ar core Op Fl N Ar system
>  .Op Fl c Ar count
> @@ -68,6 +69,13 @@ the default image).
>  .Pp
>  The options are as follows:
>  .Bl -tag -width indent
> +.It Fl -libxo
> +Generate output via
> +.Xr libxo 3
> +in a selection of different human and machine readable formats.
> +See
> +.Xr xo_parse_args 3
> +for details on command line arguments.
>  .It Fl a
>  When used with
>  .Fl i ,
> @@ -361,6 +369,8 @@ statistics every second.
>  .Xr ps 1 ,
>  .Xr systat 1 ,
>  .Xr libmemstat 3 ,
> +.Xr libxo 3 ,
> +.Xr xo_parse_args 3 ,
>  .Xr gstat 8 ,
>  .Xr iostat 8 ,
>  .Xr pstat 8 ,
>
> Modified: head/usr.bin/vmstat/vmstat.c
> ==============================================================================
> --- head/usr.bin/vmstat/vmstat.c	Fri Nov 20 03:24:04 2015	(r291089)
> +++ head/usr.bin/vmstat/vmstat.c	Fri Nov 20 05:15:34 2015	(r291090)
> @@ -76,6 +76,9 @@ __FBSDID("$FreeBSD$");
>  #include <time.h>
>  #include <unistd.h>
>  #include <libutil.h>
> +#include <libxo/xo.h>
> +
> +#define VMSTAT_XO_VERSION "1"
>
>  static char da[] = "da";
>
> @@ -184,6 +187,11 @@ main(int argc, char *argv[])
>  	interval = reps = todo = 0;
>  	maxshowdevs = 2;
>  	hflag = isatty(1);
> +
> +	argc = xo_parse_args(argc, argv);
> +	if (argc < 0)
> +		return argc;
> +
>  	while ((c = getopt(argc, argv, "ac:fhHiM:mN:n:oPp:stw:z")) != -1) {
>  		switch (c) {
>  		case 'a':
> @@ -220,7 +228,7 @@ main(int argc, char *argv[])
>  			nflag = 1;
>  			maxshowdevs = atoi(optarg);
>  			if (maxshowdevs < 0)
> -				errx(1, "number of devices %d is < 0",
> +				xo_errx(1, "number of devices %d is < 0",
>  				     maxshowdevs);
>  			break;
>  		case 'o':
> @@ -228,7 +236,7 @@ main(int argc, char *argv[])
>  			break;
>  		case 'p':
>  			if (devstat_buildmatch(optarg, &matches, &num_matches) != 0)
> -				errx(1, "%s", devstat_errbuf);
> +				xo_errx(1, "%s", devstat_errbuf);
>  			break;
>  		case 's':
>  			todo |= SUMSTAT;
> @@ -237,7 +245,7 @@ main(int argc, char *argv[])
>  #ifdef notyet
>  			todo |= TIMESTAT;
>  #else
> -			errx(EX_USAGE, "sorry, -t is not (re)implemented yet");
> +			xo_errx(EX_USAGE, "sorry, -t is not (re)implemented yet");
>  #endif
>  			break;
>  		case 'w':
> @@ -256,18 +264,21 @@ main(int argc, char *argv[])
>  	argc -= optind;
>  	argv += optind;
>
> +	xo_set_version(VMSTAT_XO_VERSION);
>  	if (todo == 0)
>  		todo = VMSTAT;
>
>  	if (memf != NULL) {
>  		kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf);
>  		if (kd == NULL)
> -			errx(1, "kvm_openfiles: %s", errbuf);
> +			xo_errx(1, "kvm_openfiles: %s", errbuf);
>  	}
>
>  retry_nlist:
>  	if (kd != NULL && (c = kvm_nlist(kd, namelist)) != 0) {
>  		if (c > 0) {
> +			int bufsize = 0, len = 0;
> +			char *buf, *bp;
>  			/*
>  			 * 'cnt' was renamed to 'vm_cnt'. If 'vm_cnt' is not
>  			 * found try looking up older 'cnt' symbol.
> @@ -277,20 +288,34 @@ retry_nlist:
>  				namelist[X_SUM].n_name = "_cnt";
>  				goto retry_nlist;
>  			}
> -			warnx("undefined symbols:");
>  			for (c = 0;
>  			     c < (int)(sizeof(namelist)/sizeof(namelist[0]));
>  			     c++)
>  				if (namelist[c].n_type == 0)
> -					(void)fprintf(stderr, " %s",
> +					bufsize += strlen(namelist[c].n_name) + 1;
> +			bufsize += len + 1;
> +			buf = bp = alloca(bufsize);
> +
> +			for (c = 0;
> +			     c < (int)(sizeof(namelist)/sizeof(namelist[0]));
> +			     c++)
> +				if (namelist[c].n_type == 0) {
> +					xo_error(" %s",
>  					    namelist[c].n_name);
> -			(void)fputc('\n', stderr);
> +					len = strlen(namelist[c].n_name);
> +					*bp++ = ' ';
> +					memcpy(bp, namelist[c].n_name, len);
> +					bp += len;
> +				}
> +			*bp = '\0';
> +			xo_error("undefined symbols:\n", buf);
>  		} else
> -			warnx("kvm_nlist: %s", kvm_geterr(kd));
> +			xo_warnx("kvm_nlist: %s", kvm_geterr(kd));
> +		xo_finish();
>  		exit(1);
>  	}
>  	if (kd && Pflag)
> -		errx(1, "Cannot use -P with crash dumps");
> +		xo_errx(1, "Cannot use -P with crash dumps");
>
>  	if (todo & VMSTAT) {
>  		/*
> @@ -299,7 +324,7 @@ retry_nlist:
>  		 * message informing the user of his mistake.
>  		 */
>  		if (devstat_checkversion(NULL) < 0)
> -			errx(1, "%s", devstat_errbuf);
> +			xo_errx(1, "%s", devstat_errbuf);
>
>
>  		argv = getdrivedata(argv);
> @@ -336,6 +361,7 @@ retry_nlist:
>  		dointr(interval, reps);
>  	if (todo & VMSTAT)
>  		dovmstat(interval, reps);
> +	xo_finish();
>  	exit(0);
>  }
>
> @@ -347,7 +373,7 @@ mysysctl(const char *name, void *oldp, s
>
>  	error = sysctlbyname(name, oldp, oldlenp, newp, newlen);
>  	if (error != 0 && errno != ENOMEM)
> -		err(1, "sysctl(%s)", name);
> +		xo_err(1, "sysctl(%s)", name);
>  	return (error);
>  }
>
> @@ -355,13 +381,13 @@ static char **
>  getdrivedata(char **argv)
>  {
>  	if ((num_devices = devstat_getnumdevs(NULL)) < 0)
> -		errx(1, "%s", devstat_errbuf);
> +		xo_errx(1, "%s", devstat_errbuf);
>
>  	cur.dinfo = (struct devinfo *)calloc(1, sizeof(struct devinfo));
>  	last.dinfo = (struct devinfo *)calloc(1, sizeof(struct devinfo));
>
>  	if (devstat_getdevs(NULL, &cur) == -1)
> -		errx(1, "%s", devstat_errbuf);
> +		xo_errx(1, "%s", devstat_errbuf);
>
>  	num_devices = cur.dinfo->numdevs;
>  	generation = cur.dinfo->generation;
> @@ -393,7 +419,7 @@ getdrivedata(char **argv)
>  	 */
>  	if ((num_devices_specified == 0) && (num_matches == 0)) {
>  		if (devstat_buildmatch(da, &matches, &num_matches) != 0)
> -			errx(1, "%s", devstat_errbuf);
> +			xo_errx(1, "%s", devstat_errbuf);
>
>  		select_mode = DS_SELECT_ADD;
>  	} else
> @@ -409,7 +435,7 @@ getdrivedata(char **argv)
>  		       num_devices, matches, num_matches, specified_devices,
>  		       num_devices_specified, select_mode,
>  		       maxshowdevs, 0) == -1)
> -		errx(1, "%s", devstat_errbuf);
> +		xo_errx(1, "%s", devstat_errbuf);
>
>  	return(argv);
>  }
> @@ -439,16 +465,16 @@ fill_pcpu(struct pcpu ***pcpup, int* max
>
>  	maxcpu = kvm_getmaxcpu(kd);
>  	if (maxcpu < 0)
> -		errx(1, "kvm_getmaxcpu: %s", kvm_geterr(kd));
> +		xo_errx(1, "kvm_getmaxcpu: %s", kvm_geterr(kd));
>
>  	pcpu = calloc(maxcpu, sizeof(struct pcpu *));
>  	if (pcpu == NULL)
> -		err(1, "calloc");
> +		xo_err(1, "calloc");
>
>  	for (i = 0; i < maxcpu; i++) {
>  		pcpu[i] = kvm_getpcpu(kd, i);
>  		if (pcpu[i] == (struct pcpu *)-1)
> -			errx(1, "kvm_getpcpu: %s", kvm_geterr(kd));
> +			xo_errx(1, "kvm_getpcpu: %s", kvm_geterr(kd));
>  	}
>
>  	*maxcpup = maxcpu;
> @@ -576,12 +602,12 @@ fill_vmtotal(struct vmtotal *vmtp)
>  {
>  	if (kd != NULL) {
>  		/* XXX fill vmtp */
> -		errx(1, "not implemented");
> +		xo_errx(1, "not implemented");
>  	} else {
>  		size_t size = sizeof(*vmtp);
>  		mysysctl("vm.vmtotal", vmtp, &size, NULL, 0);
>  		if (size != sizeof(*vmtp))
> -			errx(1, "vm.total size mismatch");
> +			xo_errx(1, "vm.total size mismatch");
>  	}
>  }
>
> @@ -599,17 +625,17 @@ getcpuinfo(u_long *maskp, int *maxidp)
>  	u_long mask;
>
>  	if (kd != NULL)
> -		errx(1, "not implemented");
> +		xo_errx(1, "not implemented");
>  	mask = 0;
>  	ncpus = 0;
>  	size = sizeof(maxcpu);
>  	mysysctl("kern.smp.maxcpus", &maxcpu, &size, NULL, 0);
>  	if (size != sizeof(maxcpu))
> -		errx(1, "sysctl kern.smp.maxcpus");
> +		xo_errx(1, "sysctl kern.smp.maxcpus");
>  	size = sizeof(long) * maxcpu * CPUSTATES;
>  	times = malloc(size);
>  	if (times == NULL)
> -		err(1, "malloc %zd bytes", size);
> +		xo_err(1, "malloc %zd bytes", size);
>  	mysysctl("kern.cp_times", times, &size, NULL, 0);
>  	maxid = (size / CPUSTATES / sizeof(long)) - 1;
>  	for (i = 0; i <= maxid; i++) {
> @@ -632,16 +658,20 @@ getcpuinfo(u_long *maskp, int *maxidp)
>
>
>  static void
> -prthuman(u_int64_t val, int size)
> +prthuman(const char *name, u_int64_t val, int size)
>  {
>  	char buf[10];
>  	int flags;
> +	char fmt[128];
> +
> +	snprintf(fmt, sizeof(fmt), "{:%s/%%*s}", name);
>
>  	if (size < 5 || size > 9)
> -		errx(1, "doofus");
> +		xo_errx(1, "doofus");
>  	flags = HN_B | HN_NOSPACE | HN_DECIMAL;
>  	humanize_number(buf, size, val, "", HN_AUTOSCALE, flags);
> -	printf("%*s", size, buf);
> +	xo_attr("value", "%ju", (uintmax_t) val);
> +	xo_emit(fmt, size, buf);
>  }
>
>  static int hz, hdrcnt;
> @@ -699,7 +729,7 @@ dovmstat(unsigned int interval, int reps
>  		size = sizeof(clockrate);
>  		mysysctl("kern.clockrate", &clockrate, &size, NULL, 0);
>  		if (size != sizeof(clockrate))
> -			errx(1, "clockrate size mismatch");
> +			xo_errx(1, "clockrate size mismatch");
>  		hz = clockrate.hz;
>  	}
>
> @@ -714,18 +744,18 @@ dovmstat(unsigned int interval, int reps
>  			printhdr(maxid, cpumask);
>  		if (kd != NULL) {
>  			if (kvm_getcptime(kd, cur.cp_time) < 0)
> -				errx(1, "kvm_getcptime: %s", kvm_geterr(kd));
> +				xo_errx(1, "kvm_getcptime: %s", kvm_geterr(kd));
>  		} else {
>  			size = sizeof(cur.cp_time);
>  			mysysctl("kern.cp_time", &cur.cp_time, &size, NULL, 0);
>  			if (size != sizeof(cur.cp_time))
> -				errx(1, "cp_time size mismatch");
> +				xo_errx(1, "cp_time size mismatch");
>  		}
>  		if (Pflag) {
>  			size = size_cp_times;
>  			mysysctl("kern.cp_times", cur_cp_times, &size, NULL, 0);
>  			if (size != size_cp_times)
> -				errx(1, "cp_times mismatch");
> +				xo_errx(1, "cp_times mismatch");
>  		}
>
>  		tmp_dinfo = last.dinfo;
> @@ -742,7 +772,7 @@ dovmstat(unsigned int interval, int reps
>  		 */
>  		switch (devstat_getdevs(NULL, &cur)) {
>  		case -1:
> -			errx(1, "%s", devstat_errbuf);
> +			xo_errx(1, "%s", devstat_errbuf);
>  			break;
>  		case 1: {
>  			int retval;
> @@ -759,7 +789,7 @@ dovmstat(unsigned int interval, int reps
>  					    maxshowdevs, 0);
>  			switch (retval) {
>  			case -1:
> -				errx(1, "%s", devstat_errbuf);
> +				xo_errx(1, "%s", devstat_errbuf);
>  				break;
>  			case 1:
>  				printhdr(maxid, cpumask);
> @@ -774,49 +804,64 @@ dovmstat(unsigned int interval, int reps
>
>  		fill_vmmeter(&sum);
>  		fill_vmtotal(&total);
> -		(void)printf("%1d %1d %1d",
> +		xo_open_container("processes");
> +		xo_emit("{:runnable/%1d} {:waiting/%ld} "
> +		        "{:swapped-out/%ld}",

Are these %1d -> %ld conversions here intended or a typo?

>  		    total.t_rq - 1, total.t_dw + total.t_pw, total.t_sw);
> +		xo_close_container("processes");
> +		xo_open_container("memory");
>  #define vmstat_pgtok(a) ((a) * (sum.v_page_size >> 10))
>  #define	rate(x)	(((x) * rate_adj + halfuptime) / uptime)	/* round */
>  		if (hflag) {
> -			printf("");
> -			prthuman(total.t_avm * (u_int64_t)sum.v_page_size, 5);
> -			printf(" ");
> -			prthuman(total.t_free * (u_int64_t)sum.v_page_size, 5);
> -			printf(" ");
> -			(void)printf("%5lu ",
> -			    (unsigned long)rate(sum.v_vm_faults -
> -			    osum.v_vm_faults));
> +			xo_emit("");
> +			prthuman("available-memory",
> +			         total.t_avm * (u_int64_t)sum.v_page_size, 5);
> +			xo_emit(" ");
> +			prthuman("free-memory",
> +			         total.t_free * (u_int64_t)sum.v_page_size, 5);
> +			xo_emit(" ");
>  		} else {
> -			printf(" %7d", vmstat_pgtok(total.t_avm));
> -			printf(" %7d ", vmstat_pgtok(total.t_free));
> -			(void)printf("%4lu ",
> -			    (unsigned long)rate(sum.v_vm_faults -
> -			    osum.v_vm_faults));
> -		}
> -		(void)printf("%3lu ",
> +			xo_emit(" ");
> +			xo_emit("{:available-memory/%7d}",
> +			        vmstat_pgtok(total.t_avm));
> +			xo_emit(" ");
> +			xo_emit("{:free-memory/%7d}",
> +			        vmstat_pgtok(total.t_free));
> +		}
> +		xo_emit("{:total-page-faults/%5lu} ",
> +		        (unsigned long)rate(sum.v_vm_faults -
> +		        osum.v_vm_faults));
> +		xo_close_container("memory");
> +
> +		xo_open_container("paging-rates");
> +		xo_emit("{:page-reactivated/%3lu} ",
>  		    (unsigned long)rate(sum.v_reactivated - osum.v_reactivated));
> -		(void)printf("%3lu ",
> +		xo_emit("{:paged-in/%3lu} ",
>  		    (unsigned long)rate(sum.v_swapin + sum.v_vnodein -
>  		    (osum.v_swapin + osum.v_vnodein)));
> -		(void)printf("%3lu ",
> +		xo_emit("{:paged-out/%3lu} ",
>  		    (unsigned long)rate(sum.v_swapout + sum.v_vnodeout -
>  		    (osum.v_swapout + osum.v_vnodeout)));
> -		(void)printf("%5lu ",
> +		xo_emit("{:freed/%5lu} ",
>  		    (unsigned long)rate(sum.v_tfree - osum.v_tfree));
> -		(void)printf("%4lu ",
> +		xo_emit("{:scanned/%4lu} ",
>  		    (unsigned long)rate(sum.v_pdpages - osum.v_pdpages));
> +		xo_close_container("paging-rates");
> +
>  		devstats();
> -		(void)printf("%4lu %5lu %5lu",
> +		xo_open_container("fault-rates");
> +		xo_emit("{:interrupts/%4lu} {:system-calls/%5lu} "
> +		        "{:context-switches/%5u}",
>  		    (unsigned long)rate(sum.v_intr - osum.v_intr),
>  		    (unsigned long)rate(sum.v_syscall - osum.v_syscall),
>  		    (unsigned long)rate(sum.v_swtch - osum.v_swtch));
> +		xo_close_container("fault-rates");
>  		if (Pflag)
>  			pcpustats(ncpus, cpumask, maxid);
>  		else
>  			cpustats();
> -		(void)printf("\n");
> -		(void)fflush(stdout);
> +		xo_emit("\n");
> +		xo_flush();
>  		if (reps >= 0 && --reps <= 0)
>  			break;
>  		osum = sum;
> @@ -841,43 +886,43 @@ printhdr(int maxid, u_long cpumask)
>
>  	num_shown = (num_selected < maxshowdevs) ? num_selected : maxshowdevs;
>  	if (hflag) {
> -		(void)printf("procs  memory      page%*s ", 19, "");
> +		xo_emit("{T:procs}  {T:memory}       ${T:/page%*s}", 19, "");
>  	} else {
> -		(void)printf("procs     memory       page%*s ", 19, "");
> +		xo_emit("{T:procs}     {T:memory}        ${T:/page%*s}", 19, "");
>  	}
>  	if (num_shown > 1)
> -		(void)printf("   disks %*s", num_shown * 4 - 7, "");
> +		xo_emit(" {T:/disks %*s}", num_shown * 4 - 7, "");
>  	else if (num_shown == 1)
> -		(void)printf("   disk");
> -	(void)printf("   faults      ");
> +		xo_emit("   {T:disks}");
> +	xo_emit("   {T:faults}      ");
>  	if (Pflag) {
>  		for (i = 0; i <= maxid; i++) {
>  			if (cpumask & (1ul << i))
> -				printf("  cpu%d   ", i);
> +				xo_emit("  {T:/cpu%d}   ", i);
>  		}
> -		printf("\n");
> +		xo_emit("\n");
>  	} else
> -		printf("   cpu\n");
> +		xo_emit("   {T:cpu}\n");
>  	if (hflag) {
> -		(void)printf("r b w  avm   fre   flt  re  pi  po    fr   sr ");
> +		xo_emit("{T:r} {T:b} {T:w}  {T:avm}   {T:fre}   {T:flt}  {T:re}  {T:pi}
> {T:po}    {T:fr}   {T:sr} ");
>  	} else {
> -		(void)printf("r b w     avm     fre  flt  re  pi  po    fr   sr ");
> +		xo_emit("{T:r} {T:b} {T:w}     {T:avm}     {T:fre}  {T:flt}  {T:re}
> {T:pi}  {T:po}    {T:fr}   {T:sr} ");
>  	}
>  	for (i = 0; i < num_devices; i++)
>  		if ((dev_select[i].selected)
>  		 && (dev_select[i].selected <= maxshowdevs))
> -			(void)printf("%c%c%d ", dev_select[i].device_name[0],
> +			xo_emit("{T:/%c%c%d} ", dev_select[i].device_name[0],
>  				     dev_select[i].device_name[1],
>  				     dev_select[i].unit_number);
> -	(void)printf("  in    sy    cs");
> +	xo_emit("  {T:in}    {T:sy}    {T:cs}");
>  	if (Pflag) {
>  		for (i = 0; i <= maxid; i++) {
>  			if (cpumask & (1ul << i))
> -				printf(" us sy id");
> +				xo_emit(" {T:us} {T:sy} {T:id}");
>  		}
> -		printf("\n");
> +		xo_emit("\n");
>  	} else
> -		printf(" us sy id\n");
> +		xo_emit(" {T:us} {T:sy} {T:id}\n");
>  	if (wresized != 0)
>  		doresize();
>  	hdrcnt = winlines;
> @@ -920,7 +965,7 @@ doresize(void)
>  		if (status == -1 && errno == EINTR)
>  			continue;
>  		else if (status == -1)
> -			err(1, "ioctl");
> +			xo_err(1, "ioctl");
>  		if (w.ws_row > 3)
>  			winlines = w.ws_row - 3;
>  		else
> @@ -943,13 +988,16 @@ dotimes(void)
>  	kread(X_REC, &rectime, sizeof(rectime));
>  	kread(X_PGIN, &pgintime, sizeof(pgintime));
>  	kread(X_SUM, &sum, sizeof(sum));
> -	(void)printf("%u reclaims, %u total time (usec)\n",
> +	xo_emit("{:page-reclaims/%u} {N:reclaims}, "
> +		"{:reclaim-time/%u} {N:total time (usec)}\n",
>  	    sum.v_pgrec, rectime);
> -	(void)printf("average: %u usec / reclaim\n", rectime / sum.v_pgrec);
> -	(void)printf("\n");
> -	(void)printf("%u page ins, %u total time (msec)\n",
> +	xo_emit("{L:average}: {:reclaim-average/%u} {N:usec \\/ reclaim}\n",
> +		rectime / sum.v_pgrec);
> +	xo_emit("\n");
> +	xo_emit("{:page-ins/%u} {N:page ins}, "
> +		"{:page-in-time/%u} {N:total time (msec)}\n",
>  	    sum.v_pgin, pgintime / 10);
> -	(void)printf("average: %8.1f msec / page in\n",
> +	xo_emit("{L:average}: {:average/%8.1f} {N:msec \\/ page in}\n",
>  	    pgintime / (sum.v_pgin * 10.0));
>  }
>  #endif
> @@ -974,87 +1022,136 @@ dosum(void)
>  	long nchtotal;
>
>  	fill_vmmeter(&sum);
> -	(void)printf("%9u cpu context switches\n", sum.v_swtch);
> -	(void)printf("%9u device interrupts\n", sum.v_intr);
> -	(void)printf("%9u software interrupts\n", sum.v_soft);
> -	(void)printf("%9u traps\n", sum.v_trap);
> -	(void)printf("%9u system calls\n", sum.v_syscall);
> -	(void)printf("%9u kernel threads created\n", sum.v_kthreads);
> -	(void)printf("%9u  fork() calls\n", sum.v_forks);
> -	(void)printf("%9u vfork() calls\n", sum.v_vforks);
> -	(void)printf("%9u rfork() calls\n", sum.v_rforks);
> -	(void)printf("%9u swap pager pageins\n", sum.v_swapin);
> -	(void)printf("%9u swap pager pages paged in\n", sum.v_swappgsin);
> -	(void)printf("%9u swap pager pageouts\n", sum.v_swapout);
> -	(void)printf("%9u swap pager pages paged out\n", sum.v_swappgsout);
> -	(void)printf("%9u vnode pager pageins\n", sum.v_vnodein);
> -	(void)printf("%9u vnode pager pages paged in\n", sum.v_vnodepgsin);
> -	(void)printf("%9u vnode pager pageouts\n", sum.v_vnodeout);
> -	(void)printf("%9u vnode pager pages paged out\n", sum.v_vnodepgsout);
> -	(void)printf("%9u page daemon wakeups\n", sum.v_pdwakeups);
> -	(void)printf("%9u pages examined by the page daemon\n", sum.v_pdpages);
> -	(void)printf("%9u pages reactivated\n", sum.v_reactivated);
> -	(void)printf("%9u copy-on-write faults\n", sum.v_cow_faults);
> -	(void)printf("%9u copy-on-write optimized faults\n", sum.v_cow_optim);
> -	(void)printf("%9u zero fill pages zeroed\n", sum.v_zfod);
> -	(void)printf("%9u zero fill pages prezeroed\n", sum.v_ozfod);
> -	(void)printf("%9u intransit blocking page faults\n", sum.v_intrans);
> -	(void)printf("%9u total VM faults taken\n", sum.v_vm_faults);
> -	(void)printf("%9u page faults requiring I/O\n", sum.v_io_faults);
> -	(void)printf("%9u pages affected by kernel thread creation\n",
> -	    sum.v_kthreadpages);
> -	(void)printf("%9u pages affected by  fork()\n", sum.v_forkpages);
> -	(void)printf("%9u pages affected by vfork()\n", sum.v_vforkpages);
> -	(void)printf("%9u pages affected by rfork()\n", sum.v_rforkpages);
> -	(void)printf("%9u pages cached\n", sum.v_tcached);
> -	(void)printf("%9u pages freed\n", sum.v_tfree);
> -	(void)printf("%9u pages freed by daemon\n", sum.v_dfree);
> -	(void)printf("%9u pages freed by exiting processes\n", sum.v_pfree);
> -	(void)printf("%9u pages active\n", sum.v_active_count);
> -	(void)printf("%9u pages inactive\n", sum.v_inactive_count);
> -	(void)printf("%9u pages in VM cache\n", sum.v_cache_count);
> -	(void)printf("%9u pages wired down\n", sum.v_wire_count);
> -	(void)printf("%9u pages free\n", sum.v_free_count);
> -	(void)printf("%9u bytes per page\n", sum.v_page_size);
> +	xo_open_container("summary-statistics");
> +	xo_emit("{:context-switches/%9u} {N:cpu context switches}\n",
> +		sum.v_swtch);
> +	xo_emit("{:interrupts/%9u} {N:device interrupts}\n",
> +		sum.v_intr);
> +	xo_emit("{:software-interrupts/%9u} {N:software interrupts}\n",
> +		sum.v_soft);
> +	xo_emit("{:traps/%9u} {N:traps}\n", sum.v_trap);
> +	xo_emit("{:system-calls/%9u} {N:system calls}\n",
> +		sum.v_syscall);
> +	xo_emit("{:kernel-threads/%9u} {N:kernel threads created}\n",
> +		sum.v_kthreads);
> +	xo_emit("{:forks/%9u} {N: fork() calls}\n", sum.v_forks);
> +	xo_emit("{:vforks/%9u} {N:vfork() calls}\n",
> +		sum.v_vforks);
> +	xo_emit("{:rforks/%9u} {N:rfork() calls}\n",
> +		sum.v_rforks);
> +	xo_emit("{:swap-ins/%9u} {N:swap pager pageins}\n",
> +		sum.v_swapin);
> +	xo_emit("{:swap-in-pages/%9u} {N:swap pager pages paged in}\n",
> +		sum.v_swappgsin);
> +	xo_emit("{:swap-outs/%9u} {N:swap pager pageouts}\n",
> +		sum.v_swapout);
> +	xo_emit("{:swap-out-pages/%9u} {N:swap pager pages paged out}\n",
> +		sum.v_swappgsout);
> +	xo_emit("{:vnode-page-ins/%9u} {N:vnode pager pageins}\n",
> +		sum.v_vnodein);
> +	xo_emit("{:vnode-page-in-pages/%9u} {N:vnode pager pages paged in}\n",
> +		sum.v_vnodepgsin);
> +	xo_emit("{:vnode-page-outs/%9u} {N:vnode pager pageouts}\n",
> +		sum.v_vnodeout);
> +	xo_emit("{:vnode-page-outs/%9u} {N:vnode pager pages paged out}\n",
> +		sum.v_vnodepgsout);
> +	xo_emit("{:page-daemon-wakeups/%9u} {N:page daemon wakeups}\n",
> +		sum.v_pdwakeups);
> +	xo_emit("{:page-daemon-pages/%9u} {N:pages examined by the page
> daemon}\n",
> +		sum.v_pdpages);
> +	xo_emit("{:reactivated/%9u} {N:pages reactivated}\n",
> +		sum.v_reactivated);
> +	xo_emit("{:copy-on-write-faults/%9u} {N:copy-on-write faults}\n",
> +		sum.v_cow_faults);
> +	xo_emit("{:copy-on-write-optimized-faults/%9u} {N:copy-on-write optimized
> faults}\n",
> +		sum.v_cow_optim);
> +	xo_emit("{:zero-fill-pages/%9u} {N:zero fill pages zeroed}\n",
> +		sum.v_zfod);
> +	xo_emit("{:zero-fill-prezeroed/%9u} {N:zero fill pages prezeroed}\n",
> +		sum.v_ozfod);
> +	xo_emit("{:intransit-blocking/%9u} {N:intransit blocking page faults}\n",
> +		sum.v_intrans);
> +	xo_emit("{:total-faults/%9u} {N:total VM faults taken}\n",
> +		sum.v_vm_faults);
> +	xo_emit("{:faults-requiring-io/%9u} {N:page faults requiring I\\/O}\n",
> +		sum.v_io_faults);
> +	xo_emit("{:faults-from-thread-creation/%9u} {N:pages affected by kernel
> thread creation}\n",
> +		sum.v_kthreadpages);
> +	xo_emit("{:faults-from-fork/%9u} {N:pages affected by  fork}()\n",
> +		sum.v_forkpages);
> +	xo_emit("{:faults-from-vfork/%9u} {N:pages affected by vfork}()\n",
> +		sum.v_vforkpages);
> +	xo_emit("{:pages-rfork/%9u} {N:pages affected by rfork}()\n",
> +		sum.v_rforkpages);
> +	xo_emit("{:pages-total-cached/%9u} {N:pages cached}\n",
> +		sum.v_tcached);
> +	xo_emit("{:pages-freed/%9u} {N:pages freed}\n",
> +		sum.v_tfree);
> +	xo_emit("{:pages-freed-by-daemon/%9u} {N:pages freed by daemon}\n",
> +		sum.v_dfree);
> +	xo_emit("{:pages-freed-on-exit/%9u} {N:pages freed by exiting
> processes}\n",
> +		sum.v_pfree);
> +	xo_emit("{:active-pages/%9u} {N:pages active}\n",
> +		sum.v_active_count);
> +	xo_emit("{:inactive-pages/%9u} {N:pages inactive}\n",
> +		sum.v_inactive_count);
> +	xo_emit("{:vm-cache/%9u} {N:pages in VM cache}\n",
> +		sum.v_cache_count);
> +	xo_emit("{:wired-pages/%9u} {N:pages wired down}\n",
> +		sum.v_wire_count);
> +	xo_emit("{:free-pages/%9u} {N:pages free}\n",
> +		sum.v_free_count);
> +	xo_emit("{:bytes-per-page/%9u} {N:bytes per page}\n", sum.v_page_size);
>  	if (kd != NULL) {
>  		kread(X_NCHSTATS, &lnchstats, sizeof(lnchstats));
>  	} else {
>  		size_t size = sizeof(lnchstats);
>  		mysysctl("vfs.cache.nchstats", &lnchstats, &size, NULL, 0);
>  		if (size != sizeof(lnchstats))
> -			errx(1, "vfs.cache.nchstats size mismatch");
> +			xo_errx(1, "vfs.cache.nchstats size mismatch");
>  	}
>  	nchtotal = lnchstats.ncs_goodhits + lnchstats.ncs_neghits +
>  	    lnchstats.ncs_badhits + lnchstats.ncs_falsehits +
>  	    lnchstats.ncs_miss + lnchstats.ncs_long;
> -	(void)printf("%9ld total name lookups\n", nchtotal);
> -	(void)printf(
> -	    "%9s cache hits (%ld%% pos + %ld%% neg) system %ld%%
> per-directory\n",
> +	xo_emit(":total-name-lookups/%9ld} {N:total name lookups}\n",
> +	        nchtotal);
> +	xo_emit("{P:/%9s} {N:cache hits} "
> +	        "({:positive-cache-hits/%ld}% pos + "
> +	        "{:negative-cache-hits/%ld}% {N:neg}) "
> +	        "system {:cache-hit-percent/%ld}% per-directory\n",
>  	    "", PCT(lnchstats.ncs_goodhits, nchtotal),
>  	    PCT(lnchstats.ncs_neghits, nchtotal),
>  	    PCT(lnchstats.ncs_pass2, nchtotal));
> -	(void)printf("%9s deletions %ld%%, falsehits %ld%%, toolong %ld%%\n", "",
> +	xo_emit("{P:/%9s} {L:deletions} {:deletions/%ld}%, "
> +	        "{L:falsehits} {:false-hits/%ld}%, "
> +	        "{L:toolong} {:too-long/%ld}%\n", "",
>  	    PCT(lnchstats.ncs_badhits, nchtotal),
>  	    PCT(lnchstats.ncs_falsehits, nchtotal),
>  	    PCT(lnchstats.ncs_long, nchtotal));
> +	xo_close_container("summary-statistics");
>  }
>
>  static void
>  doforkst(void)
>  {
>  	fill_vmmeter(&sum);
> -	(void)printf("%u forks, %u pages, average %.2f\n",
> +	xo_open_container("fork-statistics");
> +	xo_emit("{:fork/%u} {N:forks}, {:fork-pages/%u} {N:pages}, "
> +		"{L:average} {:fork-average/%.2f}\n",
>  	    sum.v_forks, sum.v_forkpages,
>  	    sum.v_forks == 0 ? 0.0 :
>  	    (double)sum.v_forkpages / sum.v_forks);
> -	(void)printf("%u vforks, %u pages, average %.2f\n",
> +	xo_emit("{:vfork/%u} {N:vforks}, {:vfork-pages/%u} {N:pages}, "
> +		"{L:average} {:vfork-average/%.2f}\n",
>  	    sum.v_vforks, sum.v_vforkpages,
>  	    sum.v_vforks == 0 ? 0.0 :
>  	    (double)sum.v_vforkpages / sum.v_vforks);
> -	(void)printf("%u rforks, %u pages, average %.2f\n",
> +	xo_emit("{:rfork/%u} {N:rforks}, {:rfork-pages/%u} {N:pages}, "
> +		"{L:average} {:rfork-average/%.2f}\n",
>  	    sum.v_rforks, sum.v_rforkpages,
>  	    sum.v_rforks == 0 ? 0.0 :
>  	    (double)sum.v_rforkpages / sum.v_rforks);
> +	xo_close_container("fork-statistics");
>  }
>
>  static void
> @@ -1073,6 +1170,7 @@ devstats(void)
>
>  	busy_seconds = cur.snap_time - last.snap_time;
>
> +	xo_open_list("device");
>  	for (dn = 0; dn < num_devices; dn++) {
>  		int di;
>
> @@ -1086,24 +1184,33 @@ devstats(void)
>  		    &last.dinfo->devices[di], busy_seconds,
>  		    DSM_TRANSFERS_PER_SECOND, &transfers_per_second,
>  		    DSM_NONE) != 0)
> -			errx(1, "%s", devstat_errbuf);
> +			xo_errx(1, "%s", devstat_errbuf);
>
> -		(void)printf("%3.0Lf ", transfers_per_second);
> +		xo_open_instance("device");
> +		xo_emit("{ekq:name/%c%c%d}{:transfers/%3.0Lf} ",
> +			dev_select[dn].device_name[0],
> +			dev_select[dn].device_name[1],
> +			dev_select[dn].unit_number,
> +			transfers_per_second);
> +		xo_close_instance("device");
>  	}
> +	xo_close_list("device");
>  }
>
>  static void
> -percent(double pct, int *over)
> +percent(const char *name, double pct, int *over)
>  {
>  	char buf[10];
> +	char fmt[128];
>  	int l;
>
> +	snprintf(fmt, sizeof(fmt), " {:%s/%%*s}", name);
>  	l = snprintf(buf, sizeof(buf), "%.0f", pct);
>  	if (l == 1 && *over) {
> -		printf("%s",  buf);
> +		xo_emit(fmt, 1, buf);
>  		(*over)--;
>  	} else
> -		printf("%2s", buf);
> +		xo_emit(fmt, 2, buf);
>  	if (l > 2)
>  		(*over)++;
>  }
> @@ -1122,12 +1229,11 @@ cpustats(void)
>  	else
>  		lpct = 0.0;
>  	over = 0;
> -	printf(" ");
> -	percent((cur.cp_time[CP_USER] + cur.cp_time[CP_NICE]) * lpct, &over);
> -	printf(" ");
> -	percent((cur.cp_time[CP_SYS] + cur.cp_time[CP_INTR]) * lpct, &over);
> -	printf(" ");
> -	percent(cur.cp_time[CP_IDLE] * lpct, &over);
> +	xo_open_container("cpu-statistics");
> +	percent("user", (cur.cp_time[CP_USER] + cur.cp_time[CP_NICE]) * lpct,
> &over);
> +	percent("system", (cur.cp_time[CP_SYS] + cur.cp_time[CP_INTR]) * lpct,
> &over);
> +	percent("idle", cur.cp_time[CP_IDLE] * lpct, &over);
> +	xo_close_container("cpu-statistics");
>  }
>
>  static void
> @@ -1151,9 +1257,12 @@ pcpustats(int ncpus, u_long cpumask, int
>  	}
>
>  	over = 0;
> +	xo_open_list("cpu");
>  	for (i = 0; i <= maxid; i++) {
>  		if ((cpumask & (1ul << i)) == 0)
>  			continue;
> +		xo_open_instance("cpu");
> +		xo_emit("{ke:name/%d}", i);
>  		total = 0;
>  		for (state = 0; state < CPUSTATES; ++state)
>  			total += cur_cp_times[i * CPUSTATES + state];
> @@ -1161,15 +1270,15 @@ pcpustats(int ncpus, u_long cpumask, int
>  			lpct = 100.0 / total;
>  		else
>  			lpct = 0.0;
> -		printf(" ");
> -		percent((cur_cp_times[i * CPUSTATES + CP_USER] +
> +		percent("user", (cur_cp_times[i * CPUSTATES + CP_USER] +
>  			 cur_cp_times[i * CPUSTATES + CP_NICE]) * lpct, &over);
> -		printf(" ");
> -		percent((cur_cp_times[i * CPUSTATES + CP_SYS] +
> +		percent("system", (cur_cp_times[i * CPUSTATES + CP_SYS] +
>  			 cur_cp_times[i * CPUSTATES + CP_INTR]) * lpct, &over);
> -		printf(" ");
> -		percent(cur_cp_times[i * CPUSTATES + CP_IDLE] * lpct, &over);
> +		percent("idle", cur_cp_times[i * CPUSTATES + CP_IDLE] * lpct,
> +			&over);
> +		xo_close_instance("cpu");
>  	}
> +	xo_close_list("cpu");
>  }
>
>  static unsigned int
> @@ -1209,14 +1318,19 @@ print_intrcnts(unsigned long *intrcnts,
>  	inttotal = 0;
>  	old_inttotal = 0;
>  	intrname = intrnames;
> +	xo_emit("{T:/%-*s} {T:/%20s} {T:/%10s}\n",
> +	        (int)istrnamlen, "interrupt", "total", "rate");
> +	xo_open_list("interrupt");
>  	for (i = 0, intrcnt=intrcnts, old_intrcnt=old_intrcnts; i < nintr; i++) {
>  		if (intrname[0] != '\0' && (*intrcnt != 0 || aflag)) {
>  			unsigned long count, rate;
>
>  			count = *intrcnt - *old_intrcnt;
>  			rate = (count * 1000 + period_ms / 2) / period_ms;
> -			(void)printf("%-*s %20lu %10lu\n", (int)istrnamlen,
> -			    intrname, count, rate);
> +			xo_open_instance("interrupt");
> +			xo_emit("{k:name/%-*s} {:total/%20lu} {:rate/%10lu}\n",
> +			        (int)istrnamlen, intrname, count, rate);
> +			xo_close_instance("interrupt");
>  		}
>  		intrname += strlen(intrname) + 1;
>  		inttotal += *intrcnt++;
> @@ -1224,8 +1338,10 @@ print_intrcnts(unsigned long *intrcnts,
>  	}
>  	total_count = inttotal - old_inttotal;
>  	total_rate = (total_count * 1000 + period_ms / 2) / period_ms;
> -	(void)printf("%-*s %20" PRIu64 " %10" PRIu64 "\n", (int)istrnamlen,
> -	    "Total", total_count, total_rate);
> +	xo_close_list("interrupt");
> +	xo_emit("{L:/%-*s} {:total-interrupts/%20" PRIu64 "} "
> +	        "{:total-rate/%10" PRIu64 "}\n", (int)istrnamlen,
> +	        "Total", total_count, total_rate);
>  }
>
>  static void
> @@ -1243,12 +1359,12 @@ dointr(unsigned int interval, int reps)
>  	if (kd != NULL) {
>  		kread(X_SINTRNAMES, &inamlen, sizeof(inamlen));
>  		if ((intrnames = malloc(inamlen)) == NULL)
> -			err(1, "malloc()");
> +			xo_err(1, "malloc()");
>  		kread(X_INTRNAMES, intrnames, inamlen);
>  	} else {
>  		for (intrnames = NULL, inamlen = 1024; ; inamlen *= 2) {
>  			if ((intrnames = reallocf(intrnames, inamlen)) == NULL)
> -				err(1, "reallocf()");
> +				xo_err(1, "reallocf()");
>  			if (mysysctl("hw.intrnames",
>  			    intrnames, &inamlen, NULL, 0) == 0)
>  				break;
> @@ -1264,8 +1380,8 @@ dointr(unsigned int interval, int reps)
>  			istrnamlen = clen;
>  		intrname += strlen(intrname) + 1;
>  	}
> -	(void)printf("%-*s %20s %10s\n", (int)istrnamlen, "interrupt", "total",
> -	    "rate");
> +	xo_emit("%{T:/%-%s} {T:/%20s} {T:/%10s\n",
> +	        (int)istrnamlen, "interrupt", "total", "rate");
>
>  	/*
>  	 * Loop reps times printing differential interrupt counts.  If reps is
> @@ -1284,7 +1400,7 @@ dointr(unsigned int interval, int reps)
>  		if (old_intrcnts == NULL) {
>  			old_intrcnts = calloc(nintr, sizeof(unsigned long));
>  			if (old_intrcnts == NULL)
> -				err(1, "calloc()");
> +				xo_err(1, "calloc()");
>  		}
>
>  		print_intrcnts(intrcnts, old_intrcnts, intrnames, nintr,
> @@ -1310,12 +1426,12 @@ domemstat_malloc(void)
>
>  	mtlp = memstat_mtl_alloc();
>  	if (mtlp == NULL) {
> -		warn("memstat_mtl_alloc");
> +		xo_warn("memstat_mtl_alloc");
>  		return;
>  	}
>  	if (kd == NULL) {
>  		if (memstat_sysctl_malloc(mtlp, 0) < 0) {
> -			warnx("memstat_sysctl_malloc: %s",
> +			xo_warnx("memstat_sysctl_malloc: %s",
>  			    memstat_strerror(memstat_mtl_geterror(mtlp)));
>  			return;
>  		}
> @@ -1323,35 +1439,43 @@ domemstat_malloc(void)
>  		if (memstat_kvm_malloc(mtlp, kd) < 0) {
>  			error = memstat_mtl_geterror(mtlp);
>  			if (error == MEMSTAT_ERROR_KVM)
> -				warnx("memstat_kvm_malloc: %s",
> +				xo_warnx("memstat_kvm_malloc: %s",
>  				    kvm_geterr(kd));
>  			else
> -				warnx("memstat_kvm_malloc: %s",
> +				xo_warnx("memstat_kvm_malloc: %s",
>  				    memstat_strerror(error));
>  		}
>  	}
> -	printf("%13s %5s %6s %7s %8s  Size(s)\n", "Type", "InUse", "MemUse",
> -	    "HighUse", "Requests");
> +	xo_emit("{T:/%13s} {T:/%5s} {T:/%6s} {T:/%7s} {T:/%8s}  {T:Size(s)}\n",
> +		"Type", "InUse", "MemUse", "HighUse", "Requests");
> +	xo_open_list("memory");
>  	for (mtp = memstat_mtl_first(mtlp); mtp != NULL;
>  	    mtp = memstat_mtl_next(mtp)) {
>  		if (memstat_get_numallocs(mtp) == 0 &&
>  		    memstat_get_count(mtp) == 0)
>  			continue;
> -		printf("%13s %5" PRIu64 " %5" PRIu64 "K %7s %8" PRIu64 "  ",
> +		xo_open_instance("memory");
> +		xo_emit("{k:type/%13s} {:in-use/%5" PRIu64 "} "
> +			"{:memory-use/%5" PRIu64 "}{U:K} {:high-use/%7s} "
> +			"{:requests/%8" PRIu64 "}  ",
>  		    memstat_get_name(mtp), memstat_get_count(mtp),
>  		    (memstat_get_bytes(mtp) + 1023) / 1024, "-",
>  		    memstat_get_numallocs(mtp));
>  		first = 1;
> +		xo_open_list("size");
>  		for (i = 0; i < 32; i++) {
>  			if (memstat_get_sizemask(mtp) & (1 << i)) {
>  				if (!first)
> -					printf(",");
> -				printf("%d", 1 << (i + 4));
> +					xo_emit(",");
> +				xo_emit("{l:size/%d}", 1 << (i + 4));
>  				first = 0;
>  			}
>  		}
> -		printf("\n");
> +		xo_close_list("size");
> +		xo_close_instance("memory");
> +		xo_emit("\n");
>  	}
> +	xo_close_list("memory");
>  	memstat_mtl_free(mtlp);
>  }
>
> @@ -1365,12 +1489,12 @@ domemstat_zone(void)
>
>  	mtlp = memstat_mtl_alloc();
>  	if (mtlp == NULL) {
> -		warn("memstat_mtl_alloc");
> +		xo_warn("memstat_mtl_alloc");
>  		return;
>  	}
>  	if (kd == NULL) {
>  		if (memstat_sysctl_uma(mtlp, 0) < 0) {
> -			warnx("memstat_sysctl_uma: %s",
> +			xo_warnx("memstat_sysctl_uma: %s",
>  			    memstat_strerror(memstat_mtl_geterror(mtlp)));
>  			return;
>  		}
> @@ -1378,28 +1502,35 @@ domemstat_zone(void)
>  		if (memstat_kvm_uma(mtlp, kd) < 0) {
>  			error = memstat_mtl_geterror(mtlp);
>  			if (error == MEMSTAT_ERROR_KVM)
> -				warnx("memstat_kvm_uma: %s",
> +				xo_warnx("memstat_kvm_uma: %s",
>  				    kvm_geterr(kd));
>  			else
> -				warnx("memstat_kvm_uma: %s",
> +				xo_warnx("memstat_kvm_uma: %s",
>  				    memstat_strerror(error));
>  		}
>  	}
> -	printf("%-20s %6s %6s %8s %8s %8s %4s %4s\n\n", "ITEM", "SIZE",
> -	    "LIMIT", "USED", "FREE", "REQ", "FAIL", "SLEEP");
> +	xo_emit("{T:/%-20s} {T:/%6s} {T:/%6s} {T:/%8s} {T:/%8s} {T:/%8s} "
> +		"{T:/%4s} {T:/%4s}\n\n", "ITEM", "SIZE",
> +		"LIMIT", "USED", "FREE", "REQ", "FAIL", "SLEEP");
> +	xo_open_list("zone");
>  	for (mtp = memstat_mtl_first(mtlp); mtp != NULL;
>  	    mtp = memstat_mtl_next(mtp)) {
>  		strlcpy(name, memstat_get_name(mtp), MEMTYPE_MAXNAME);
>  		strcat(name, ":");
> -		printf("%-20s %6" PRIu64 ", %6" PRIu64 ",%8" PRIu64 ",%8" PRIu64
> -		    ",%8" PRIu64 ",%4" PRIu64 ",%4" PRIu64 "\n", name,
> -		    memstat_get_size(mtp), memstat_get_countlimit(mtp),
> -		    memstat_get_count(mtp), memstat_get_free(mtp),
>
> *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
> _______________________________________________
> svn-src-head at freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/svn-src-head
> To unsubscribe, send any mail to "svn-src-head-unsubscribe at freebsd.org"
>


More information about the svn-src-head mailing list