Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
8e86b9e9
Commit
8e86b9e9
authored
Jul 27, 2017
by
Benjamin Poirier
Committed by
Brenden Blanco
Aug 11, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tcptop: Cleanup argument parsing
parent
890c76ab
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
16 deletions
+15
-16
tools/tcptop.py
tools/tcptop.py
+15
-16
No files found.
tools/tcptop.py
View file @
8e86b9e9
...
...
@@ -34,6 +34,13 @@ from subprocess import call
import
ctypes
as
ct
# arguments
def
range_check
(
string
):
value
=
int
(
string
)
if
value
<
1
:
msg
=
"value must be stricly positive, got %d"
%
(
value
,)
raise
argparse
.
ArgumentTypeError
(
msg
)
return
value
examples
=
"""examples:
./tcptop # trace TCP send/recv by host
./tcptop -C # don't clear the screen
...
...
@@ -49,15 +56,11 @@ parser.add_argument("-S", "--nosummary", action="store_true",
help
=
"skip system summary line"
)
parser
.
add_argument
(
"-p"
,
"--pid"
,
help
=
"trace this PID only"
)
parser
.
add_argument
(
"interval"
,
nargs
=
"?"
,
default
=
1
,
parser
.
add_argument
(
"interval"
,
nargs
=
"?"
,
default
=
1
,
type
=
range_check
,
help
=
"output interval, in seconds (default 1)"
)
parser
.
add_argument
(
"count"
,
nargs
=
"?"
,
default
=
99999999
,
parser
.
add_argument
(
"count"
,
nargs
=
"?"
,
default
=
-
1
,
type
=
range_check
,
help
=
"number of outputs"
)
args
=
parser
.
parse_args
()
countdown
=
int
(
args
.
count
)
if
args
.
interval
and
int
(
args
.
interval
)
==
0
:
print
(
"ERROR: interval 0. Exiting."
)
exit
()
debug
=
0
# linux stats
...
...
@@ -204,15 +207,13 @@ ipv6_recv_bytes = b["ipv6_recv_bytes"]
print
(
'Tracing... Output every %s secs. Hit Ctrl-C to end'
%
args
.
interval
)
# output
exiting
=
0
while
(
1
):
i
=
0
exiting
=
False
while
i
!=
args
.
count
and
not
exiting
:
try
:
if
args
.
interval
:
sleep
(
int
(
args
.
interval
))
else
:
sleep
(
99999999
)
sleep
(
args
.
interval
)
except
KeyboardInterrupt
:
exiting
=
1
exiting
=
True
# header
if
args
.
noclear
:
...
...
@@ -282,6 +283,4 @@ while (1):
ipv6_send_bytes
.
clear
()
ipv6_recv_bytes
.
clear
()
countdown
-=
1
if
exiting
or
countdown
==
0
:
exit
()
i
+=
1
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment