10 couch = couchdb.Server("http://IPADDR:5984/")
12 #db.resource.http.add_credentials('admin', 'ssorcmor')
14 def set_or_update(id, data):
19 # NOTE: how to update type?
22 print db.update([doc])
24 def get_hist_id(data):
25 return data['ts'] + "-" + data['hostname']
27 def get_single_id(data):
28 return data['hostname'] + "-" + data['type']
30 for filename in sys.argv[1:]:
33 data_hist = file_to_dict(filename)
34 data_single = data_hist.copy()
40 if 'ts' not in data_hist or 'hostname' not in data_hist or 'type' not in data_hist:
41 print "data missing fields", data_hist
44 #hist_id = get_hist_id(data_hist)
45 #set_or_update(hist_id, data_hist)
48 single_id = get_single_id(data_single)
49 data_single['type'] += "-single"
50 set_or_update(single_id, data_single)
52 os.system("echo %s >> /root/load.log" % filename)