From b317212f7493be433345a1a98fd7f625fd1777dc Mon Sep 17 00:00:00 2001 From: lbonanomi Date: Sun, 10 Mar 2019 17:07:33 -0700 Subject: [PATCH 1/3] Pedantic refactoring to save forks. --- README.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2060672..6b7af65 100644 --- a/README.md +++ b/README.md @@ -2645,13 +2645,8 @@ ___ ###### Graph # of connections for each hosts ```bash -netstat -an | \ -grep ESTABLISHED | \ -awk '{print $5}' | \ -awk -F: '{print $1}' | \ -grep -v -e '^[[:space:]]*$' | \ -sort | uniq -c | \ -awk '{ printf("%s\t%s\t",$2,$1) ; for (i = 0; i < $1; i++) {printf("*")}; print "" }' +netstat -an | awk '/ESTABLISHED/ { split($5,ip,":"); if (ip[1] !~ /^$/) print ip[1] }' | \ +sort | uniq -c | awk '{ printf("%s\t%s\t",$2,$1) ; for (i = 0; i < $1; i++) {printf("*")}; print "" }' ``` ###### Monitor open connections for specific port including listen, count and sort it per IP From dd6e43c7f2f3801488cbfc88a5b3edbad7fb3308 Mon Sep 17 00:00:00 2001 From: lbonanomi Date: Sun, 10 Mar 2019 17:09:50 -0700 Subject: [PATCH 2/3] Pedantic refactoring to save a few forks --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6b7af65..e6c2de6 100644 --- a/README.md +++ b/README.md @@ -2645,7 +2645,7 @@ ___ ###### Graph # of connections for each hosts ```bash -netstat -an | awk '/ESTABLISHED/ { split($5,ip,":"); if (ip[1] !~ /^$/) print ip[1] }' | \ +netstat -an | awk '/ESTABLISHED/ { split($5,ip,":"); if (ip[1] !~ /^$/) print ip[1] }' | \ sort | uniq -c | awk '{ printf("%s\t%s\t",$2,$1) ; for (i = 0; i < $1; i++) {printf("*")}; print "" }' ``` From debd4e06a0afe0eb9c0127837a2fbd7b2b4e8527 Mon Sep 17 00:00:00 2001 From: "@trimstray" Date: Mon, 11 Mar 2019 15:09:22 +0100 Subject: [PATCH 3/3] minor fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e6c2de6..6b7af65 100644 --- a/README.md +++ b/README.md @@ -2645,7 +2645,7 @@ ___ ###### Graph # of connections for each hosts ```bash -netstat -an | awk '/ESTABLISHED/ { split($5,ip,":"); if (ip[1] !~ /^$/) print ip[1] }' | \ +netstat -an | awk '/ESTABLISHED/ { split($5,ip,":"); if (ip[1] !~ /^$/) print ip[1] }' | \ sort | uniq -c | awk '{ printf("%s\t%s\t",$2,$1) ; for (i = 0; i < $1; i++) {printf("*")}; print "" }' ```