At Fri, 3 Dec 2010 12:57:59 -0800 (PST) CentOS mailing list <centos@xxxxxxxxxx> wrote: > > > > I have the need to know how many connection the server has, i run this command but i don't know how to sum all the results and get a final number. > any ideas? > > netstat -an | grep -E 'tcp|udp' | awk '{print $6}' | sort | uniq -c | sort -n > > Â Â 1 CLOSE_WAIT > Â Â 1 FIN_WAIT_2 > Â Â 1 LAST_ACK > Â Â 1 TIME_WAIT > Â Â 4 SYN_SENT > Â 15 > Â 37 LISTEN > Â 44 ESTABLISHED <the above script> | awk '{print $1;}' | tr '\n' '+'|sed 's/\+$//g'|bc The awk prints just the number, the tr replaces the newlines with +'s, the sed strips off the trailing + (from the last newline), and bc does the math. > > > > ---------------------------------- > > Alejandro Rodriguez Luna > > Web: http://www.alexluna.org > > E-mail: el_alexluna@xxxxxxxxxxxx > > MSN: el_alexluna@xxxxxxxxxxxx > > GTalk: alexluna@xxxxxxxxx > > Movil: 044-311-112-86-41 > > ---------------------------------- > > > > MIME-Version: 1.0 > > _______________________________________________ > CentOS mailing list > CentOS@xxxxxxxxxx > http://lists.centos.org/mailman/listinfo/centos > > -- Robert Heller -- 978-544-6933 / heller@xxxxxxxxxxxx Deepwoods Software -- http://www.deepsoft.com/ () ascii ribbon campaign -- against html e-mail /\ www.asciiribbon.org -- against proprietary attachments
_______________________________________________ CentOS mailing list CentOS@xxxxxxxxxx http://lists.centos.org/mailman/listinfo/centos