Change the default behavior of the netstat run during check_network to trunk
authorperry <perry@NetBSD.org>
Sun, 07 Dec 2003 22:22:15 +0000
branchtrunk
changeset 121613 916c3db85a45
parent 121612 bb351113b8bb
child 121614 48a6a90799bc
Change the default behavior of the netstat run during check_network to print a summary rather than the full (and not usually desired) output of netstat -inv. The old behavior can be returned by simply setting full_netstat to YES in daily.conf. Original idea by me, cleaner and more correct execution via small awk script from Greg Woods.
etc/daily
--- a/etc/daily	Sun Dec 07 22:17:54 2003 +0000
+++ b/etc/daily	Sun Dec 07 22:22:15 2003 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh -
 #
-#	$NetBSD: daily,v 1.53 2003/12/07 16:55:04 perry Exp $
+#	$NetBSD: daily,v 1.54 2003/12/07 22:22:15 perry Exp $
 #	@(#)daily	8.2 (Berkeley) 1/25/94
 #
 
@@ -201,7 +201,25 @@
 if checkyesno check_network; then
 	echo ""
 	echo "network:"
-	netstat -inv
+	if checkyesno full_netstat; then
+		netstat -inv
+	else
+		netstat -in | awk 'BEGIN {
+			ifs[""] = 0;
+		}
+		/^[^\*]* / {
+			if (NR == 1) {
+				printf("%-8s %10s %6s %10s %6s %6s\n",
+				  $1, $(NF-4), $(NF-3), $(NF-2), $(NF-1), $NF);
+				next;
+			}
+			if (!($1 in ifs)) {
+				printf("%-8s %10d %6d %10d %6d %6d\n",
+				  $1, $(NF-4), $(NF-3), $(NF-2), $(NF-1), $NF);
+				ifs[$1] = 1;
+			}
+		}'
+	fi
 	echo ""
 	t=/var/rwho/*
 	if [ "$t" != '/var/rwho/*' ]; then