File tree 1 file changed +37
-0
lines changed
1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+
3
+ import argparse
4
+ import http .client as httplib
5
+ import random
6
+ import sys
7
+ import time
8
+
9
+ def parse_args ():
10
+ parser = argparse .ArgumentParser ()
11
+ parser .add_argument ("host" ,
12
+ help = "Address of the remote host running the web server to be contacted" )
13
+ parser .add_argument ("-p" , "--port" , help = "Port of the web server" ,
14
+ type = int , default = 80 )
15
+ parser .add_argument ("-s" , "--sleep" ,
16
+ help = "The mean time in minutes to sleep between connections" ,
17
+ type = float , default = 10.0 )
18
+ parser .add_argument ("-u" , "--url" ,
19
+ help = "Relative URL to be requested on the server" ,
20
+ default = "/pcf/timestamp46.html" )
21
+ args = parser .parse_args ()
22
+ return args
23
+
24
+ if __name__ == "__main__" :
25
+ args = parse_args ()
26
+ addr = args .host
27
+ port = args .port
28
+ lambdaexp = 1.0 / args .sleep
29
+ url = args .url
30
+ print (addr , port , lambdaexp , url )
31
+ while True :
32
+ http = httplib .HTTPConnection (addr , port )
33
+ http .request ("POST" ,
34
+ url ,
35
+ body = str (time .time ()))
36
+ sleeptime = random .expovariate (lambdaexp ) * 60
37
+ time .sleep (sleeptime )
You can’t perform that action at this time.
0 commit comments