def find_metric(self, datasource, sysname=None, info_object=None): descr = datasource.description if descr in self.cpus: metric = metric_path_for_cpu_load(sysname, 'cpu', self.get_interval(descr)) elif descr in self.memories: metric = metric_prefix_for_memory(sysname, descr) elif descr in self.bandwidths: if descr.endswith(('Max', 'max')): if descr.startswith('c5000'): metric = metric_path_for_bandwith_peak(sysname, True) else: metric = metric_path_for_bandwith_peak(sysname, False) else: if descr.startswith('c5000'): metric = metric_path_for_bandwith(sysname, True) else: metric = metric_path_for_bandwith(sysname, False) elif descr == 'sysUpTime': metric = metric_path_for_sysuptime(sysname) else: _logger.info('Could not find metric for %s' % descr) metric = None return metric
def find_metric(self, datasource, sysname=None, info_object=None): descr = datasource.description if descr in self.cpus: metric = metric_path_for_cpu_load( sysname, 'cpu', self.get_interval(descr)) elif descr in self.memories: metric = metric_prefix_for_memory(sysname, descr) elif descr in self.bandwidths: if descr.endswith(('Max', 'max')): if descr.startswith('c5000'): metric = metric_path_for_bandwith_peak( sysname, True) else: metric = metric_path_for_bandwith_peak( sysname, False) else: if descr.startswith('c5000'): metric = metric_path_for_bandwith( sysname, True) else: metric = metric_path_for_bandwith( sysname, False) elif descr == 'sysUpTime': metric = metric_path_for_sysuptime(sysname) else: _logger.info('Could not find metric for %s' % descr) metric = None return metric
def _collect_sysuptime(self): mib = Snmpv2Mib(self.agent) uptime = yield mib.get_sysUpTime() timestamp = time.time() if uptime: path = metric_path_for_sysuptime(self.netbox) defer.returnValue([(path, (timestamp, uptime))]) else: defer.returnValue([])
def _collect_sysuptime(self, netboxes): mib = Snmpv2Mib(self.agent) uptime = yield mib.get_sysUpTime() timestamp = time.time() if uptime: metrics = [] for netbox in netboxes: path = metric_path_for_sysuptime(netbox) metrics.append((path, (timestamp, uptime))) defer.returnValue(metrics) else: defer.returnValue([])