How to use the ceilometer.sample.TYPE_GAUGE function in ceilometer

To help you get started, we’ve selected a few ceilometer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstack / ceilometer / ceilometer / ipmi / notifications / ironic.py View on Github external
raise InvalidSensorData('missing key in payload: %s' % exc)

                info = self._package_payload(message, payload)

                try:
                    sensor_reading = info['payload']['Sensor Reading']
                except KeyError:
                    raise InvalidSensorData(
                        "missing 'Sensor Reading' in payload"
                    )

                if validate_reading(sensor_reading):
                    volume, unit = parse_reading(sensor_reading)
                    yield sample.Sample.from_notification(
                        name='hardware.ipmi.%s' % self.metric.lower(),
                        type=sample.TYPE_GAUGE,
                        unit=unit,
                        volume=volume,
                        resource_id=resource_id,
                        message=info,
                        user_id=info['user_id'],
                        project_id=info['project_id'],
                        timestamp=info['timestamp'])

            except InvalidSensorData as exc:
                LOG.warning(
                    'invalid sensor data for %(resource)s: %(error)s' %
                    dict(resource=resource_id, error=exc)
                )
                continue
github openstack / ceilometer / ceilometer / compute / notifications / instance.py View on Github external
def get_sample(self, message):
        yield sample.Sample.from_notification(
            name='instance',
            type=sample.TYPE_GAUGE,
            unit='instance',
            volume=1,
            user_id=message['payload']['user_id'],
            project_id=message['payload']['tenant_id'],
            resource_id=message['payload']['instance_id'],
            message=message)
github openstack / ceilometer / ceilometer / network / services / lbaas.py View on Github external
for listener in resources:
            LOG.debug("Load Balancer Listener : %s" % listener)
            status = self.get_load_balancer_status_id(
                listener['operating_status'])
            if status == -1:
                # unknown status, skip this sample
                LOG.warning(_("Unknown status %(stat)s received on listener "
                              "%(id)s, skipping sample")
                            % {'stat': listener['operating_status'],
                               'id': listener['id']})
                continue

            yield sample.Sample(
                name='network.services.lb.listener',
                type=sample.TYPE_GAUGE,
                unit='listener',
                volume=status,
                user_id=None,
                project_id=listener['tenant_id'],
                resource_id=listener['id'],
                resource_metadata=self.extract_metadata(listener)
            )
github openstack / ceilometer / ceilometer / ipmi / pollsters / node.py View on Github external
def read_data(self, cache):
        return self.nodemanager.read_inlet_temperature()


class OutletTemperaturePollster(_Base):
    NAME = "hardware.ipmi.node.outlet_temperature"
    TYPE = sample.TYPE_GAUGE
    UNIT = "C"

    def read_data(self, cache):
        return self.nodemanager.read_outlet_temperature()


class PowerPollster(_Base):
    NAME = "hardware.ipmi.node.power"
    TYPE = sample.TYPE_GAUGE
    UNIT = "W"

    def read_data(self, cache):
        return self.nodemanager.read_power_all()


class AirflowPollster(_Base):
    NAME = "hardware.ipmi.node.airflow"
    TYPE = sample.TYPE_GAUGE
    UNIT = "CFM"

    def read_data(self, cache):
        return self.nodemanager.read_airflow()


class CUPSIndexPollster(_Base):
github openstack / ceilometer / ceilometer / compute / notifications / instance.py View on Github external
def get_sample(self, message):
        yield sample.Sample.from_notification(
            name='instance',
            type=sample.TYPE_GAUGE,
            unit='instance',
            volume=1,
            user_id=message['payload']['user_id'],
            project_id=message['payload']['tenant_id'],
            resource_id=message['payload']['instance_id'],
            message=message)
github openstack / ceilometer / ceilometer / transformer / conversions.py View on Github external
def flush(self):
        if not self.initial_timestamp:
            return []

        expired = (self.retention_time and
                   timeutils.is_older_than(self.initial_timestamp,
                                           self.retention_time))
        full = self.size and self.aggregated_samples >= self.size
        if full or expired:
            x = list(self.samples.values())
            # gauge aggregates need to be averages
            for s in x:
                if s.type == sample.TYPE_GAUGE:
                    key = self._get_unique_key(s)
                    s.volume /= self.counts[key]
            self.samples.clear()
            self.counts.clear()
            self.aggregated_samples = 0
            self.initial_timestamp = None
            return x
        return []
github openstack / ceilometer / ceilometer / objectstore / swift.py View on Github external
def get_samples(self, manager, cache, resources):
        tenants = resources
        for tenant, account in self._iter_accounts(manager.keystone,
                                                   cache, tenants):
            yield sample.Sample(
                name='storage.objects.containers',
                type=sample.TYPE_GAUGE,
                volume=int(account['x-account-container-count']),
                unit='container',
                user_id=None,
                project_id=tenant,
                resource_id=tenant,
                resource_metadata=None,
            )
github openstack / ceilometer / ceilometer / network / floatingip.py View on Github external
def get_samples(self, manager, cache, resources):

        for fip in resources or []:
            if fip['status'] is None:
                LOG.warning("Invalid status, skipping IP address %s" %
                            fip['floating_ip_address'])
                continue
            status = self.get_status_id(fip['status'])
            yield sample.Sample(
                name='ip.floating',
                type=sample.TYPE_GAUGE,
                unit='ip',
                volume=status,
                user_id=fip.get('user_id'),
                project_id=fip['tenant_id'],
                resource_id=fip['id'],
                resource_metadata=self.extract_metadata(fip)
            )
github openstack / ceilometer / ceilometer / compute / pollsters / __init__.py View on Github external
class NoVolumeException(Exception):
    pass


class GenericComputePollster(plugin_base.PollsterBase):
    """This class aims to cache instance statistics data

    First polled pollsters that inherit of this will retrieve and cache
    stats of an instance, then other pollsters will just build the samples
    without queyring the backend anymore.
    """

    sample_name = None
    sample_unit = ''
    sample_type = sample.TYPE_GAUGE
    sample_stats_key = None
    inspector_method = None

    def setup_environment(self):
        super(GenericComputePollster, self).setup_environment()
        self.inspector = self._get_inspector(self.conf)

    @staticmethod
    def aggregate_method(stats):
        # Don't aggregate anything by default
        return stats

    @classmethod
    def _get_inspector(cls, conf):
        # FIXME(sileht): This doesn't looks threadsafe...
        try:
github openstack / ceilometer / ceilometer / image / glance.py View on Github external
def get_samples(self, manager, cache, resources):
        for image in resources:
            yield sample.Sample(
                name='image.size',
                type=sample.TYPE_GAUGE,
                unit='B',
                volume=image.size,
                user_id=None,
                project_id=image.owner,
                resource_id=image.id,
                resource_metadata=self.extract_image_metadata(image),
            )