-
Notifications
You must be signed in to change notification settings - Fork 0
/
DatabaseHelper.py
110 lines (85 loc) · 3.6 KB
/
DatabaseHelper.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
'''
Created on 21.01.2014
@author: uwe schilling
'''
from SQLiteObject import SQLiteObject
from RRDToolObject import RRDToolObject
import datetime
import time
class DatabaseHelper(object):
'''
classdocs
'''
def __init__(self):
'''
Constructor
'''
self.databases = set()
def addSQLite(self, fileName):
self.databases.add(SQLiteObject(fileName))
def addRRDB(self, folder):
self.databases.add(RRDToolObject(folder))
def closeConnection(self):
for db in self.databases:
db.closeConnection
def addUser(self, userName, timeStamp, WR_MB, RD_MB, REQS):
for db in self.databases:
db.addUser(userName, timeStamp, WR_MB, RD_MB, REQS)
def addJob(self, jobID, timeStamp, WR_MB, RD_MB, REQS):
for db in self.databases:
db.addJob(jobID, timeStamp, WR_MB, RD_MB, REQS)
def addGlobal(self, timeStamp, WR_MB, RD_MB, REQS):
for db in self.databases:
db.addGlobal(timeStamp, WR_MB, RD_MB, REQS)
def addMDS(self, MDS_name, timeStamp, WR_MB, RD_MB, REQS):
for db in self.databases:
db.addMDS(MDS_name, timeStamp, WR_MB, RD_MB, REQS)
def addOSS(self, OSS_name, timeStamp, WR_MB, RD_MB, REQS):
for db in self.databases:
db.addOSS(OSS_name, timeStamp, WR_MB, RD_MB, REQS)
def addMDT(self, MDT_name, timeStamp, WR_MB, RD_MB, REQS):
for db in self.databases:
db.addOSS(MDT_name, timeStamp, WR_MB, RD_MB, REQS)
def addOST(self, OST_name, timeStamp, WR_MB, RD_MB, REQS):
for db in self.databases:
db.addOSS(OST_name, timeStamp, WR_MB, RD_MB, REQS)
def insert_timestamp(self, timestamp):
for db in self.databases:
db.insert_timestamp(timestamp)
def insert_source(self, source):
for db in self.databases:
db.insert_source(source)
def insert_server(self, server, stype):
for db in self.databases:
db.insert_server(server, stype)
def add_nid_server(self, server, nid_name):
for db in self.databases:
db.add_nid_server(server, nid_name)
def getNidID(self, server, i):
for db in self.databases:
db.getNidID(server, i)
def insert_nid(self, server, timestamp, source, nidvals, nidid):
for db in self.databases:
db.insert_nids(server, timestamp, source, nidvals, nidid)
def insert_nid_server(self, server, nid_name):
for db in self.databases:
db.insert_nids(server, timestamp, source, nidvals)
def insert_ost_samples(self, il_ost):
for db in self.databases:
db.insert_ost_samples(il_ost)
def insert_mdt_samples(self, il_mdt):
for db in self.databases:
db.insert_mdt_samples(il_mdt)
#------------------------------------------------------------------------------
def dateToTimeStamp(self, year, month, day, houer, minute):
''' convert from year day month to time stamp '''
dateTimeInput = datetime.datetime(year, month, day, houer, minute)
timeStamp = time.mktime(dateTimeInput.timetuple())
timeStamp = int(timeStamp)
return timeStamp
#------------------------------------------------------------------------------
def timeStampToDate(self, timeStamp):
''' converts form time stamp to year day month '''
return datetime.datetime.fromtimestamp(
float(timeStamp)).strftime('%Y-%m-%d %H:%M:%S')
#------------------------------------------------------------------------------