Esempio n. 1
0
    def get_samples(self, manager, cache, resources):
        stats = self.ipmi.read_sensor_any(self.METRIC)

        sensor_type_data = self._get_sensor_types(stats, self.METRIC)

        for sensor_data in sensor_type_data:
            try:
                sensor_reading = sensor_data["Sensor Reading"]
            except KeyError:
                raise InvalidSensorData("missing 'Sensor Reading'")

            if not parser.validate_reading(sensor_reading):
                continue

            volume, unit = parser.parse_reading(sensor_reading)

            resource_id = "%(host)s-%(sensor-id)s" % {
                "host": CONF.host,
                "sensor-id": parser.transform_id(sensor_data["Sensor ID"]),
            }

            yield sample.Sample(
                name="hardware.ipmi.%s" % self.METRIC.lower(),
                type=sample.TYPE_GAUGE,
                unit=unit,
                volume=volume,
                user_id=None,
                project_id=None,
                resource_id=resource_id,
                timestamp=timeutils.utcnow().isoformat(),
                resource_metadata=None,
            )
Esempio n. 2
0
    def get_samples(self, manager, cache, resources):
        stats = self.ipmi.read_sensor_any(self.METRIC)

        sensor_type_data = self._get_sensor_types(stats, self.METRIC)

        for sensor_data in sensor_type_data:
            try:
                sensor_reading = sensor_data['Sensor Reading']
            except KeyError:
                raise InvalidSensorData("missing 'Sensor Reading'")

            if not parser.validate_reading(sensor_reading):
                continue

            volume, unit = parser.parse_reading(sensor_reading)

            resource_id = '%(host)s-%(sensor-id)s' % {
                'host': CONF.host,
                'sensor-id': parser.transform_id(sensor_data['Sensor ID'])
            }

            yield sample.Sample(name='hardware.ipmi.%s' % self.METRIC.lower(),
                                type=sample.TYPE_GAUGE,
                                unit=unit,
                                volume=volume,
                                user_id=None,
                                project_id=None,
                                resource_id=resource_id,
                                timestamp=timeutils.utcnow().isoformat(),
                                resource_metadata=None)
Esempio n. 3
0
    def get_samples(self, manager, cache, resources):
        # Only one resource for IPMI pollster
        try:
            stats = self.ipmi.read_sensor_any(self.METRIC)
        except ipmiexcept.IPMIException:
            self.polling_failures += 1
            LOG.warning(_(
                'Polling %(mtr)s sensor failed for %(cnt)s times!')
                % ({'mtr': self.METRIC,
                    'cnt': self.polling_failures}))
            if (CONF.ipmi.polling_retry >= 0 and
                    self.polling_failures > CONF.ipmi.polling_retry):
                LOG.warning(_('Pollster for %s is disabled!') % self.METRIC)
                raise plugin_base.PollsterPermanentError(resources[0])
            else:
                return

        self.polling_failures = 0

        sensor_type_data = self._get_sensor_types(stats, self.METRIC)

        for sensor_data in sensor_type_data:
            # Continue if sensor_data is not parseable.
            try:
                sensor_reading = sensor_data['Sensor Reading']
                sensor_id = sensor_data['Sensor ID']
            except KeyError:
                continue

            if not parser.validate_reading(sensor_reading):
                continue

            try:
                volume, unit = parser.parse_reading(sensor_reading)
            except parser.InvalidSensorData:
                continue

            resource_id = '%(host)s-%(sensor-id)s' % {
                'host': CONF.host,
                'sensor-id': parser.transform_id(sensor_id)
            }

            metadata = {
                'node': CONF.host
            }

            yield sample.Sample(
                name='hardware.ipmi.%s' % self.METRIC.lower(),
                type=sample.TYPE_GAUGE,
                unit=unit,
                volume=volume,
                user_id=None,
                project_id=None,
                resource_id=resource_id,
                timestamp=timeutils.utcnow().isoformat(),
                resource_metadata=metadata)
Esempio n. 4
0
    def get_samples(self, manager, cache, resources):
        # Only one resource for IPMI pollster
        try:
            stats = self.ipmi.read_sensor_any(self.METRIC)
        except ipmiexcept.IPMIException:
            self.polling_failures += 1
            LOG.warning(
                _('Polling %(mtr)s sensor failed for %(cnt)s times!') %
                ({
                    'mtr': self.METRIC,
                    'cnt': self.polling_failures
                }))
            if (CONF.ipmi.polling_retry >= 0
                    and self.polling_failures > CONF.ipmi.polling_retry):
                LOG.warning(_('Pollster for %s is disabled!') % self.METRIC)
                raise plugin_base.PollsterPermanentError(resources[0])
            else:
                return

        self.polling_failures = 0

        sensor_type_data = self._get_sensor_types(stats, self.METRIC)

        for sensor_data in sensor_type_data:
            # Continue if sensor_data is not parseable.
            try:
                sensor_reading = sensor_data['Sensor Reading']
                sensor_id = sensor_data['Sensor ID']
            except KeyError:
                continue

            if not parser.validate_reading(sensor_reading):
                continue

            try:
                volume, unit = parser.parse_reading(sensor_reading)
            except parser.InvalidSensorData:
                continue

            resource_id = '%(host)s-%(sensor-id)s' % {
                'host': CONF.host,
                'sensor-id': parser.transform_id(sensor_id)
            }

            metadata = {'node': CONF.host}

            yield sample.Sample(name='hardware.ipmi.%s' % self.METRIC.lower(),
                                type=sample.TYPE_GAUGE,
                                unit=unit,
                                volume=volume,
                                user_id=None,
                                project_id=None,
                                resource_id=resource_id,
                                timestamp=timeutils.utcnow().isoformat(),
                                resource_metadata=metadata)
Esempio n. 5
0
    def get_samples(self, manager, cache, resources):
        stats = self.ipmi.read_sensor_any(self.METRIC)

        sensor_type_data = self._get_sensor_types(stats, self.METRIC)

        for sensor_data in sensor_type_data:
            # Continue if sensor_data is not parseable.
            try:
                sensor_reading = sensor_data['Sensor Reading']
                sensor_id = sensor_data['Sensor ID']
            except KeyError:
                continue

            if not parser.validate_reading(sensor_reading):
                continue

            try:
                volume, unit = parser.parse_reading(sensor_reading)
            except parser.InvalidSensorData:
                continue

            resource_id = '%(host)s-%(sensor-id)s' % {
                'host': CONF.host,
                'sensor-id': parser.transform_id(sensor_id)
            }

            metadata = {
                'node': CONF.host
            }

            yield sample.Sample(
                name='hardware.ipmi.%s' % self.METRIC.lower(),
                type=sample.TYPE_GAUGE,
                unit=unit,
                volume=volume,
                user_id=None,
                project_id=None,
                resource_id=resource_id,
                timestamp=timeutils.utcnow().isoformat(),
                resource_metadata=metadata)