My favorites
|
Sign in
rrdpy
Python RRD Utilities
Project Home
Downloads
Source
Checkout
|
Browse
|
Changes
|
‹r21
r26
Source path:
svn
/
trunk
/
rrd_feeder_http.py
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
#!/usr/bin/env python
# Copyright (c) 2008 Corey Goldberg (corey@goldb.org)
#
# RRDTool HTTP Performance Meter (Data Feeder/Grapher)
import rrd
import time
import sys
import httplib
host = 'www.python.org'
path = '/'
use_ssl = False
interval = 10
rrd_file = 'test.rrd'
def main():
my_rrd = rrd.RRD(rrd_file, 'Response Time')
while True:
start_time = time.clock()
try:
send(host)
except:
print 'failed request'
end_time = time.clock()
raw_latency = (end_time - start_time)
expire_time = (interval - raw_latency)
latency = ('%.3f' % raw_latency)
my_rrd.update(latency)
my_rrd.graph(60)
print latency
if expire_time > 0:
time.sleep(expire_time)
def send(host):
if use_ssl:
conn = httplib.HTTPSConnection(host)
else:
conn = httplib.HTTPConnection(host)
try:
conn.request('GET', path)
conn.getresponse().read()
except:
raise
finally:
conn.close()
if __name__ == '__main__':
main()
Show details
Hide details
Change log
r22
by cgoldberg on Sep 26, 2008
Diff
[No log message]
Go to:
/trunk/rrd_feeder_http.py
Project members,
sign in
to write a code review
Older revisions
r21
by cgoldberg on Sep 24, 2008
Diff
[No log message]
r20
by cgoldberg on Sep 24, 2008
Diff
[No log message]
r19
by cgoldberg on Sep 24, 2008
Diff
[No log message]
All revisions of this file
File info
Size: 1246 bytes, 57 lines
View raw file
Hosted by