Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mininet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Olaf Bergmann
mininet
Commits
f1bf3c60
Commit
f1bf3c60
authored
12 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Added popenpoll.py example of using popen()/pmonitor()
parent
06f7408c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/README
+5
-0
5 additions, 0 deletions
examples/README
examples/popenpoll.py
+33
-0
33 additions, 0 deletions
examples/popenpoll.py
with
38 additions
and
0 deletions
examples/README
+
5
−
0
View file @
f1bf3c60
...
...
@@ -48,6 +48,11 @@ multitest.py:
This example creates a network and runs multiple tests on it.
popenpoll.py:
This example demonstrates monitoring output from multiple hosts using
the node.popen() interface (which returns Popen objects) and pmonitor().
scratchnet.py, scratchnetuser.py:
These two examples demonstrate how to create a network by using the lowest-
...
...
This diff is collapsed.
Click to expand it.
examples/popenpoll.py
0 → 100755
+
33
−
0
View file @
f1bf3c60
#!/usr/bin/python
"
Monitor multiple hosts using popen()/pmonitor()
"
from
mininet.net
import
Mininet
from
mininet.topo
import
SingleSwitchTopo
from
mininet.util
import
pmonitor
from
time
import
time
from
signal
import
SIGINT
def
pmonitorTest
(
N
=
3
,
seconds
=
10
):
"
Run pings and monitor multiple hosts using pmonitor
"
topo
=
SingleSwitchTopo
(
N
)
net
=
Mininet
(
topo
)
net
.
start
()
hosts
=
net
.
hosts
print
"
Starting test...
"
server
=
hosts
[
0
]
popens
=
{}
for
h
in
hosts
:
popens
[
h
]
=
h
.
popen
(
'
ping
'
,
server
.
IP
()
)
print
"
Monitoring output for
"
,
seconds
,
"
seconds
"
endTime
=
time
()
+
seconds
for
h
,
line
in
pmonitor
(
popens
,
timeoutms
=
500
):
if
h
:
print
'
%s: %s
'
%
(
h
.
name
,
line
),
if
time
()
>=
endTime
:
for
p
in
popens
.
values
():
p
.
send_signal
(
SIGINT
)
net
.
stop
()
if
__name__
==
'
__main__
'
:
pmonitorTest
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment