Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
M
mp-web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Maalepaaler
mp-web
Commits
9d81a41e
Commit
9d81a41e
authored
Sep 17, 2014
by
Olav Kvittem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added deliver-file.pl
parent
e4f8270e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
yt/deliver-file.pl
yt/deliver-file.pl
+63
-0
No files found.
yt/deliver-file.pl
0 → 100755
View file @
9d81a41e
#! /usr/bin/perl
#
# Deliver an amount of data for perfomance testing
# Olav Kvittem ( Olav.Kvittem@uninett.no )
#
# use CGI;
use
CGI
qw/:standard -debug/
;
my
$q
=
CGI
->
new
;
$feilmelding
=
"
<h3><font color=red>%s</font></h3>
\n
";
if
(
0
&&
$q
->
http
('
HTTP_X_TOKEN
')
ne
"
virre-virre-vapp
"
){
my
%msg
;
$msg
{
error
}
=
"
Access to iperf denied : unauthorized
";
push
(
@mtr
,
%msg
);
print
STDERR
"
Error:
";
my
%headers
=
map
{
$_
=>
$q
->
http
(
$_
)
}
$q
->
http
();
print
STDERR
"
Wrong secret : Got the following headers:
\n
";
for
my
$header
(
keys
%headers
)
{
print
STDERR
"
$header
:
$headers
{
$header
}
\n
";
}
print
$q
->
header
('
appliation/json
');
print
encode_json
\
%msg
;
}
else
{
my
$bytes
=
$q
->
param
('
bytes
')
;
#
my
$duration
=
$q
->
param
('
duration
');
# second
$bytes
=~
s/[^\w\d\.\,]/_/g
;
# protect attack
$duration
=~
s/[^\d\.\,]/_/g
;
my
$testfile
=
"
bigfile-1M.bin
";
open
DATA
,
"
<
",
$testfile
||
error
("
Could not open test file :
$testfile
: $!
");
my
$data
=<
DATA
>
;
my
$datasent
=
0
;
my
$start
=
time
;
syswrite
STDOUT
,
$q
->
header
('
application/binary
');
printf
STDERR
"
bytes %d duration %d sec
\n
",
$bytes
,
$duration
;
while
(
$datasent
<
$bytes
&&
(
(
time
-
$start
)
<
$duration
)
){
syswrite
STDOUT
,
$data
;
$datasent
+=
length
(
$data
);
printf
STDERR
"
data sent %d time %d sec
\n
",
$datasent
,
time
-
$start
;
}
}
exit
(
0
);
sub
error
{
my
$msg
=
shift
;
die
$msg
;
}
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