/usr/sbin/varnetload is in tuned-utils-systemtap 2.9.0-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | #!/usr/bin/python -Es
#
# varnetload: A python script to create reproducable sustained network traffic
# Copyright (C) 2008-2013 Red Hat, Inc.
# Authors: Phil Knirsch
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#
# Usage: varnetload [-d delay in milliseconds] [-t runtime in seconds] [-u URL]
#
# Howto use it:
# - In order to effectively use it you need to have a http server in your local
# LAN where you can put files.
# - Upload a large HTML (or any other kind of file) to the http server.
# - Use the -u option of the script to point to that URL
# - Play with the delay option to vary the load put on your network. Typical
# useful values range from 0 to 500.
#
import time, getopt, sys
from urllib2 import *
def usage():
print("Usage: varnetload [-d delay in milliseconds] [-t runtime in seconds] [-u URL]")
delay = 1000.0
rtime = 60.0
url = "http://myhost.mydomain/index.html"
try:
opts, args = getopt.getopt(sys.argv[1:], "d:t:u:")
except getopt.error, e:
print("Error parsing command-line arguments: %s" % e)
usage()
sys.exit(1)
for (opt, val) in opts:
if opt == '-d':
delay = float(val)
elif opt == '-t':
rtime = float(val)
elif opt == '-u':
url = val
else:
print("Unknown option: %s" % opt)
usage()
sys.exit(1)
endtime = time.time() + rtime
delay = float(delay)/1000.0
try:
count = 0
while(time.time() < endtime):
if (delay < 0.01):
urlopen(url).read(409600)
time.sleep(delay)
urlopen(url).read(409600)
time.sleep(delay)
urlopen(url).read(409600)
time.sleep(delay)
urlopen(url).read(409600)
time.sleep(delay)
urlopen(url).read(409600)
time.sleep(delay)
urlopen(url).read(409600)
time.sleep(delay)
urlopen(url).read(409600)
time.sleep(delay)
urlopen(url).read(409600)
time.sleep(delay)
urlopen(url).read(409600)
time.sleep(delay)
count += 9
urlopen(url).read(409600)
time.sleep(delay)
count += 1
except URLError, e:
print("Downloading failed: %s" % e.reason)
sys.exit(2)
print("Finished varnetload. Received %d pages in %d seconds" % (count, rtime))
|