4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since 5478d3d was
e19ada0,
checked in by Shane Alcock <salcock@…>, 11 years ago
|
- Stupid OS's that don't have /bin/bash
|
-
Property mode set to
100755
|
File size:
1.9 KB
|
Line | |
---|
1 | #!/bin/sh |
---|
2 | |
---|
3 | if [ $# -lt 1 ]; then |
---|
4 | echo usage: $0 [options] inputuri... |
---|
5 | echo See manpage for more details. |
---|
6 | exit |
---|
7 | fi |
---|
8 | |
---|
9 | top_count=10 |
---|
10 | send=1 |
---|
11 | sort="bytes" |
---|
12 | filter="" |
---|
13 | addr="v4" |
---|
14 | |
---|
15 | while getopts "f:sdn:bapA:h" opt; do |
---|
16 | case $opt in |
---|
17 | A) |
---|
18 | addr=$OPTARG |
---|
19 | ;; |
---|
20 | f) |
---|
21 | filter=$OPTARG |
---|
22 | ;; |
---|
23 | s) |
---|
24 | send=1 |
---|
25 | ;; |
---|
26 | d) |
---|
27 | send=0 |
---|
28 | ;; |
---|
29 | n) |
---|
30 | top_count=$OPTARG |
---|
31 | ;; |
---|
32 | b) |
---|
33 | sort="bytes" |
---|
34 | ;; |
---|
35 | a) |
---|
36 | sort="app" |
---|
37 | ;; |
---|
38 | p) |
---|
39 | sort="pkts" |
---|
40 | ;; |
---|
41 | h) |
---|
42 | echo usage: $0 [options] inputuri... |
---|
43 | echo Type \'man tracetopends\' for more details. |
---|
44 | exit 1 |
---|
45 | ;; |
---|
46 | /?) |
---|
47 | echo "Invalid option: -$OPTARG" |
---|
48 | exit 1 |
---|
49 | ;; |
---|
50 | :) |
---|
51 | echo "Option -$OPTARG requires an argument" |
---|
52 | exit 1 |
---|
53 | ;; |
---|
54 | esac |
---|
55 | done |
---|
56 | |
---|
57 | sort_index=0 |
---|
58 | |
---|
59 | if [ $send = 1 ]; then |
---|
60 | if [ $sort = "bytes" ]; then |
---|
61 | sort_index=4 |
---|
62 | elif [ $sort = "pkts" ]; then |
---|
63 | sort_index=3 |
---|
64 | else |
---|
65 | sort_index=5 |
---|
66 | fi |
---|
67 | fi |
---|
68 | |
---|
69 | if [ $send = 0 ]; then |
---|
70 | if [ $sort = "bytes" ]; then |
---|
71 | sort_index=7 |
---|
72 | elif [ $sort = "pkts" ]; then |
---|
73 | sort_index=6 |
---|
74 | else |
---|
75 | sort_index=8 |
---|
76 | fi |
---|
77 | fi |
---|
78 | |
---|
79 | exec |
---|
80 | |
---|
81 | shift $(($OPTIND - 1)) |
---|
82 | |
---|
83 | if [ $addr = "mac" ]; then |
---|
84 | printf "%18s %16s %16s %16s %16s %16s %16s %16s\n" \ |
---|
85 | "MAC Address" \ |
---|
86 | "Last Seen" \ |
---|
87 | "Src Pkts" \ |
---|
88 | "Src Bytes" \ |
---|
89 | "Src Payload" \ |
---|
90 | "Dst Pkts" \ |
---|
91 | "Dst Bytes" \ |
---|
92 | "Dst Payload" |
---|
93 | fi |
---|
94 | |
---|
95 | if [ $addr = "v4" ]; then |
---|
96 | printf "%16s %16s %16s %16s %16s %16s %16s %16s\n" \ |
---|
97 | "IPv4 Address" \ |
---|
98 | "Last Seen" \ |
---|
99 | "Src Pkts" \ |
---|
100 | "Src Bytes" \ |
---|
101 | "Src Payload" \ |
---|
102 | "Dst Pkts" \ |
---|
103 | "Dst Bytes" \ |
---|
104 | "Dst Payload" |
---|
105 | fi |
---|
106 | |
---|
107 | if [ $addr = "v6" ]; then |
---|
108 | printf "%40s %16s %16s %16s %16s %16s %16s %16s\n" \ |
---|
109 | "IPv6 Address" \ |
---|
110 | "Last Seen" \ |
---|
111 | "Src Pkts" \ |
---|
112 | "Src Bytes" \ |
---|
113 | "Src Payload" \ |
---|
114 | "Dst Pkts" \ |
---|
115 | "Dst Bytes" \ |
---|
116 | "Dst Payload" |
---|
117 | fi |
---|
118 | |
---|
119 | if [ "$filter" = "" ]; then |
---|
120 | traceends -A $addr $@ | { trap '' int; sort -n -k $sort_index -r -s; } | { trap '' int; head -n $top_count; } |
---|
121 | else |
---|
122 | traceends -A $addr -f "$filter" $@ | { trap '' int; sort -n -k $sort_index -r -s; } | { trap '' int; head -n $top_count; } |
---|
123 | fi |
---|
124 | |
---|
125 | exit 0 |
---|
126 | |
---|
Note: See
TracBrowser
for help on using the repository browser.