Author: manu Date: Tue Jan 23 13:03:47 2018 New Revision: 328279 URL: https://svnweb.freebsd.org/changeset/base/328279
Log: sockstat: Add -q option to suppress the header line MFC after: 1 week Sponsored by: Gandi.net Modified: head/usr.bin/sockstat/sockstat.1 head/usr.bin/sockstat/sockstat.c Modified: head/usr.bin/sockstat/sockstat.1 ============================================================================== --- head/usr.bin/sockstat/sockstat.1 Tue Jan 23 08:07:00 2018 (r328278) +++ head/usr.bin/sockstat/sockstat.1 Tue Jan 23 13:03:47 2018 (r328279) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 12, 2017 +.Dd January 23, 2018 .Dt SOCKSTAT 1 .Os .Sh NAME @@ -83,6 +83,8 @@ The argument is a comma-separated list of protocol names, as they are defined in .Xr protocols 5 . +.It Fl q +Quiet mode, do not print the header line. .It Fl S Display the protocol stack, if applicable. This is currently only implemented for TCP. Modified: head/usr.bin/sockstat/sockstat.c ============================================================================== --- head/usr.bin/sockstat/sockstat.c Tue Jan 23 08:07:00 2018 (r328278) +++ head/usr.bin/sockstat/sockstat.c Tue Jan 23 13:03:47 2018 (r328279) @@ -76,6 +76,7 @@ static int opt_c; /* Show connected sockets */ static int opt_j; /* Show specified jail */ static int opt_L; /* Don't show IPv4 or IPv6 loopback sockets */ static int opt_l; /* Show listening sockets */ +static int opt_q; /* Don't show header */ static int opt_S; /* Show protocol stack if applicable */ static int opt_s; /* Show protocol state if applicable */ static int opt_U; /* Show remote UDP encapsulation port number */ @@ -1155,19 +1156,21 @@ display(void) struct sock *s; int hash, n, pos; - printf("%-8s %-10s %-5s %-2s %-6s %-*s %-*s", - "USER", "COMMAND", "PID", "FD", "PROTO", - opt_w ? 45 : 21, "LOCAL ADDRESS", - opt_w ? 45 : 21, "FOREIGN ADDRESS"); - if (opt_U) - printf(" %-6s", "ENCAPS"); - if (opt_s) { - printf(" %-12s", "PATH STATE"); - printf(" %-12s", "CONN STATE"); + if (opt_q != 1) { + printf("%-8s %-10s %-5s %-2s %-6s %-*s %-*s", + "USER", "COMMAND", "PID", "FD", "PROTO", + opt_w ? 45 : 21, "LOCAL ADDRESS", + opt_w ? 45 : 21, "FOREIGN ADDRESS"); + if (opt_U) + printf(" %-6s", "ENCAPS"); + if (opt_s) { + printf(" %-12s", "PATH STATE"); + printf(" %-12s", "CONN STATE"); + } + if (opt_S) + printf(" %.*s", TCP_FUNCTION_NAME_LEN_MAX, "STACK"); + printf("\n"); } - if (opt_S) - printf(" %.*s", TCP_FUNCTION_NAME_LEN_MAX, "STACK"); - printf("\n"); setpassent(1); for (xf = xfiles, n = 0; n < nxfiles; ++n, ++xf) { if (xf->xf_data == NULL) @@ -1248,7 +1251,7 @@ main(int argc, char *argv[]) int o, i; opt_j = -1; - while ((o = getopt(argc, argv, "46cj:Llp:P:SsUuvw")) != -1) + while ((o = getopt(argc, argv, "46cj:Llp:P:qSsUuvw")) != -1) switch (o) { case '4': opt_4 = 1; @@ -1274,6 +1277,8 @@ main(int argc, char *argv[]) case 'P': protos_defined = parse_protos(optarg); break; + case 'q': + opt_q = 1; case 'S': opt_S = 1; break; _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"