def report(self): """ report check vaules ro be saved in remote DB :return: Dictionary with items to report {'MEM': {'free': 50, 'used': 50 ... } } """ report_dict = collections.defaultdict(float) r_dict = collections.defaultdict(float) count = 1 for mydict in self.mem_average: for key, value in iteritems(mydict): if key in MemUpdate.NAMED_CHECKS: report_dict[key] += value for key, value in iteritems(report_dict): r_dict[key] = value / self.mem_queue_len # Return the dict with CHECK Prefix return {'table_name': self.fn_for_db, self.prefix: r_dict}
def report(self): """ report check vaules ro be saved in remote DB :return: Dictionary with items to report {'CPU': {'total': 35, 'user': 22, 'system': 13 ... ... } } """ report_dict = collections.defaultdict(float) r_dict = collections.defaultdict(float) count = 1 for mydict in self.cpu_average: for key, value in iteritems(mydict): if key in CpuUpdate.NAMED_CHECKS: report_dict[key] += value for key, value in iteritems(report_dict): r_dict[key] = value / self.cpu_queue_len #r_dict[] # Return the dict with CHECK Prefix return {'table_name': self.fn_for_db, self.prefix: r_dict}
def report(self, *args, **kwargs): """ Abstract class that needs to be implemented in all Monitors :param args: Optional list of Monitors to update :param kwargs: Optional list of KeyWord args :return: List of stats from all updated monitors """ logger.info("Do something before real update") # IF no args then update all update behaviours in list if not args: for (classname, instance) in three2two.iteritems(self.monitor): # Return data from monitor (classname) stat = instance.update(*args, **kwargs) logger.info("Do something with THIS update metrics for monitor {}".format(classname)) # This is now a list of dicts, probably not OK, need dict self.metrics.append(stat) # We have args and only update those behaviours else: for inst in args: cname = inst.__class__.__name__ if cname in self.monitor: stat = inst.update(**kwargs) logger.info("Do something with THIS update metrics for monitor {}").format(cname) # This is now a list of dicts, probably not OK, need dict self.metrics.append(stat) logger.info("Do something with all update metrics") return self.metrics