def run(self): self.update_counters() if not self.pnic_before: return if self.graph_type == 'input': kbs = self.get_bytes_received() elif self.graph_type == 'output': kbs = self.get_bytes_sent() else: raise Exception("graph_type must be either 'input' or 'output'!") # Cycle array by inserting at the start and chopping off the last element self.kbs_arr.insert(0, kbs) self.kbs_arr = self.kbs_arr[:self.graph_width] color = self.get_gradient(kbs, self.colors, self.upper_limit) network_graph = make_graph(self.kbs_arr, self.upper_limit) self.output = { "full_text": self.format.format( network_graph=network_graph, kbs="{0:.1f}".format(round(kbs, 2)).rjust(6) ), 'color': color, }
def get_network_graph_sent(self, kbs, limit): # Cycle array by inserting at the start and chopping off the last element self.kbs_sent_arr.insert(0, kbs) self.kbs_sent_arr = self.kbs_sent_arr[:self.graph_width] graph = make_graph(self.kbs_sent_arr, 0.0, limit, self.graph_style) if self.graph_direction == 'right-to-left': return graph[::-1] else: return graph
def run(self): format_options = self.get_usage() core_reading = format_options[self.cpu] self.cpu_readings.insert(0, core_reading) self.cpu_readings = self.cpu_readings[:self.graph_width] graph = make_graph(self.cpu_readings, 0.0, 100.0, self.graph_style) format_options.update({'cpu_graph': graph}) color = self.get_gradient(core_reading, self.colors) self.output = { "full_text": self.format.format_map(format_options), 'color': color }
def run(self): format_options = self.get_usage() core_reading = format_options[self.cpu] self.cpu_readings.insert(0, core_reading) self.cpu_readings = self.cpu_readings[:self.graph_width] graph = make_graph(self.cpu_readings, 0.0, 100.0, self.graph_style) if self.direction == "right-to-left": graph = graph[::-1] elif self.direction == "left-to-right": pass else: raise Exception("Invalid direction '%s'." % self.direction) format_options.update({'cpu_graph': graph}) color = self.get_gradient(core_reading, self.colors) self.data = format_options self.output = { "full_text": self.format.format_map(format_options), 'color': color }
def get_network_graph_sent(self, kbs, limit): # Cycle array by inserting at the start and chopping off the last element self.kbs_sent_arr.insert(0, kbs) self.kbs_sent_arr = self.kbs_sent_arr[:self.graph_width] return make_graph(self.kbs_sent_arr, 0.0, limit, self.graph_style)
def get_network_graph(self, kbs, limit): # Cycle array by inserting at the start and chopping off the last element self.kbs_arr.insert(0, kbs) self.kbs_arr = self.kbs_arr[:self.graph_width] return make_graph(self.kbs_arr, 0.0, limit, self.graph_style)