def probe(self): full_duration = 0 load_duration = 0 total = 0 errors = 0 slafail = 0 for res in self.results: total = total + 1 full_duration = full_duration + res['full_duration'] load_duration = load_duration + res['load_duration'] for runres in res['result']: if runres['error'] != []: errors = errors + 1 if 'sla' in res: for sla in res['sla']: if not sla['success']: slafail = slafail + 1 yield osnag.Metric('total', total) yield osnag.Metric('errors', errors) yield osnag.Metric('slafail', slafail) yield osnag.Metric('fulldur', full_duration, uom='s') yield osnag.Metric('loaddur', load_duration, uom='s')
def probe(self): try: nova = client.Client(self.api_version, session=self.session, region_name=self.region_name) except Exception as e: self.exit_error(str(e)) try: if self.host: result = nova.hypervisors.get( nova.hypervisors.find(hypervisor_hostname=self.host)) else: result = nova.hypervisors.statistics() except Exception as e: self.exit_error(str(e)) yield osnag.Metric('vcpus_used', result.vcpus_used, min=0, max=result.vcpus) yield osnag.Metric('vcpus_percent', 100 * result.vcpus_used / result.vcpus, min=0, max=100) yield osnag.Metric('memory_used', result.memory_mb_used, min=0, max=result.memory_mb) yield osnag.Metric('memory_percent', 100 * result.memory_mb_used / result.memory_mb, min=0, max=100) yield osnag.Metric('running_vms', result.running_vms, min=0)
def probe(self): client = self.get_client() try: result = client.status.get()['storage']['summary'] except Exception as e: self.exit_error(str(e)) #{u'storage': {u'summary': {u'metrics': 98, u'measures': 98}}} yield osnag.Metric('measures', result['measures']) yield osnag.Metric('metrics', result['metrics'])
def probe(self): try: auth = identity.Password( username=self.openstack['username'], password=self.openstack['password'], project_name=self.openstack['project_name'], user_domain_name=self.openstack['user_domain_name'], project_domain_name=self.openstack['project_domain_name'], auth_url=self.openstack['auth_url']) sess = session.Session(auth=auth) except Exception as e: self.exit_error('cannot get token ' + str(e)) try: neutron = client.Client(session=sess) except Exception as e: self.exit_error('cannot load ' + str(e)) try: result = neutron.show_network_ip_availability(self.network_uuid) except Exception as e: self.exit_error(str(e)) net_ip = result['network_ip_availability'] stati = dict(total=0, used=0) stati['total'] = net_ip['total_ips'] stati['used'] = net_ip['used_ips'] for r in stati.keys(): yield osnag.Metric(r, stati[r], min=0)
def probe(self): try: keystone = ksclient.Client( username=self.openstack['username'], password=self.openstack['password'], tenant_name=self.openstack['tenant_name'], auth_url=self.openstack['auth_url'], insecure=self.openstack['insecure']) except Exception as e: self.exit_error('cannot get token ' + str(e)) try: neutron = client.Client( '2.0', endpoint_url=keystone.service_catalog.url_for( endpoint_type='public', service_type='network'), token=keystone.auth_token, insecure=self.openstack['insecure']) except Exception as e: self.exit_error('cannot load ' + str(e)) try: result = neutron.list_floatingips() except Exception as e: self.exit_error(str(e)) stati = dict(assigned=0, used=0) for floatingip in result['floatingips']: stati['assigned'] += 1 if floatingip['fixed_ip_address']: stati['used'] += 1 for r in stati.keys(): yield osnag.Metric(r, stati[r], min=0)
def probe(self): try: neutron = client.Client(self.api_version, session=self.session, region_name=self.region_name) except Exception as e: self.exit_error('cannot load ' + str(e)) try: result = neutron.list_agents(host=self.host, binary=self.binary) except Exception as e: self.exit_error('list_agents: ' + str(e)) stati = dict(up=0, disabled=0, down=0, total=0) for agent in result['agents']: stati['total'] += 1 if agent['admin_state_up'] and agent['alive']: stati['up'] += 1 elif not agent['admin_state_up']: stati['disabled'] += 1 else: stati['down'] += 1 for r in stati.keys(): yield osnag.Metric(r, stati[r], min=0)
def probe(self): try: auth = identity.Password( username=self.openstack['username'], password=self.openstack['password'], project_name=self.openstack['project_name'], user_domain_name=self.openstack['user_domain_name'], project_domain_name=self.openstack['project_domain_name'], auth_url=self.openstack['auth_url']) sess = session.Session(auth=auth) except Exception as e: self.exit_error('cannot get token ' + str(e)) try: neutron = client.Client(session=sess) except Exception as e: self.exit_error('cannot load ' + str(e)) try: result = neutron.list_routers() except Exception as e: self.exit_error(str(e)) stati = dict(active=0, down=0, build=0) for router in result['routers']: if router['status'] == 'ACTIVE': stati['active'] += 1 if router['status'] == 'DOWN': stati['down'] += 1 if router['status'] == 'BUILD': stati['build'] += 1 for r in stati.keys(): yield osnag.Metric(r, stati[r], min=0)
def probe(self): try: nova = client.Client(self.api_version, session=self.session, region_name=self.region_name) except Exception as e: self.exit_error(str(e)) try: result = nova.services.list(host=self.host, binary=self.binary) except Exception as e: self.exit_error(str(e)) stati = dict(up=0, disabled=0, down=0, total=0) for agent in result: stati['total'] += 1 if agent.status == 'enabled' and agent.state == 'up': stati['up'] += 1 elif agent.status == 'disabled': stati['disabled'] += 1 else: stati['down'] += 1 for r in stati.keys(): yield osnag.Metric(r, stati[r], min=0)
def probe(self): try: neutron = client.Client('2.0', session=self.get_session(), ca_cert=self.openstack['cacert'], insecure=self.openstack['insecure']) except Exception as e: self.exit_error('cannot load ' + str(e)) try: result = neutron.list_routers() except Exception as e: self.exit_error(str(e)) stati = dict(active=0, down=0, build=0) for router in result['routers']: if router['status'] == 'ACTIVE': stati['active'] += 1 if router['status'] == 'DOWN': stati['down'] += 1 if router['status'] == 'BUILD': stati['build'] += 1 for r in stati.keys(): yield osnag.Metric(r, stati[r], min=0)
def probe(self): try: cinder = Client( '2', session=self.get_session(), insecure=self.openstack['insecure'], cacert=self.openstack['cacert'], ) except Exception as e: self.exit_error(str(e)) try: result = cinder.services.list() except Exception as e: self.exit_error(str(e)) stati = dict(up=0, disabled=0, down=0, total=0) for agent in result: if (self.host == None or self.host == agent.host) and ( self.binary == None or self.binary == agent.binary): stati['total'] += 1 if agent.status == 'enabled' and agent.state == 'up': stati['up'] += 1 elif agent.status == 'disabled': stati['disabled'] += 1 else: stati['down'] += 1 for r in stati.keys(): yield osnag.Metric(r, stati[r], min=0)
def probe(self): try: neutron = client.Client('2.0', session=self.get_session(), ca_cert=self.openstack['cacert'], insecure=self.openstack['insecure']) except Exception as e: self.exit_error('cannot load ' + str(e)) try: if self.host and self.binary: result = neutron.list_agents(host=self.host, binary=self.binary) elif self.binary: result = neutron.list_agents(binary=self.binary) elif self.host: result = neutron.list_agents(host=self.host) else: result = neutron.list_agents() except Exception as e: self.exit_error(str(e)) stati = dict(up=0, disabled=0, down=0, total=0) for agent in result['agents']: stati['total'] += 1 if agent['admin_state_up'] and agent['alive']: stati['up'] += 1 elif not agent['admin_state_up']: stati['disabled'] += 1 else: stati['down'] += 1 for r in stati.keys(): yield osnag.Metric(r, stati[r], min=0)
def probe(self): try: keystone = ksclient.Client( username=self.openstack['username'], password=self.openstack['password'], tenant_name=self.openstack['tenant_name'], auth_url=self.openstack['auth_url'], insecure=self.openstack['insecure']) except Exception as e: self.exit_error('cannot get token ' + str(e)) try: neutron = client.Client( '2.0', endpoint_url=keystone.service_catalog.url_for( endpoint_type='public', service_type='network'), token=keystone.auth_token, insecure=self.openstack['insecure']) except Exception as e: self.exit_error('cannot load ' + str(e)) try: result = neutron.show_network_ip_availability(self.network_uuid) except Exception as e: self.exit_error(str(e)) net_ip = result['network_ip_availability'] stati = dict(total=0, used=0) stati['total'] = net_ip['total_ips'] stati['used'] = net_ip['used_ips'] for r in stati.keys(): yield osnag.Metric(r, stati[r], min=0)
def probe(self): try: auth = identity.Password(username = self.openstack['username'], password = self.openstack['password'], project_name=self.openstack['project_name'], user_domain_name=self.openstack['user_domain_name'], project_domain_name=self.openstack['project_domain_name'], auth_url=self.openstack['auth_url']) sess = session.Session(auth=auth) except Exception as e: self.exit_error('cannot get token ' + str(e)) try: neutron = client.Client(session=sess) except Exception as e: self.exit_error('cannot load ' + str(e)) try: result=neutron.list_floatingips() except Exception as e: self.exit_error(str(e)) stati=dict(assigned=0, used=0) for floatingip in result['floatingips']: stati['assigned'] += 1 if floatingip['fixed_ip_address']: stati['used'] += 1 for r in stati.keys(): yield osnag.Metric(r, stati[r], min=0)
def probe(self): try: nova = Client( '2', self.openstack['username'], self.openstack['password'], project_name=self.openstack['project_name'], user_domain_name=self.openstack['user_domain_name'], project_domain_name=self.openstack['project_domain_name'], auth_url=self.openstack['auth_url'], cacert=self.openstack['cacert'], insecure=self.openstack['insecure']) except Exception as e: self.exit_error(str(e)) try: result = nova.services.list(host=self.host, binary=self.binary) except Exception as e: self.exit_error(str(e)) stati = dict(up=0, disabled=0, down=0, total=0) for agent in result: stati['total'] += 1 if agent.status == 'enabled' and agent.state == 'up': stati['up'] += 1 elif agent.status == 'disabled': stati['disabled'] += 1 else: stati['down'] += 1 for r in stati.keys(): yield osnag.Metric(r, stati[r], min=0)
def probe(self): try: ceilometer = client.Client(self.api_version, session=self.session, region_name=self.region_name) except Exception as e: self.exit_error('cannot start ceil ' + str(e)) now = datetime.datetime.now(self.tzone) tstart = now - self.tframe query = [] query.append({'field': 'timestamp','op':'gt','value':tstart.strftime(date_format)}) try: teste = ceilometer.statistics.list(self.meter, q=query) #print "meters = %s" % ceilometer.meters.list() #print "resources = %s" % ceilometer.resources.list() #print "alarms = %s" % ceilometer.alarms.list() except Exception as e: self.exit_error('cannot load: ' + str(e)) for t in teste : period_end=self.tzone.localize(datetime.datetime.strptime(getattr(t,'period_end','')[:19],date_format)) age = now - period_end yield osnag.Metric('count', getattr(t,'count',''),uom='samples') yield osnag.Metric('age', age.total_seconds()/60, uom='m' ) yield osnag.Metric('value', getattr(t,self.aggregate,''), min=getattr(t,'min',''), max=getattr(t,'max',''), uom=getattr(t,'unit','')) if self.verbose: print print 'now: %s' % now.strftime(date_format_tz) print 'query start %s' % tstart.strftime(date_format_tz) print 'duration_start: %s' % getattr(t,'duration_start','') print 'period_start: %s' % getattr(t,'period_start','') print 'duration_end: %s' % getattr(t,'duration_end','') print 'period_end: %s' % period_end.strftime(date_format_tz) print 'age %s minutes' % str(age.total_seconds()/60) print 'count: %s samples' % getattr(t,'count','') print 'min: %s ' % getattr(t,'min','') + getattr(t,'unit','') print 'max: %s ' % getattr(t,'max','') + getattr(t,'unit','') print 'duration: %s minutes' % (int(getattr(t,'duration',''))/60) print 'avg: %s ' % getattr(t,'avg','') + getattr(t,'unit','') print 'sum: %s ' % getattr(t,'sum','') + getattr(t,'unit','') print
def probe(self): start = time.time() try: Client(session=self.session, region_name=self.region_name) except Exception as e: self.exit_error('cannot get token') get_time = time.time() yield osnag.Metric('gettime', get_time-start, min=0)
def probe(self): try: nova = Client( '2', self.openstack['username'], self.openstack['password'], project_name=self.openstack['project_name'], user_domain_name=self.openstack['user_domain_name'], project_domain_name=self.openstack['project_domain_name'], auth_url=self.openstack['auth_url'], cacert=self.openstack['cacert'], insecure=self.openstack['insecure']) except Exception as e: self.exit_error(str(e)) try: if self.host: result = nova.hypervisors.get( nova.hypervisors.find(hypervisor_hostname=self.host)) else: result = nova.hypervisors.statistics() except Exception as e: self.exit_error(str(e)) yield osnag.Metric('vcpus_used', result.vcpus_used, min=0, max=result.vcpus) yield osnag.Metric('vcpus_percent', 100 * result.vcpus_used / result.vcpus, min=0, max=100) yield osnag.Metric('memory_used', result.memory_mb_used, min=0, max=result.memory_mb) yield osnag.Metric('memory_percent', 100 * result.memory_mb_used / result.memory_mb, min=0, max=100) yield osnag.Metric('running_vms', result.running_vms, min=0)
def probe(self): start = time.time() try: nova = client.Client(self.api_version, session=self.session, region_name=self.region_name) images.GlanceManager(nova).list() except Exception as e: self.exit_error(str(e)) get_time = time.time() yield osnag.Metric('gettime', get_time-start, min=0)
def probe(self): start = time.time() try: panko = Client( session = self.get_session(), ) #print panko.event.list() except Exception as e: self.exit_error(str(e)) get_time = time.time() yield osnag.Metric('gettime', get_time-start, min=0)
def probe(self): start = time.time() try: glance = Client('2', session = self.get_session, ) glance.images.list() except Exception as e: self.exit_error(str(e)) get_time = time.time() yield osnag.Metric('gettime', get_time-start, min=0)
def probe(self): try: session_options = dict(auth=self.auth_plugin) adapter_options = dict(interface=self.interface, region_name=self.region_name) gnocchi = client.Client(self.api_version, adapter_options=adapter_options, session_options=session_options) except Exception as e: self.exit_error('cannot get client: ' + str(e)) status = gnocchi.status.get() measures = status.get('storage', {}).get('summary', {}).get('measures') yield osnag.Metric('measures_to_process', measures)
def probe(self): start = time.time() try: keystone=ksclient.Client(username = self.openstack['username'], password = self.openstack['password'], tenant_name = self.openstack['tenant_name'], auth_url = self.openstack['auth_url'], cacert = self.openstack['cacert'], insecure = self.openstack['insecure']) except Exception as e: self.exit_error('cannot get token') get_time = time.time() yield osnag.Metric('gettime', get_time-start, min=0)
def probe(self): try: keystone = client.Client(version=self.api_version, interface='public', session=self.session, region_name=self.region_name) except Exception as e: self.exit_error('cannot create keystone client: ' + str(e)) try: endpoints = keystone.endpoints.list() except Exception as e: self.exit_error('cannot get endpoints: ' + str(e)) yield osnag.Metric('endpoints', len(endpoints), min=0)
def probe(self): start = time.time() try: nova = Client('2', self.openstack['username'], self.openstack['password'], self.openstack['tenant_name'], auth_url=self.openstack['auth_url'], insecure=self.openstack['insecure']) nova.images.list() except Exception as e: self.exit_error(str(e)) get_time = time.time() yield osnag.Metric('gettime', get_time - start, min=0)
def probe(self): # Getting the Python Ironic client to talk SSL is a dark art # Use the command line client instead try: cmd = "ironic --json node-list --detail --associated=true" out = subprocess.check_output(cmd, shell=True) nodes = json.loads(out) except Exception as e: self.exit_error(str(e)) stati = dict(disabled=0, total=0) stati['total'] = len(nodes) disabled = [x for x in nodes if not x[u'console_enabled']] stati['disabled'] = len(disabled) for r in stati.keys(): yield osnag.Metric(r, stati[r], min=0)
def probe(self): try: keystone = ksclient.Client( username=self.openstack['username'], password=self.openstack['password'], tenant_name=self.openstack['tenant_name'], auth_url=self.openstack['auth_url'], cacert=self.openstack['cacert'], insecure=self.openstack['insecure']) except Exception as e: self.exit_error('cannot get token ' + str(e)) try: neutron = client.Client( '2.0', endpoint_url=keystone.service_catalog.url_for( endpoint_type='public', service_type='network'), token=keystone.auth_token, ca_cert=self.openstack['cacert'], insecure=self.openstack['insecure']) except Exception as e: self.exit_error('cannot load ' + str(e)) try: result = neutron.list_agents(host=self.host, binary=self.binary) except Exception as e: self.exit_error(str(e)) stati = dict(up=0, disabled=0, down=0, total=0) for agent in result['agents']: stati['total'] += 1 if agent['admin_state_up'] and agent['alive']: stati['up'] += 1 elif not agent['admin_state_up']: stati['disabled'] += 1 else: stati['down'] += 1 for r in stati.keys(): yield osnag.Metric(r, stati[r], min=0)
def probe(self): try: neutron = client.Client(self.api_version, session=self.session, region_name=self.region_name) except Exception as e: self.exit_error('cannot load ' + str(e)) try: result = neutron.show_network_ip_availability(self.network_uuid) except Exception as e: self.exit_error(str(e)) net_ip = result['network_ip_availability'] stati = dict(total=0, used=0) stati['total'] = net_ip['total_ips'] stati['used'] = net_ip['used_ips'] for r in stati.keys(): yield osnag.Metric(r, stati[r], min=0)
def probe(self): try: neutron = client.Client(self.api_version, session=self.session, region_name=self.region_name) except Exception as e: self.exit_error('cannot load ' + str(e)) try: result = neutron.list_floatingips() except Exception as e: self.exit_error(str(e)) stati = dict(assigned=0, used=0) for floatingip in result['floatingips']: stati['assigned'] += 1 if floatingip['fixed_ip_address']: stati['used'] += 1 for r in stati.keys(): yield osnag.Metric(r, stati[r], min=0)
def probe(self): try: k = ks.Client(username=self.openstack['username'], password=self.openstack['password'], tenant_name=self.openstack['tenant_name'], auth_url=self.openstack['auth_url'], cacert=self.openstack['cacert'], insecure=self.openstack['insecure']) except Exception as e: self.exit_error('cannot get token ' + str(e)) try: neutron = client.Client('2.0', endpoint_url=k.service_catalog.url_for( endpoint_type='public', service_type='network'), token=k.auth_token, ca_cert=self.openstack['cacert'], insecure=self.openstack['insecure']) except Exception as e: self.exit_error('cannot load ' + str(e)) try: result = neutron.list_routers() except Exception as e: self.exit_error(str(e)) stati = dict(active=0, down=0, build=0) for router in result['routers']: if router['status'] == 'ACTIVE': stati['active'] += 1 if router['status'] == 'DOWN': stati['down'] += 1 if router['status'] == 'BUILD': stati['build'] += 1 for r in stati.keys(): yield osnag.Metric(r, stati[r], min=0)
def probe(self): try: session_options = dict(auth=self.auth_plugin) adapter_options = dict(interface=self.interface, region_name=self.region_name) gnocchi = client.Client(self.api_version, adapter_options=adapter_options, session_options=session_options) except Exception as e: self.exit_error('cannot get client: ' + str(e)) now = datetime.utcnow() some_time_ago = now - self.since for resource_id in self.resources: measures = gnocchi.metric.get_measures(self.metric, resource_id=resource_id, start=some_time_ago) yield osnag.Metric(resource_id, len(measures), context='measures', min=0)