def load(self, ts_start, ts_end): self.ts_start = ts_start self.ts_end = ts_end if self.handle is None: return [] #info = self.rrd.info(self.rrd.filename) ret = self.handle.read(ts_start, ts_end) #print ('result: ', ret) # ((ts_start, ts_end, step), (metric1, metric2, metric3), [(0, 0, 0), (1, 1, 1)....]) ts_start = ret[0][0] * 1000 ts_step = ret[0][2] * 1000 names = ret[1] items = ret[2] tmap = {} for i in range(0, len(names)): tmap[names[i]] = i # loader title chart_data_list = [] if self.title != '': title_chart = chart_data() title_chart.title = self.title title_chart.renderer = self.renderer['title'] chart_data_list.append(title_chart) if self.filter == None: # select all self.filter = names #print(self.filter) for titles in self.filter: # for each chart new_chart = chart_data() tmp_list = self.make_chart(titles, tmap, items, ts_start, ts_step) for tmp in tmp_list: new_chart.push_data(tmp[0], tmp[1]) renderer_name = 'default' if isinstance(titles, list) and titles[0].startswith('#'): # renderer renderer_name = titles[0][1:] if renderer_name in self.renderer: new_chart.renderer = self.renderer[renderer_name] chart_data_list.append(new_chart) return chart_data_list
def load(self, ts_start, ts_end): chart_data_list = [] # merged result chart_list_list = [] chart_len = -1 for loader in self.loaders: chart_list = loader.load(ts_start, ts_end) if len(chart_list) == 0: continue chart_list_list.append(chart_list) if chart_len == -1: # init chart_len = len(chart_list) elif chart_len != len(chart_list): print('# chart list length mismatch') return [] for x in range(0, chart_len): new_chart = chart_data() for y in range(0, len(chart_list_list)): chart = chart_list_list[y][x] new_chart.sum(chart) new_chart.mode = chart.mode chart_data_list.append(new_chart) return chart_data_list
def load(self, ts_start, ts_end): chart = chart_data() chart.mode = 'number' for data in self.datas: new_data = [] if isinstance(data, list) or isinstance(data, range): iter_x = iter(self.range) iter_y = iter(data) try: while True: new_data.append([next(iter_x), next(iter_y)]) except StopIteration: pass chart.push_data('', new_data) else: # lambda for x in self.range: new_data.append([x, data(x)]) chart.push_data('', new_data) return [chart]
def load(self, ts_start, ts_end): chart_data_list = [] # merged result chart_list_list = [] chart_len = -1 for loader in self.loaders: chart_list = loader.load(ts_start, ts_end) if len(chart_list) == 0: continue chart_list_list.append(chart_list) if chart_len == -1: # init chart_len = len(chart_list) elif chart_len != len(chart_list): print('# chart list length mismatch') return [] for x in range(0, chart_len): new_chart = chart_data() for y in range(0, len(chart_list_list)): chart = chart_list_list[y][x] new_chart.sum(chart) new_chart.mode = chart.mode new_chart.renderer = chart.renderer chart_data_list.append(new_chart) return chart_data_list
def load(self, ts_start, ts_end): chart = chart_data() chart.mode = 'number' chart.renderer = flot_line_renderer() for data in self.datas: new_data = [] if isinstance(data, list) or isinstance(data, range): iter_x = iter(self.range) iter_y = iter(data) try: while True: new_data.append([next(iter_x), next(iter_y)]) except StopIteration: pass chart.push_data('', new_data) else: # lambda for x in self.range: new_data.append([x, data(x)]) chart.push_data('', new_data) return [chart]
def load(self, ts_start, ts_end): chart_data_list = [] # merged result chart_list_list = [] chart_len = -1 if not isinstance(self.loaders, list): print("# loaders (param of merge) should be list") return [] for loader in self.loaders: chart_list = loader.load(ts_start, ts_end) if len(chart_list) == 0: continue chart_list_list.append(chart_list) if chart_len == -1: # init chart_len = len(chart_list) elif chart_len != len(chart_list): print("# chart list length mismatch") return [] for x in range(0, chart_len): new_chart = chart_data() for y in range(0, len(chart_list_list)): chart = chart_list_list[y][x] new_chart.sum(chart) new_chart.mode = chart.mode new_chart.renderer = chart.renderer chart_data_list.append(new_chart) return chart_data_list
def load(self, ts_start, ts_end): chart_data_list = [] # merged result if not isinstance(self.loaders, list): print('# loaders (param of merge) should be list') return [] chart_list_list = parallel_load(ts_start, ts_end, self.loaders) chart_len = -1 for chart_list in chart_list_list: if chart_len == -1: # init chart_len = len(chart_list) elif chart_len != len(chart_list): print('# chart list length mismatch') return [] for x in range(0, chart_len): new_chart = chart_data() for y in range(0, len(chart_list_list)): chart = chart_list_list[y][x] self.modify(new_chart, chart) if self.title_prefix != '': new_chart.title = '%s%s' % (self.title_prefix, new_chart.title) chart_data_list.append(new_chart) return sorted(chart_data_list, key=lambda chart: chart.title)
def load(self, ts_start, ts_end): chart_data_list = [] # merged result if self.title != '': title_chart = chart_data() title_chart.title = self.title chart_data_list.append(title_chart) for loader in self.loaders: chart_list = loader.load(ts_start, ts_end) if len(chart_list) == 0: continue chart_data_list += chart_list return chart_data_list
def load(self, ts_start, ts_end): chart_data_list = [] # merged result if self.title != "": title_chart = chart_data() title_chart.title = self.title chart_data_list.append(title_chart) for loader in self.loaders: chart_list = loader.load(ts_start, ts_end) if len(chart_list) == 0: continue chart_data_list += chart_list return chart_data_list
def load(self, ts_start, ts_end): chart_data_list = [] # merged result if not isinstance(self.loaders, list): print('# loaders (param of merge) should be list') return [] chart_list_list = parallel_load(ts_start, ts_end, self.loaders) if self.title != '': title_chart = chart_data() title_chart.title = self.title chart_data_list.append(title_chart) for chart_list in chart_list_list: chart_data_list += chart_list #return sorted(chart_data_list, key=lambda chart: chart.title) return chart_data_list
def load(self, ts_start, ts_end): self.ts_start = ts_start self.ts_end = ts_end if self.handle is None: print ('invalid handle') return [] ret = self.handle.read(ts_start, ts_end) #print ('result: ', ret) # default(rrd) type ((ts_start, ts_end, step), (metric1, metric2, metric3), [(0, 0, 0), (1, 1, 1)....]) # rrd type ('#rrd', (ts_start, ts_end, step), (metric1, metric2, metric3), [(0, 0, 0), (1, 1, 1)....]) # tsdb type ('#timestamp', (metric1, metric2, metric3), [(ts, 0, 0, 0), (ts, 1, 1, 1)....]) tmap = {} if isinstance(ret[0], str): if ret[0] == '#timestamp': ts_start = None ts_step = None names = ret[1] items = ret[2] else: ts_start = ret[1][0] * 1000 ts_step = ret[1][2] * 1000 names = ret[2] items = ret[3] for i in range(0, len(names)): tmap[names[i]] = i+1 # skip 1 for tag else: # implicit rrd style ts_start = ret[0][0] * 1000 ts_step = ret[0][2] * 1000 names = ret[1] items = ret[2] for i in range(0, len(names)): tmap[names[i]] = i # for debug #print(tmap) #print(names) #print(items) # loader title chart_data_list = [] if self.title != '': title_chart = chart_data() title_chart.title = self.title title_chart.renderer = self.renderer['title'] chart_data_list.append(title_chart) if self.filter == None: # select all self.filter = names #print(self.filter) for titles in self.filter: # for each chart new_chart = chart_data() tmp_list = self.make_chart(titles, tmap, items, ts_start, ts_step) for tmp in tmp_list: new_chart.push_data(tmp[0], tmp[1]) renderer_name = 'default' if isinstance(titles, list) and titles[0].startswith('#'): # renderer renderer_name = titles[0][1:] if renderer_name in self.renderer: new_chart.renderer = self.renderer[renderer_name] chart_data_list.append(new_chart) return chart_data_list
def load(self, ts_start, ts_end): self.ts_start = ts_start self.ts_end = ts_end if self.handle is None: return [] ret = self.handle.read(ts_start, ts_end) #print ('result: ', ret) # default(rrd) type ((ts_start, ts_end, step), (metric1, metric2, metric3), [(0, 0, 0), (1, 1, 1)....]) # rrd type ('#rrd', (ts_start, ts_end, step), (metric1, metric2, metric3), [(0, 0, 0), (1, 1, 1)....]) # tsdb type ('#timestamp', (metric1, metric2, metric3), [(ts, 0, 0, 0), (ts, 1, 1, 1)....]) tmap = {} if isinstance(ret[0], str): if ret[0] == '#timestamp': ts_start = None ts_step = None names = ret[1] items = ret[2] else: ts_start = ret[1][0] * 1000 ts_step = ret[1][2] * 1000 names = ret[2] items = ret[3] for i in range(0, len(names)): tmap[names[i]] = i + 1 # skip 1 for tag else: # implicit rrd style ts_start = ret[0][0] * 1000 ts_step = ret[0][2] * 1000 names = ret[1] items = ret[2] for i in range(0, len(names)): tmap[names[i]] = i # for debug #print(tmap) #print(names) #print(items) # loader title chart_data_list = [] if self.title != '': title_chart = chart_data() title_chart.title = self.title title_chart.renderer = self.renderer['title'] chart_data_list.append(title_chart) if self.filter == None: # select all self.filter = names #print(self.filter) for titles in self.filter: # for each chart new_chart = chart_data() tmp_list = self.make_chart(titles, tmap, items, ts_start, ts_step) for tmp in tmp_list: new_chart.push_data(tmp[0], tmp[1]) renderer_name = 'default' if isinstance(titles, list) and titles[0].startswith('#'): # renderer renderer_name = titles[0][1:] if renderer_name in self.renderer: new_chart.renderer = self.renderer[renderer_name] chart_data_list.append(new_chart) return chart_data_list
def load(self, ts_start, ts_end): self.ts_start = ts_start self.ts_end = ts_end if self.handle is None: print ('invalid handle') return [] ret = self.handle.read(ts_start, ts_end) #print ('result: ', ret) # default(rrd) type ((ts_start, ts_end, step), (metric1, metric2, metric3), [(0, 0, 0), (1, 1, 1)....]) # rrd type ('#rrd', (ts_start, ts_end, step), (metric1, metric2, metric3), [(0, 0, 0), (1, 1, 1)....]) # tsdb type ('#timestamp', (metric1, metric2, metric3), [(ts, 0, 0, 0), (ts, 1, 1, 1)....]) tmap = {} if isinstance(ret[0], str): if ret[0] == '#timestamp': ts_start = None ts_step = None names = ret[1] items = ret[2] else: ts_start = ret[1][0] * 1000 ts_step = ret[1][2] * 1000 names = ret[2] items = ret[3] for i in range(0, len(names)): tmap[names[i]] = i+1 # skip 1 for tag else: # implicit rrd style ts_start = ret[0][0] * 1000 ts_step = ret[0][2] * 1000 names = ret[1] items = ret[2] for i in range(0, len(names)): tmap[names[i]] = i # for debug #print("tmap ",tmap) #print("names ",names) #print("items ",items) # loader title chart_data_list = [] if self.title != '': #print("self.title", self.title) title_chart = chart_data() title_chart.title = self.title title_chart.renderer = self.renderer['title'] chart_data_list.append(title_chart) if self.filter == None: # select all self.filter = names for titles in self.filter: # for each chart new_chart = chart_data() tmp_list = self.make_chart(titles, tmap, items, ts_start, ts_step) for t in range(len(tmp_list)): #print("tmp ", titles,tmp[0], tmp[1][0:2]) ###### tmp = tmp_list[t] if(tmp[0] == 'user'): tmp2 = [] for i in range(len(tmp[1])): if tmp[1][i] == None: tmp2.append(tmp[1][i]) else: tmp4 = tmp_list[t-1] tmp2.append([tmp[1][i][0], (tmp[1][i][1]+ tmp4[1][i][1])/2]) new_chart.push_data('stack', tmp2) ###### new_chart.push_data(tmp[0], tmp[1]) renderer_name = 'default' if isinstance(titles, list) and titles[0].startswith('#'): # renderer renderer_name = titles[0][1:] if renderer_name in self.renderer: #print("rndere nake : ",titles) new_chart.renderer = self.renderer[renderer_name] chart_data_list.append(new_chart) return chart_data_list
def load(self, ts_start, ts_end): title_chart = chart_data() title_chart.title = self.title return [title_chart]