-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathait-db-add-netperf-udp_stream
executable file
·60 lines (48 loc) · 1.83 KB
/
ait-db-add-netperf-udp_stream
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
#! /usr/bin/python
# -*- python -*-
# -*- coding: utf-8 -*-
from dbstats import dbstats
class netperf_udp_stream_report:
def __init__(self, filename):
self.msg_sizes = {}
self._load_udp_stream_report(filename)
def _load_udp_stream_report(self, filename):
try:
f = file(filename)
except:
return
for line in f.readlines():
fields = line.strip().split(',')
msg_size = int(fields[0])
self.msg_sizes[msg_size] = {}
self.msg_sizes[msg_size]["msg_err"] = int(fields[1])
self.msg_sizes[msg_size]["local_socket_size"] = int(fields[2])
self.msg_sizes[msg_size]["local_elapsed_time"] = float(fields[3])
self.msg_sizes[msg_size]["local_msg_ok"] = int(fields[4])
self.msg_sizes[msg_size]["local_throughput"] = float(fields[5])
self.msg_sizes[msg_size]["remote_socket_size"] = int(fields[6])
self.msg_sizes[msg_size]["remote_elapsed_time"] = float(fields[7])
self.msg_sizes[msg_size]["remote_msg_ok"] = int(fields[8])
self.msg_sizes[msg_size]["remote_throughput"] = float(fields[9])
f.close()
if __name__ == '__main__':
import sys, os, shutil
appname = sys.argv[1]
client_machine = sys.argv[2]
server_machine = sys.argv[3]
report = sys.argv[4]
if not os.access(report, os.F_OK):
print "report %s is not accessible" % report
sys.exit(1)
db = dbstats(appname)
if not db.setreport(report, client_machine, server_machine):
print "report %s already in database" % report
sys.exit(1)
print "Adding report %s to the database" % db.report
m = netperf_udp_stream_report(report)
for msg_size in m.msg_sizes.keys():
db.insert_netperf_udp_stream(msg_size, m.msg_sizes[msg_size])
if os.access("/proc/lock_stat", os.F_OK) and \
os.access("lock_stat/last", os.F_OK):
os.rename("lock_stat/last", "lock_stat/%d.txt" % db.report)
shutil.move(report, "reports/%s/%d" % (appname, db.report))