diff options
author | Mohit Mehta <mohit.mehta@vyatta.com> | 2008-04-03 21:59:25 +0000 |
---|---|---|
committer | Mohit Mehta <mohit.mehta@vyatta.com> | 2008-04-03 21:59:25 +0000 |
commit | 5612efdef70dca2c8f02578cc1b119be4b794d08 (patch) | |
tree | bb4893de453981d6b7dcf22ec966379c54199a5f | |
parent | d14dee306fe9a8f497e20d9fa58bd199615569c3 (diff) | |
download | vyatta-op-5612efdef70dca2c8f02578cc1b119be4b794d08.tar.gz vyatta-op-5612efdef70dca2c8f02578cc1b119be4b794d08.zip |
Fix Bug 1059 Feature Request: integrate 'tcpdump' and 'tethereal' into Vyatta CLI
- 'show interfaces ethernet <> capture' captures traffic at specified interface
- 'show interfaces ethernet <> capture port <>' captures traffic at specified interface port
- 'show interfaces ethernet <> capture not port <>' captures traffic at specified interface excluding specified port
9 files changed, 75 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am index a09f4d4..35d6691 100644 --- a/Makefile.am +++ b/Makefile.am @@ -16,6 +16,7 @@ bin_SCRIPTS += scripts/vyatta-show-interfaces.pl bin_SCRIPTS += scripts/vyatta-show-version bin_SCRIPTS += scripts/vyatta-show-dhclient.pl bin_SCRIPTS += scripts/vyatta-show-dmi +bin_SCRIPTS += scripts/vyatta-tshark-interface-port.pl bin_sudo_users_SCRIPTS = scripts/vyatta-identify-interface.pl bin_sudo_users_SCRIPTS += scripts/vyatta-delete-log-file.sh diff --git a/etc/bash_completion.d/10vyatta-op b/etc/bash_completion.d/10vyatta-op index 8ccb7ee..fe3163c 100644 --- a/etc/bash_completion.d/10vyatta-op +++ b/etc/bash_completion.d/10vyatta-op @@ -321,7 +321,7 @@ _vyatta_op_run () local ret=0 if [ -n "$run_cmd" ]; then if [[ -t 1 && "$1" == "show" && \ - ! $run_cmd =~ ^\(LESSOPEN=\|less\|pager\|tail\).* ]] ; then + ! $run_cmd =~ ^\(LESSOPEN=\|less\|pager\|tail\|/opt/vyatta/bin/vyatta-tshark-interface-port.pl\).* ]] ; then eval "($run_cmd) | ${VYATTA_PAGER:-cat}" else eval "$run_cmd" diff --git a/scripts/vyatta-tshark-interface-port.pl b/scripts/vyatta-tshark-interface-port.pl new file mode 100644 index 0000000..4eff322 --- /dev/null +++ b/scripts/vyatta-tshark-interface-port.pl @@ -0,0 +1,62 @@ +#!/usr/bin/perl +# +# Module: vyatta-tshark-interface-port.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) 2006, 2007, 2008 Vyatta, Inc. +# All Rights Reserved. +# +# Author: Mohit Mehta +# Date: April 2008 +# Description: tshark on a given port for a given interface from vyatta cli +# +# **** End License **** +# + +use lib "/opt/vyatta/share/perl5/"; + +use strict; +use warnings; + +# +# main +# + +my $intf = $ARGV[0]; + +if ($#ARGV > 0){ + my $port = $ARGV[1]; + my $not_port = $ARGV[2]; + if ($port =~ /[a-zA-Z]/){ + print "Port number has to be numeric. Allowed values: <1-65535>\n"; + exit 1; + } else { + if (($port > 0) and ($port < 65536)){ + if ($not_port == 0){ + exec "sudo /usr/bin/tshark -n -i $intf port $port"; + } else { + exec "sudo /usr/bin/tshark -n -i $intf not port $port"; + } + } else { + print "Invalid port number. Allowed values: <1-65535>\n"; + exit 1; + } + + } +} else { + exec "sudo /usr/bin/tshark -n -i $intf"; +} + +exit 0; + +#end of file diff --git a/templates/show/interfaces/ethernet/node.tag/capture/node.def b/templates/show/interfaces/ethernet/node.tag/capture/node.def new file mode 100644 index 0000000..318f6cf --- /dev/null +++ b/templates/show/interfaces/ethernet/node.tag/capture/node.def @@ -0,0 +1,2 @@ +help: Show captured traffic on specified ethernet interface +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" diff --git a/templates/show/interfaces/ethernet/node.tag/capture/not/node.def b/templates/show/interfaces/ethernet/node.tag/capture/not/node.def new file mode 100644 index 0000000..ca8a2ed --- /dev/null +++ b/templates/show/interfaces/ethernet/node.tag/capture/not/node.def @@ -0,0 +1 @@ +help: Show captured traffic excluding the specified ethernet interface port diff --git a/templates/show/interfaces/ethernet/node.tag/capture/not/port/node.def b/templates/show/interfaces/ethernet/node.tag/capture/not/port/node.def new file mode 100644 index 0000000..ca8a2ed --- /dev/null +++ b/templates/show/interfaces/ethernet/node.tag/capture/not/port/node.def @@ -0,0 +1 @@ +help: Show captured traffic excluding the specified ethernet interface port diff --git a/templates/show/interfaces/ethernet/node.tag/capture/not/port/node.tag/node.def b/templates/show/interfaces/ethernet/node.tag/capture/not/port/node.tag/node.def new file mode 100644 index 0000000..a350ac5 --- /dev/null +++ b/templates/show/interfaces/ethernet/node.tag/capture/not/port/node.tag/node.def @@ -0,0 +1,3 @@ +help: Show captured traffic excluding the specified ethernet interface port +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "$8" 1 +allowed: echo -n '<1-65535>' diff --git a/templates/show/interfaces/ethernet/node.tag/capture/port/node.def b/templates/show/interfaces/ethernet/node.tag/capture/port/node.def new file mode 100644 index 0000000..7f6d889 --- /dev/null +++ b/templates/show/interfaces/ethernet/node.tag/capture/port/node.def @@ -0,0 +1 @@ +help: Show captured traffic on specified ethernet interface port diff --git a/templates/show/interfaces/ethernet/node.tag/capture/port/node.tag/node.def b/templates/show/interfaces/ethernet/node.tag/capture/port/node.tag/node.def new file mode 100644 index 0000000..f1aedc4 --- /dev/null +++ b/templates/show/interfaces/ethernet/node.tag/capture/port/node.tag/node.def @@ -0,0 +1,3 @@ +help: Show captured traffic on specified ethernet interface port +run: /opt/vyatta/bin/vyatta-tshark-interface-port.pl "$4" "$7" 0 +allowed: echo -n '<1-65535>' |