Beispiel #1
0
 def generate_one_sample(host, c_data):
     return util.make_sample_from_host(host,
                                       name='cpu.load.5min',
                                       type=sample.TYPE_GAUGE,
                                       unit='process',
                                       volume=c_data.cpu_5_min,
                                       )
Beispiel #2
0
    def generate_samples(self, host_url, data):
        """Generate a list of Sample from the data returned by inspector

        :param host_url: host url of the endpoint
        :param data: list of data returned by the corresponding inspector
        """
        samples = []
        definition = self.meter_definition
        partition = self.conf.f5.partition
        for (value, metadata, extra) in data:
            name = metadata.get('name')
            if '/' + partition + '/' not in name:
                continue

            resource_id = name.split('/')[-1]
            s = util.make_sample_from_host(host_url,
                                           name=definition.name,
                                           sample_type=definition.type,
                                           unit=definition.unit,
                                           volume=value,
                                           resource_id=resource_id,
                                           res_metadata=metadata,
                                           name_prefix=None)
            samples.append(s)
        return samples
Beispiel #3
0
 def generate_one_sample(host, c_data):
     return util.make_sample_from_host(host,
                                       name='cpu.load.15min',
                                       type=sample.TYPE_GAUGE,
                                       unit='process',
                                       volume=c_data.cpu_15_min,
                                       )
Beispiel #4
0
 def generate_one_sample(host, c_data):
     return util.make_sample_from_host(host,
                                       name='cpu.util.15min',
                                       type=sample.TYPE_GAUGE,
                                       unit='%',
                                       volume=c_data.cpu_15_min,
                                       )
Beispiel #5
0
 def generate_one_sample(host, c_data):
     return util.make_sample_from_host(host,
                                       name='memory.used',
                                       type=sample.TYPE_GAUGE,
                                       unit='B',
                                       volume=c_data.used,
                                       )
Beispiel #6
0
 def generate_one_sample(host, c_data):
     return util.make_sample_from_host(
         host,
         name='cpu.util.5min',
         type=sample.TYPE_GAUGE,
         unit='%',
         volume=c_data.cpu_5_min,
     )
Beispiel #7
0
 def generate_one_sample(host, c_data):
     return util.make_sample_from_host(
         host,
         name='memory.used',
         type=sample.TYPE_GAUGE,
         unit='B',
         volume=c_data.used,
     )
Beispiel #8
0
 def generate_one_sample(host, c_data):
     (nic, info) = c_data
     return util.make_sample_from_host(host,
                                       name='network.incoming.bytes',
                                       type=sample.TYPE_CUMULATIVE,
                                       unit='B',
                                       volume=info.rx_bytes,
                                       res_metadata=nic,
                                       )
Beispiel #9
0
 def generate_one_sample(host, c_data):
     (volt, info) = c_data
     return util.make_sample_from_host(host,
                                       name='volt.status.current',
                                       type=sample.TYPE_GAUGE,
                                       unit='B',
                                       volume=info.status,
                                       res_metadata=volt,
                                       )
Beispiel #10
0
 def generate_one_sample(host, c_data):
     (nic, info) = c_data
     return util.make_sample_from_host(host,
                                       name='network.outgoing.errors',
                                       type=sample.TYPE_CUMULATIVE,
                                       unit='packet',
                                       volume=info.error,
                                       res_metadata=nic,
                                       )
Beispiel #11
0
 def generate_one_sample(host, c_data):
     (degree, info) = c_data
     return util.make_sample_from_host(host,
                                       name='degree.temperature.current',
                                       type=sample.TYPE_GAUGE,
                                       unit='B',
                                       volume=info.temperature,
                                       res_metadata=degree,
                                       )
Beispiel #12
0
 def generate_one_sample(host, c_data):
     (disk, info) = c_data
     return util.make_sample_from_host(host,
                                       name='disk.size.used',
                                       type=sample.TYPE_GAUGE,
                                       unit='B',
                                       volume=info.used,
                                       res_metadata=disk,
                                       )
Beispiel #13
0
 def generate_one_sample(self, host, c_data):
     value, metadata, extra = c_data
     return util.make_sample_from_host(host,
                                       name=self.IDENTIFIER,
                                       sample_type=sample.TYPE_GAUGE,
                                       unit='process',
                                       volume=value,
                                       res_metadata=metadata,
                                       extra=extra)
Beispiel #14
0
 def generate_one_sample(host, c_data):
     (nic, info) = c_data
     return util.make_sample_from_host(
         host,
         name='network.outgoing.errors',
         type=sample.TYPE_CUMULATIVE,
         unit='packet',
         volume=info.error,
         res_metadata=nic,
     )
Beispiel #15
0
 def generate_one_sample(host, c_data):
     (nic, info) = c_data
     return util.make_sample_from_host(
         host,
         name='network.incoming.bytes',
         type=sample.TYPE_CUMULATIVE,
         unit='B',
         volume=info.rx_bytes,
         res_metadata=nic,
     )
Beispiel #16
0
 def generate_one_sample(host, c_data):
     (volt, info) = c_data
     return util.make_sample_from_host(
         host,
         name='volt.voltage.current',
         type=sample.TYPE_GAUGE,
         unit='B',
         volume=info.voltage,
         res_metadata=volt,
     )
Beispiel #17
0
 def generate_one_sample(host, c_data):
     (degree, info) = c_data
     return util.make_sample_from_host(
         host,
         name='degree.temperature.current',
         type=sample.TYPE_GAUGE,
         unit='B',
         volume=info.temperature,
         res_metadata=degree,
     )
Beispiel #18
0
 def generate_one_sample(host, c_data):
     (rpm, info) = c_data
     return util.make_sample_from_host(
         host,
         name='rpm.status.current',
         type=sample.TYPE_GAUGE,
         unit='B',
         volume=info.status,
         res_metadata=rpm,
     )
Beispiel #19
0
 def generate_one_sample(host, c_data):
     (disk, info) = c_data
     return util.make_sample_from_host(
         host,
         name='disk.size.used',
         type=sample.TYPE_GAUGE,
         unit='B',
         volume=info.used,
         res_metadata=disk,
     )
Beispiel #20
0
 def test_make_sample_extra(self):
     extra = {'project_id': 'project', 'resource_id': 'resource'}
     s = util.make_sample_from_host(self.host_url,
                                    name='test',
                                    sample_type=sample.TYPE_GAUGE,
                                    unit='B',
                                    volume=1,
                                    extra=extra)
     self.assertEqual(None, s.user_id)
     self.assertEqual('project', s.project_id)
     self.assertEqual('resource', s.resource_id)
Beispiel #21
0
 def test_make_sample(self):
     s = util.make_sample_from_host(self.host_url,
                                    name='test',
                                    sample_type=sample.TYPE_GAUGE,
                                    unit='B',
                                    volume=1,
                                    res_metadata={
                                        'metakey': 'metaval',
                                    })
     self.assertEqual('127.0.0.1', s.resource_id)
     self.assertIn('snmp://127.0.0.1:161', s.resource_metadata.values())
     self.assertIn('metakey', s.resource_metadata.keys())
Beispiel #22
0
 def test_make_sample(self):
     s = util.make_sample_from_host(self.host_url,
                                    name='test',
                                    sample_type=sample.TYPE_GAUGE,
                                    unit='B',
                                    volume=1,
                                    res_metadata={
                                        'metakey': 'metaval',
                                    })
     self.assertEqual('127.0.0.1', s.resource_id)
     self.assertIn('snmp://127.0.0.1:161', s.resource_metadata.values())
     self.assertIn('metakey', s.resource_metadata.keys())
Beispiel #23
0
 def generate_one_sample(self, host, c_data):
     value, metadata, extra = c_data
     res_id = host.hostname
     if metadata.get('name'):
         res_id = res_id + ".%s" % metadata.get('name')
     return util.make_sample_from_host(host,
                                       name=self.IDENTIFIER,
                                       sample_type=sample.TYPE_CUMULATIVE,
                                       unit=self.unit,
                                       volume=value,
                                       res_metadata=metadata,
                                       extra=extra,
                                       resource_id=res_id)
Beispiel #24
0
 def generate_one_sample(self, host, c_data):
     value, metadata, extra = c_data
     res_id = extra.get('resource_id') or host.hostname
     if metadata.get('device'):
         res_id = res_id + ".%s" % metadata.get('device')
     return util.make_sample_from_host(host,
                                       name=self.IDENTIFIER,
                                       sample_type=sample.TYPE_GAUGE,
                                       unit='KB',
                                       volume=value,
                                       res_metadata=metadata,
                                       extra=extra,
                                       resource_id=res_id)
Beispiel #25
0
 def test_make_sample_extra(self):
     extra = {
         'project_id': 'project',
         'resource_id': 'resource'
     }
     s = util.make_sample_from_host(self.host_url,
                                    name='test',
                                    sample_type=sample.TYPE_GAUGE,
                                    unit='B',
                                    volume=1,
                                    extra=extra)
     self.assertEqual(None, s.user_id)
     self.assertEqual('project', s.project_id)
     self.assertEqual('resource', s.resource_id)
Beispiel #26
0
 def test_make_sample_extra(self):
     extra = {'project_id': 'project', 'resource_id': 'resource'}
     s = util.make_sample_from_host(self.host_url,
                                    name='test',
                                    sample_type=sample.TYPE_GAUGE,
                                    unit='B',
                                    volume=1,
                                    extra=extra)
     self.assertIsNone(s.user_id)
     self.assertEqual('project', s.project_id)
     self.assertEqual('resource', s.resource_id)
     self.assertEqual(
         {
             'resource_url': 'snmp://127.0.0.1:161',
             'project_id': 'project',
             'resource_id': 'resource'
         }, s.resource_metadata)
Beispiel #27
0
    def generate_samples(self, host_url, data):
        """Generate a list of Sample from the data returned by inspector

        :param host_url: host url of the endpoint
        :param data: list of data returned by the corresponding inspector
        """
        samples = []
        definition = self.meter_definition
        for (value, metadata, extra) in data:
            s = util.make_sample_from_host(host_url,
                                           name=definition.name,
                                           sample_type=definition.type,
                                           unit=definition.unit,
                                           volume=value,
                                           res_metadata=metadata,
                                           extra=extra,
                                           name_prefix=None)
            samples.append(s)
        return samples
Beispiel #28
0
    def generate_samples(self, host_url, data):
        """Generate a list of Sample from the data returned by inspector

        :param host_url: host url of the endpoint
        :param data: list of data returned by the corresponding inspector
        """
        samples = []
        definition = self.meter_definition
        for (value, metadata, extra) in data:
            s = util.make_sample_from_host(host_url,
                                           name=definition.name,
                                           sample_type=definition.type,
                                           unit=definition.unit,
                                           volume=value,
                                           res_metadata=metadata,
                                           extra=extra,
                                           name_prefix=None)
            samples.append(s)
        return samples
Beispiel #29
0
 def test_make_sample_extra(self):
     extra = {
         'project_id': 'project',
         'resource_id': 'resource'
     }
     s = util.make_sample_from_host(self.host_url,
                                    name='test',
                                    sample_type=sample.TYPE_GAUGE,
                                    unit='B',
                                    volume=1,
                                    extra=extra)
     self.assertIsNone(s.user_id)
     self.assertEqual('project', s.project_id)
     self.assertEqual('resource', s.resource_id)
     self.assertEqual({'resource_url': 'snmp://127.0.0.1:161',
                       'project_id': 'project',
                       'resource_id':
                       'resource'},
                      s.resource_metadata)
Beispiel #30
0
    def generate_samples(self, host_url, data):
        """Generate a list of Sample from the data returned by inspector

        :param host_url: host url of the endpoint
        :param data: list of data returned by the corresponding inspector
        """
        samples = []
        definition = self.meter_definition
        for (value, metadata, extra) in data:
            name = metadata.get('name')
            if 'NECTAR_RC' not in name:
                continue

            resource_id = name.split('/')[-1]
            s = util.make_sample_from_host(host_url,
                                           name=definition.name,
                                           sample_type=definition.type,
                                           unit=definition.unit,
                                           volume=value,
                                           resource_id=resource_id,
                                           res_metadata=metadata,
                                           name_prefix=None)
            samples.append(s)
        return samples