diff options
author | John Southworth <john.southworth@vyatta.com> | 2011-09-15 19:11:35 -0500 |
---|---|---|
committer | John Southworth <john.southworth@vyatta.com> | 2011-10-27 17:11:29 -0500 |
commit | 6af87429ae97d7cd069268ad3597508e6954d5e8 (patch) | |
tree | 4f361f9e7cf446324adac096f5798d0b219690e8 | |
parent | b04673afd899d2032200799a9d9b0c72901ad262 (diff) | |
download | vyatta-op-6af87429ae97d7cd069268ad3597508e6954d5e8.tar.gz vyatta-op-6af87429ae97d7cd069268ad3597508e6954d5e8.zip |
Fix 'monitor interface traffic save'
(cherry picked from commit ecb4650bc1ff7f7039a8de0c21f72667be9b189d)
14 files changed, 22 insertions, 10 deletions
diff --git a/gen-monitor-interface-templates.sh b/gen-monitor-interface-templates.sh index 69fe979..be4ccd1 100644 --- a/gen-monitor-interface-templates.sh +++ b/gen-monitor-interface-templates.sh @@ -36,7 +36,7 @@ for type in "${types[@]}"; do # save echo 'help: Save monitored traffic to a file' > $type/node.tag/traffic/save/node.def - echo -e 'help: Save monitored traffic to a file\nrun: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --save "${@:7}"' > $type/node.tag/traffic/save/node.def + echo -e 'help: Save monitored traffic to a file\nrun: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --save "${@:7}"' > $type/node.tag/traffic/save/node.tag/node.def # detail echo -e "help: Monitor detailed traffic for the specified $type interface"> $type/node.tag/traffic/detail/node.def diff --git a/scripts/vyatta-tshark.pl b/scripts/vyatta-tshark.pl index 103808d..75b1a5b 100755 --- a/scripts/vyatta-tshark.pl +++ b/scripts/vyatta-tshark.pl @@ -57,15 +57,21 @@ sub check_if_interface_is_tsharkable { # # main # -my ($detail,$filter,$intf,$unlimited); +my ($detail,$filter,$intf,$unlimited,$save); -GetOptions("detail!" => \$detail, +GetOptions("detail!" => \$detail, "filter=s" => \$filter, + "save=s" => \$save, "intf=s" => \$intf, - "unlimited!" => \$unlimited); + "unlimited!" => \$unlimited); check_if_interface_is_tsharkable($intf); +if (defined($save)){ + exec "sudo /usr/bin/tshark -i $intf -w '$save' | grep -v root"; + exit 0; +} + if (defined($filter)) { if (defined($detail)) { if (defined($unlimited)){ diff --git a/templates/monitor/interfaces/bonding/node.tag/traffic/save/node.def b/templates/monitor/interfaces/bonding/node.tag/traffic/save/node.def index bd747b5..402f47c 100644 --- a/templates/monitor/interfaces/bonding/node.tag/traffic/save/node.def +++ b/templates/monitor/interfaces/bonding/node.tag/traffic/save/node.def @@ -1,2 +1 @@ help: Save monitored traffic to a file -run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --save "${@:7}" diff --git a/templates/monitor/interfaces/bonding/node.tag/traffic/save/node.tag/node.def b/templates/monitor/interfaces/bonding/node.tag/traffic/save/node.tag/node.def new file mode 100644 index 0000000..bd747b5 --- /dev/null +++ b/templates/monitor/interfaces/bonding/node.tag/traffic/save/node.tag/node.def @@ -0,0 +1,2 @@ +help: Save monitored traffic to a file +run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --save "${@:7}" diff --git a/templates/monitor/interfaces/bridge/node.tag/traffic/save/node.def b/templates/monitor/interfaces/bridge/node.tag/traffic/save/node.def index bd747b5..402f47c 100644 --- a/templates/monitor/interfaces/bridge/node.tag/traffic/save/node.def +++ b/templates/monitor/interfaces/bridge/node.tag/traffic/save/node.def @@ -1,2 +1 @@ help: Save monitored traffic to a file -run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --save "${@:7}" diff --git a/templates/monitor/interfaces/bridge/node.tag/traffic/save/node.tag/node.def b/templates/monitor/interfaces/bridge/node.tag/traffic/save/node.tag/node.def new file mode 100644 index 0000000..bd747b5 --- /dev/null +++ b/templates/monitor/interfaces/bridge/node.tag/traffic/save/node.tag/node.def @@ -0,0 +1,2 @@ +help: Save monitored traffic to a file +run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --save "${@:7}" diff --git a/templates/monitor/interfaces/ethernet/node.tag/traffic/save/node.def b/templates/monitor/interfaces/ethernet/node.tag/traffic/save/node.def index bd747b5..402f47c 100644 --- a/templates/monitor/interfaces/ethernet/node.tag/traffic/save/node.def +++ b/templates/monitor/interfaces/ethernet/node.tag/traffic/save/node.def @@ -1,2 +1 @@ help: Save monitored traffic to a file -run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --save "${@:7}" diff --git a/templates/monitor/interfaces/ethernet/node.tag/traffic/save/node.tag/node.def b/templates/monitor/interfaces/ethernet/node.tag/traffic/save/node.tag/node.def new file mode 100644 index 0000000..bd747b5 --- /dev/null +++ b/templates/monitor/interfaces/ethernet/node.tag/traffic/save/node.tag/node.def @@ -0,0 +1,2 @@ +help: Save monitored traffic to a file +run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --save "${@:7}" diff --git a/templates/monitor/interfaces/loopback/node.tag/traffic/save/node.def b/templates/monitor/interfaces/loopback/node.tag/traffic/save/node.def index bd747b5..402f47c 100644 --- a/templates/monitor/interfaces/loopback/node.tag/traffic/save/node.def +++ b/templates/monitor/interfaces/loopback/node.tag/traffic/save/node.def @@ -1,2 +1 @@ help: Save monitored traffic to a file -run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --save "${@:7}" diff --git a/templates/monitor/interfaces/loopback/node.tag/traffic/save/node.tag/node.def b/templates/monitor/interfaces/loopback/node.tag/traffic/save/node.tag/node.def new file mode 100644 index 0000000..bd747b5 --- /dev/null +++ b/templates/monitor/interfaces/loopback/node.tag/traffic/save/node.tag/node.def @@ -0,0 +1,2 @@ +help: Save monitored traffic to a file +run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --save "${@:7}" diff --git a/templates/monitor/interfaces/pseudo-ethernet/node.tag/traffic/save/node.def b/templates/monitor/interfaces/pseudo-ethernet/node.tag/traffic/save/node.def index bd747b5..402f47c 100644 --- a/templates/monitor/interfaces/pseudo-ethernet/node.tag/traffic/save/node.def +++ b/templates/monitor/interfaces/pseudo-ethernet/node.tag/traffic/save/node.def @@ -1,2 +1 @@ help: Save monitored traffic to a file -run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --save "${@:7}" diff --git a/templates/monitor/interfaces/pseudo-ethernet/node.tag/traffic/save/node.tag/node.def b/templates/monitor/interfaces/pseudo-ethernet/node.tag/traffic/save/node.tag/node.def new file mode 100644 index 0000000..bd747b5 --- /dev/null +++ b/templates/monitor/interfaces/pseudo-ethernet/node.tag/traffic/save/node.tag/node.def @@ -0,0 +1,2 @@ +help: Save monitored traffic to a file +run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --save "${@:7}" diff --git a/templates/monitor/interfaces/tunnel/node.tag/traffic/save/node.def b/templates/monitor/interfaces/tunnel/node.tag/traffic/save/node.def index bd747b5..402f47c 100644 --- a/templates/monitor/interfaces/tunnel/node.tag/traffic/save/node.def +++ b/templates/monitor/interfaces/tunnel/node.tag/traffic/save/node.def @@ -1,2 +1 @@ help: Save monitored traffic to a file -run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --save "${@:7}" diff --git a/templates/monitor/interfaces/tunnel/node.tag/traffic/save/node.tag/node.def b/templates/monitor/interfaces/tunnel/node.tag/traffic/save/node.tag/node.def new file mode 100644 index 0000000..bd747b5 --- /dev/null +++ b/templates/monitor/interfaces/tunnel/node.tag/traffic/save/node.tag/node.def @@ -0,0 +1,2 @@ +help: Save monitored traffic to a file +run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --save "${@:7}" |