svn commit: r309130 - in stable/11: bin/hostname etc usr.sbin/gstat

Marcelo Araujo araujo at FreeBSD.org
Fri Nov 25 05:54:19 UTC 2016


Author: araujo
Date: Fri Nov 25 05:54:17 2016
New Revision: 309130
URL: https://svnweb.freebsd.org/changeset/base/309130

Log:
  MFC r308443, r308459, r308462, r308478, r308786
  
  r308443:
  Add -d flag that prints domain only.
  
  PR:		212875
  Submitted by:	Ben RUBSON <ben.rubson at gmail.com>
  Reviewed by:	pi
  
  r308459:
  Fix missing '-' for the flags -s and -d on both manpage and usage.
  
  Reported by:	garga, bde
  
  r308462:
  Add flag -B which does the same like batch mode but without exiting after
  print. Also add a new flag -s that add blocks size to statistics.
  
  PR:		198347, 212726
  Submitted by:	Ben RUBSON <ben.rubson at gmail.com>
  Tested by:	pi
  MFC After:	2 weeks.
  
  r308478:
  We can't use protect(1) inside a jail(8)!
  To avoid have warning for services that are using oomprotect, oomprotect
  will only be applied on services that won't run inside jails.
  
  Reported by:	allanjude
  MFC after:	2 weeks.
  
  r308786:
  rc.subr: Swap checks so we only fork sysctl if *_oomprotect is set.

Modified:
  stable/11/bin/hostname/hostname.1
  stable/11/bin/hostname/hostname.c
  stable/11/etc/rc.subr
  stable/11/usr.sbin/gstat/gstat.8
  stable/11/usr.sbin/gstat/gstat.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/bin/hostname/hostname.1
==============================================================================
--- stable/11/bin/hostname/hostname.1	Fri Nov 25 05:46:15 2016	(r309129)
+++ stable/11/bin/hostname/hostname.1	Fri Nov 25 05:54:17 2016	(r309130)
@@ -29,7 +29,7 @@
 .\"	@(#)hostname.1	8.2 (Berkeley) 4/28/95
 .\" $FreeBSD$
 .\"
-.Dd December 7, 2006
+.Dd November 10, 2016
 .Dt HOSTNAME 1
 .Os
 .Sh NAME
@@ -37,7 +37,8 @@
 .Nd set or print name of current host system
 .Sh SYNOPSIS
 .Nm
-.Op Fl fs
+.Op Fl f
+.Op Fl s | d
 .Op Ar name-of-host
 .Sh DESCRIPTION
 The
@@ -62,6 +63,8 @@ This is the default behavior.
 .It Fl s
 Trim off any domain information from the printed
 name.
+.It Fl d
+Only print domain information.
 .El
 .Sh SEE ALSO
 .Xr gethostname 3 ,

Modified: stable/11/bin/hostname/hostname.c
==============================================================================
--- stable/11/bin/hostname/hostname.c	Fri Nov 25 05:46:15 2016	(r309129)
+++ stable/11/bin/hostname/hostname.c	Fri Nov 25 05:54:17 2016	(r309130)
@@ -54,11 +54,12 @@ static void usage(void) __dead2;
 int
 main(int argc, char *argv[])
 {
-	int ch, sflag;
+	int ch, sflag, dflag;
 	char *p, hostname[MAXHOSTNAMELEN];
 
 	sflag = 0;
-	while ((ch = getopt(argc, argv, "fs")) != -1)
+	dflag = 0;
+	while ((ch = getopt(argc, argv, "fsd")) != -1)
 		switch (ch) {
 		case 'f':
 			/*
@@ -70,6 +71,9 @@ main(int argc, char *argv[])
 		case 's':
 			sflag = 1;
 			break;
+		case 'd':
+			dflag = 1;
+			break;
 		case '?':
 		default:
 			usage();
@@ -77,7 +81,7 @@ main(int argc, char *argv[])
 	argc -= optind;
 	argv += optind;
 
-	if (argc > 1)
+	if (argc > 1 || (sflag && dflag))
 		usage();
 
 	if (*argv) {
@@ -90,6 +94,10 @@ main(int argc, char *argv[])
 			p = strchr(hostname, '.');
 			if (p != NULL)
 				*p = '\0';
+		} else if (dflag) {
+			p = strchr(hostname, '.');
+			if (p != NULL)
+				strcpy(hostname, ++p);
 		}
 		(void)printf("%s\n", hostname);
 	}
@@ -100,6 +108,6 @@ static void
 usage(void)
 {
 
-	(void)fprintf(stderr, "usage: hostname [-fs] [name-of-host]\n");
+	(void)fprintf(stderr, "usage: hostname [-f] [-s | -d] [name-of-host]\n");
 	exit(1);
 }

Modified: stable/11/etc/rc.subr
==============================================================================
--- stable/11/etc/rc.subr	Fri Nov 25 05:46:15 2016	(r309129)
+++ stable/11/etc/rc.subr	Fri Nov 25 05:54:17 2016	(r309130)
@@ -1205,18 +1205,18 @@ $command $rc_flags $command_args"
 		# Apply protect(1) to the PID if ${name}_oomprotect is set.
 		case "$rc_arg" in
 		start)
-			if [ -n "$_oomprotect" ]; then
-				if [ -f "${PROTECT}" ]; then
-					pid=$(check_process $command)
-					case $_oomprotect in
-					[Aa][Ll][Ll])
-						${PROTECT} -i -p ${pid}
-						;;
-					[Yy][Ee][Ss])
-						${PROTECT} -p ${pid}
-						;;
-					esac
-				fi
+			# We cannot use protect(1) inside jails.
+			if [ -n "$_oomprotect" ] && [ -f "${PROTECT}" ] &&
+			    [ "$(sysctl -n security.jail.jailed)" -eq 0 ]; then
+				pid=$(check_process $command)
+				case $_oomprotect in
+				[Aa][Ll][Ll])
+					${PROTECT} -i -p ${pid}
+					;;
+				[Yy][Ee][Ss])
+					${PROTECT} -p ${pid}
+					;;
+				esac
 			fi	
 		;;
 		esac

Modified: stable/11/usr.sbin/gstat/gstat.8
==============================================================================
--- stable/11/usr.sbin/gstat/gstat.8	Fri Nov 25 05:46:15 2016	(r309129)
+++ stable/11/usr.sbin/gstat/gstat.8	Fri Nov 25 05:54:17 2016	(r309130)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 3, 2014
+.Dd November 10, 2016
 .Dt GSTAT 8
 .Os
 .Sh NAME
@@ -32,7 +32,7 @@
 .Nd print statistics about GEOM disks
 .Sh SYNOPSIS
 .Nm
-.Op Fl abcdop
+.Op Fl abBcdops
 .Op Fl f Ar filter
 .Op Fl I Ar interval
 .Sh DESCRIPTION
@@ -50,6 +50,10 @@ Only display providers that are at least
 Batch mode.
 Collect numbers, print and exit.
 Default if stdout is not a tty.
+.It Fl B
+Endless batch mode.
+Same as batch mode, but does not exit after collecting
+the first set of data.
 .It Fl c
 Enable display of
 .Xr geom 4
@@ -72,6 +76,8 @@ The format of the regular expression is 
 .It Fl o
 Enable display of statistics for other operations
 .Pq Dv BIO_FLUSH .
+.It Fl s
+Enable blocks' size statistics.
 .It Fl I Ar interval
 Refresh the
 .Nm

Modified: stable/11/usr.sbin/gstat/gstat.c
==============================================================================
--- stable/11/usr.sbin/gstat/gstat.c	Fri Nov 25 05:46:15 2016	(r309129)
+++ stable/11/usr.sbin/gstat/gstat.c	Fri Nov 25 05:54:17 2016	(r309130)
@@ -51,11 +51,11 @@
 #include <sysexits.h>
 #include <unistd.h>
 
-static int flag_a, flag_b, flag_c, flag_d, flag_o, flag_p;
+static int flag_a, flag_b, flag_B, flag_c, flag_d, flag_o, flag_p, flag_s;
 static int flag_I = 1000000;
 
 #define PRINTMSG(...) do {						\
-		if (flag_b && !loop)					\
+		if ((flag_b && !loop) || (flag_B))			\
 			printf(__VA_ARGS__);				\
 		else if (!flag_b)					\
 			printw(__VA_ARGS__);				\
@@ -88,7 +88,7 @@ main(int argc, char **argv)
 	char *p;
 	char f_s[100], pf_s[100], tmp_f_s[100];
 	const char *line;
-	long double ld[13];
+	long double ld[16];
 	uint64_t u64;
 	EditLine *el;
 	History *hist;
@@ -104,7 +104,7 @@ main(int argc, char **argv)
 		flag_b = 1;
 
 	f_s[0] = '\0';
-	while ((i = getopt(argc, argv, "abdcf:I:op")) != -1) {
+	while ((i = getopt(argc, argv, "abBdcf:I:ops")) != -1) {
 		switch (i) {
 		case 'a':
 			flag_a = 1;
@@ -112,6 +112,10 @@ main(int argc, char **argv)
 		case 'b':
 			flag_b = 1;
 			break;
+		case 'B':
+			flag_B = 1;
+			flag_b = 1;
+			break;
 		case 'c':
 			flag_c = 1;
 			break;
@@ -146,6 +150,9 @@ main(int argc, char **argv)
 		case 'p':
 			flag_p = 1;
 			break;
+		case 's':
+			flag_s = 1;
+			break;
 		case '?':
 		default:
 			usage();
@@ -208,7 +215,8 @@ main(int argc, char **argv)
 	
 		geom_stats_snapshot_reset(sp);
 		geom_stats_snapshot_reset(sq);
-		move(0,0);
+		if (!flag_b)
+			move(0,0);
 		PRINTMSG("dT: %5.3fs  w: %.3fs", dt, (float)flag_I / 1000000);
 		if (f_s[0] != '\0') {
 			PRINTMSG("  filter: ");
@@ -231,10 +239,20 @@ main(int argc, char **argv)
 		}
 		PRINTMSG("\n");
 		PRINTMSG(" L(q)  ops/s   ");
-		PRINTMSG(" r/s   kBps   ms/r   ");
-		PRINTMSG(" w/s   kBps   ms/w   ");
-		if (flag_d)
-			PRINTMSG(" d/s   kBps   ms/d   ");
+		if (flag_s) {
+			PRINTMSG(" r/s     kB   kBps   ms/r   ");
+			PRINTMSG(" w/s     kB   kBps   ms/w   ");
+		}
+		else {
+			PRINTMSG(" r/s   kBps   ms/r   ");
+			PRINTMSG(" w/s   kBps   ms/w   ");
+		}
+		if (flag_d) {
+			if (flag_s)
+				PRINTMSG(" d/s     kB   kBps   ms/d   ");
+			else
+				PRINTMSG(" d/s   kBps   ms/d   ");
+		}
 		if (flag_o)
 			PRINTMSG(" o/s   ms/o   ");
 		PRINTMSG("%%busy Name\n");
@@ -298,6 +316,10 @@ main(int argc, char **argv)
 			    DSM_TRANSFERS_PER_SECOND_OTHER, &ld[11],
 			    DSM_MS_PER_TRANSACTION_OTHER, &ld[12],
 
+			    DSM_KB_PER_TRANSFER_READ, &ld[13],
+			    DSM_KB_PER_TRANSFER_WRITE, &ld[14],
+			    DSM_KB_PER_TRANSFER_FREE, &ld[15],
+
 			    DSM_NONE);
 
 			if (flag_a && ld[7] < 0.1) {
@@ -308,12 +330,16 @@ main(int argc, char **argv)
 			PRINTMSG(" %4ju", (uintmax_t)u64);
 			PRINTMSG(" %6.0f", (double)ld[0]);
 			PRINTMSG(" %6.0f", (double)ld[1]);
+			if (flag_s)
+				PRINTMSG(" %6.0f", (double)ld[13]);
 			PRINTMSG(" %6.0f", (double)ld[2] * 1024);
 			if (ld[3] > 1e3) 
 				PRINTMSG(" %6.0f", (double)ld[3]);
 			else
 				PRINTMSG(" %6.1f", (double)ld[3]);
 			PRINTMSG(" %6.0f", (double)ld[4]);
+			if (flag_s)
+				PRINTMSG(" %6.0f", (double)ld[14]);
 			PRINTMSG(" %6.0f", (double)ld[5] * 1024);
 			if (ld[6] > 1e3) 
 				PRINTMSG(" %6.0f", (double)ld[6]);
@@ -322,6 +348,8 @@ main(int argc, char **argv)
 
 			if (flag_d) {
 				PRINTMSG(" %6.0f", (double)ld[8]);
+				if (flag_s)
+					PRINTMSG(" %6.0f", (double)ld[15]);
 				PRINTMSG(" %6.0f", (double)ld[9] * 1024);
 				if (ld[10] > 1e3) 
 					PRINTMSG(" %6.0f", (double)ld[10]);
@@ -373,7 +401,10 @@ main(int argc, char **argv)
 			/* We loop extra to make sure we get the information. */
 			if (!loop)
 				break;
-			loop = 0;
+			if (!flag_B)
+				loop = 0;
+			else
+				fflush(stdout);
 			usleep(flag_I);
 			continue;
 		}
@@ -452,7 +483,7 @@ main(int argc, char **argv)
 static void
 usage(void)
 {
-	fprintf(stderr, "usage: gstat [-abcdp] [-f filter] [-I interval]\n");
+	fprintf(stderr, "usage: gstat [-abBcdps] [-f filter] [-I interval]\n");
 	exit(EX_USAGE);
         /* NOTREACHED */
 }


More information about the svn-src-all mailing list