Exemple #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,
                                       )
Exemple #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
Exemple #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,
                                       )
Exemple #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,
                                       )
Exemple #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,
                                       )
Exemple #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,
     )
Exemple #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,
     )
Exemple #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,
                                       )
Exemple #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,
                                       )
Exemple #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,
                                       )
Exemple #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,
                                       )
Exemple #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,
                                       )
Exemple #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)
Exemple #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,
     )
Exemple #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,
     )
Exemple #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,
     )
Exemple #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,
     )
Exemple #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,
     )
Exemple #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,
     )
Exemple #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)
Exemple #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())
Exemple #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())
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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
Exemple #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
Exemple #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)
Exemple #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