Author: glen                         Date: Fri Oct 23 13:44:08 2009 GMT
Module: packages                      Tag: HEAD
---- Log message:
- script to export tcp statistics summary

---- Files affected:
packages/cacti-template-snmp_tcp_connection_status:
   tcpstat (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: packages/cacti-template-snmp_tcp_connection_status/tcpstat
diff -u /dev/null packages/cacti-template-snmp_tcp_connection_status/tcpstat:1.1
--- /dev/null   Fri Oct 23 15:44:08 2009
+++ packages/cacti-template-snmp_tcp_connection_status/tcpstat  Fri Oct 23 
15:44:02 2009
@@ -0,0 +1,42 @@
+#!/bin/sh
+# NT: print netstat statistics
+# Author: [email protected]
+# $Id$
+
+# closing:0 time_wait:0 time_close:0 listen:13 syn_sent:0 syn_recv:0 
established:4 fin_wait1:0 fin_wait2:0 closewait:0 lastack:0
+# closing:1 syn_sent:0 established:1887 closewait:0 time_close:0 fin_wait1:28 
lastack:4 fin_wait2:725 time_wait:25025 syn_recv:22 listen:14
+
+LC_ALL=C ss -ant | PERL_BADLANG=0 perl -ane '
+BEGIN {
+       my %m = (
+               established => "ESTAB",
+               syn_sent => "SYN-SENT",
+               syn_recv => "SYN-RECV",
+               fin_wait1 => "FIN-WAIT-1",
+               fin_wait2 => "FIN-WAIT-2",
+               time_wait => "TIME-WAIT",
+               time_close => "UNCONN",
+               closewait => "CLOSE-WAIT",
+               lastack => "LAST-ACK",
+               listen =>  "LISTEN",
+               closing => "CLOSING",
+       );
+
+       # reset values to 0
+       %a = map { $_ => 0 } values %m;
+
+       # create reverse map for pretty print
+       %r = map { $m{$_} => $_ } keys %m;
+}
+
+++$a{$F[0]} if $F[0] =~ /^[A-Z0-9-]+$/;
+
+END {
+       my $t = $p = 0;
+       while (my($k, $v) = each %a) {
+               $k = $r{$k};
+               $t += $v;
+               $p = $p > length($v) ? $p : length($v);
+               printf("%s:%d ", $k, $v);
+       }
+}'
================================================================
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to