summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorslioch <slioch@eng-140.vyatta.com>2008-12-01 14:15:12 -0800
committerslioch <slioch@eng-140.vyatta.com>2008-12-01 14:15:12 -0800
commitbbf232732b7335efe1a40a772f2301efcff6893c (patch)
tree41f664f4a34c6b29d967c54796244d4e5d8a56bf /scripts
parent0214d6af2bdaa782d8241b729a7cf5f9a0a60de5 (diff)
downloadvyatta-wanloadbalance-bbf232732b7335efe1a40a772f2301efcff6893c.tar.gz
vyatta-wanloadbalance-bbf232732b7335efe1a40a772f2301efcff6893c.zip
formatting part of 3191 fixed with this bug. moved from dumping proc/net/ip_conntrack output to easier to digest formatted output.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/vyatta-wlb-connection4
-rw-r--r--scripts/vyatta-wlb-connection.pl74
2 files changed, 74 insertions, 4 deletions
diff --git a/scripts/vyatta-wlb-connection b/scripts/vyatta-wlb-connection
deleted file mode 100644
index 40060ae..0000000
--- a/scripts/vyatta-wlb-connection
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-cat /proc/net/ip_conntrack | grep ' mark=[1-9]'
-
diff --git a/scripts/vyatta-wlb-connection.pl b/scripts/vyatta-wlb-connection.pl
new file mode 100644
index 0000000..308010e
--- /dev/null
+++ b/scripts/vyatta-wlb-connection.pl
@@ -0,0 +1,74 @@
+#!/usr/bin/perl
+#
+# Module: vyatta-show-wlb-connection.pl
+#
+# **** License ****
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# This code was originally developed by Vyatta, Inc.
+# Portions created by Vyatta are Copyright (C) 2007 Vyatta, Inc.
+# All Rights Reserved.
+#
+# Author: Michael Larson
+# Date: December 2008
+# Description: Script to display wlb connection information
+#
+# **** End License ****
+#
+
+use lib "/opt/vyatta/share/perl5/";
+
+
+if (!open($FILE, "<", "/proc/net/ip_conntrack")) {
+ return;
+}
+
+
+print "Type\tState\t\tSrc\t\t\tDst\t\t\tPackets\tBytes\n";
+
+@line = <$FILE>;
+foreach (@line) {
+ $_ =~ s/\[\S+\]\s//;
+
+
+ my $proto,$tmp,$state,$src,$dst,$sport,$dport,$pkts,$bytes;
+
+
+ if (/tcp/) {
+ ($proto,$tmp,$tmp,$state,$src,$dst,$sport,$dport,$pkts,$bytes) = split(' ',$_);
+ }
+ elsif (/udp/) {
+ $state = "";
+ ($proto,$tmp,$tmp,$src,$dst,$sport,$dport,$pkts,$bytes) = split(' ',$_);
+ }
+ ($tmp,$src) = split('=',$src);
+ ($tmp,$dst) = split('=',$dst);
+ ($tmp,$dport) = split('=',$dport);
+ ($tmp,$sport) = split('=',$sport);
+ ($tmp,$pkts) = split('=',$pkts);
+ ($tmp,$bytes) = split('=',$bytes);
+
+ my $snet = sprintf("%s:%s%-10s",$src,$sport);
+ $snet = substr($snet,0,18);
+
+ my $dnet = sprintf("%s:%s%-10s",$dst,$dport);
+ $dnet = substr($dnet,0,18);
+
+ $state = sprintf("%s%-12s",$state);
+ $state = substr($state,0,12);
+
+ #mark=[1-9]
+ if (/ mark=[1-9]/) {
+ print "$proto\t$state\t$snet\t$dnet\t$pkts\t$bytes\n";
+ }
+}
+
+#now dump out results
+