def info_metrics(self):
        """
        Return a list of information tags for the PV Supervisor
        """
        network_status = self.communication_interfaces
        interface_info = InfoMetricFamily(
            name="sunpower_pvs_communication_interface",
            documentation="Communications Interface Information",
        )

        for comm in network_status.get("interfaces", []):
            value = dict(interface=comm["interface"],
                         internet=comm["internet"],
                         sms=comm["sms"],
                        )
            interface_info.add_metric(labels=[], value=value)

        grid_profile = self.grid_profile
        value = None
        if grid_profile:
            value = dict(id=grid_profile["active_id"],
                         name=grid_profile["active_name"],
                         percent=str(grid_profile["percent"]),
                         status=grid_profile["status"],
                        )
        grid_info = InfoMetricFamily(
            name="sunpower_pvs_grid_profile",
            documentation="Grid Profile",
            value=value,
        )

        return [dict(key="interface_info", metric=interface_info),
                dict(key="grid_profile", metric=grid_info)
               ]
Esempio n. 2
0
    def collect(self):
        yield InfoMetricFamily('smartmon', 'smartmontools information',
                               get_smartctl_version_info())

        dev_info_labels = [
            'device',
            'type',
            'protocol',
            'model_family',
            'serial_number',
            'wwn',
            'firmware_version',
        ]
        dev_info_metric = InfoMetricFamily('smartmon_device',
                                           'S.M.A.R.T. device information')

        metrics = gen_metrics()
        attr_metrics = gen_attr_metrics()
        nvme_metrics = gen_nvme_metrics()

        for dev in get_devices():
            get_device_metrics(dev, dev_info_metric, dev_info_labels, metrics,
                               attr_metrics, nvme_metrics)

        yield dev_info_metric
        yield from (x[0] for x in metrics)
        yield from (x[0] for x in attr_metrics.values())
        yield from (x[0] for x in nvme_metrics)
Esempio n. 3
0
    def collect(self):

        # Collect exporter information
        version = get_version()
        local_time = time.localtime()
        formatted_local_time = time.strftime('%Y-%m-%d %H.%M.%S', local_time)

        try:
            if local_time[8]:
                local_tzname = time.tzname[1]
            else:
                local_tzname = time.tzname[0]
        except AttributeError:
            local_tzname = 'UNKNOWN'

        # Update Prometheus metrics
        c = CounterMetricFamily(
            'mqa_exporter_current_datetime_seconds',
            'The current date and time of the server on which the exporter is running in epoch seconds ',
            labels=['appliance'])
        c.add_metric([self.appliance],
                     datetime_to_epoch(formatted_local_time,
                                       '%Y-%m-%d %H.%M.%S'))
        yield c

        i = InfoMetricFamily('mqa_exporter',
                             'MQ Appliance exporter information')
        i.add_metric(
            ['appliance', 'version', 'localTimezone'], {
                'appliance': self.appliance,
                'version': version,
                'localTimezone': local_tzname
            })
        yield i
Esempio n. 4
0
    def collect(self):
        info = self.rpc.getinfo()
        info_labels = {
            k.replace('-', '_'): v
            for k, v in info.items() if isinstance(v, str)
        }
        node_info_fam = InfoMetricFamily(
            'lightning_node',
            'Static node information',
            labels=info_labels.keys(),
        )
        node_info_fam.add_metric(info_labels, info_labels)
        yield node_info_fam

        blockheight = info['blockheight']
        yield GaugeMetricFamily(
            'lightning_node_blockheight',
            "Current Bitcoin blockheight on this node.",
            value=blockheight,
        )

        fees_msat = info["msatoshi_fees_collected"]
        yield GaugeMetricFamily(
            'lightning_fees_collected_msat',
            'How much have we been paid to route payments?',
            value=fees_msat,
        )
    def collect(self):
        """
        Collect the metrics.

        Collect the metrics and yield them. Prometheus client library
        uses this method to respond to http queries or save them to disk.
        """
        gauge = GaugeMetricFamily('node_net_ethtool',
                                  'Ethtool data',
                                  labels=['device', 'type'])
        basic_info = InfoMetricFamily('node_net_ethtool',
                                      'Ethtool device information',
                                      labels=['device'])
        xcvr_info = InfoMetricFamily('node_net_ethtool_xcvr',
                                     'Ethtool device transceiver information',
                                     labels=['device'])
        sensors = GaugeMetricFamily('node_net_ethtool_xcvr_sensors',
                                    'Ethtool transceiver sensors',
                                    labels=['device', 'type'])
        alarms = GaugeMetricFamily('node_net_ethtool_xcvr_alarms',
                                   'Ethtool transceiver sensor alarms',
                                   labels=['device', 'type'])
        for iface in self.find_physical_interfaces():
            self.update_ethtool_stats(iface, gauge)
            self.update_basic_info(iface, basic_info)
            self.update_xcvr_info(iface, xcvr_info, sensors, alarms)
        yield basic_info
        yield xcvr_info
        yield sensors
        yield alarms
        yield gauge
Esempio n. 6
0
    def collect(self):
        name = "dfinity"

        if time.time() - self.time > self.cache_timeout:
            self.cache = {}
            self.time = time.time()

        if name not in self.cache:
            try:
                response = requests.get(url=self.url,
                                        verify=False,
                                        stream=False,
                                        timeout=5)
            except requests.Timeout:
                pass
            except requests.ConnectionError:
                pass

            self.cache[name] = response.json()

        metric_counter = CounterMetricFamily(
            "repo__{}__tags_".format(name),
            "Repo `{}` tags total".format(name),
            labels=['tags'])
        metric_counter.add_metric([name], len(self.cache[name]["versions"]))
        yield metric_counter

        metric_info = InfoMetricFamily("repo__{}__tag".format(name),
                                       "Repo `{}` tag".format(name))
        metric_info.add_metric(["tag"],
                               {'name': self.cache[name]["tags"]["latest"]})
        yield metric_info
Esempio n. 7
0
    def info_collector(name, decription, router_records, metric_labels=[]):
        BaseCollector._add_id_labels(metric_labels)
        collector = InfoMetricFamily(f'mktxp_{name}', decription)

        for router_record in router_records:
            label_values = {label: router_record.get(label) if router_record.get(label) else '' for label in metric_labels}
            collector.add_metric(metric_labels, label_values)
        return collector
Esempio n. 8
0
 def test_info_labels(self):
     cmf = InfoMetricFamily('i', 'help', labels=['a'])
     cmf.add_metric(['b'], {'c': 'd'})
     self.custom_collector(cmf)
     self.assertEqual(
         1, self.registry.get_sample_value('i_info', {
             'a': 'b',
             'c': 'd'
         }))
Esempio n. 9
0
    def collect(self):
        logger.info(f'{self.name} starts with collecting the metrics')

        for entry in self.custom_metrics:
            custom_info_metric = InfoMetricFamily(entry['metric'],
                                                  'vrops-exporter',
                                                  labels=['target'])
            custom_info_metric.add_metric(labels=[self.target],
                                          value=entry['values_dict'])
            yield custom_info_metric
Esempio n. 10
0
 def collect(self):
     info = self.rpc.getinfo()
     info_labels = {k: v for k, v in info.items() if isinstance(v, str)}
     node_info_fam = InfoMetricFamily(
         'node',
         'Static node information',
         labels=info_labels.keys(),
     )
     node_info_fam.add_metric(info_labels, info_labels)
     yield node_info_fam
Esempio n. 11
0
    def collect(self):
        """
        Rundeck system info
        """
        system_info = self.request_data_from('/system/info')
        api_version = system_info['system']['rundeck']['apiversion']
        rundeck_system_info = InfoMetricFamily('rundeck_system',
                                               'Rundeck system info')
        rundeck_system_info.add_metric(
            [],
            {x: str(y)
             for x, y in system_info['system']['rundeck'].items()})
        yield rundeck_system_info
        """
        Rundeck system stats
        """
        for system_stats in self.get_system_stats(system_info):
            yield system_stats
        """
        Rundeck counters
        """
        if api_version >= self.args.rundeck_api_version < 25:
            logging.warning(
                f'Unsupported API version "{self.args.rundeck_api_version}" ' +
                f'for API request: /api/{self.args.rundeck_api_version}/metrics/metrics. '
                + 'Minimum supported version is 25')
        else:
            metrics = self.request_data_from('/metrics/metrics')

            for counters in self.get_counters(metrics):
                yield counters
        """
        Rundeck projects executions info
        """
        if self.args.rundeck_projects_executions:
            endpoint = '/projects'

            if self.args.rundeck_projects_filter:
                projects = [{
                    "name": x
                } for x in self.args.rundeck_projects_filter]
            else:
                if self.args.rundeck_projects_executions_cache:
                    projects = self.cached_request_data_from(endpoint)
                else:
                    projects = self.request_data_from(endpoint)

            with ThreadPoolExecutor() as threadpool:
                project_executions = threadpool.map(
                    self.get_project_executions, projects)

                for executions in project_executions:
                    for execution in executions:
                        if execution is not None:
                            yield execution
Esempio n. 12
0
    def collect(self):
        """
           Date time range within the executions has run
        """
        dt_range = datime_range.DateTimeRange()
        time_range = dt_range.datetime_range_to_timestamp(self.args.rundeck_executions_time_range)

        """
        Metrics Requests
        """
        metrics = self.request_data_from('/metrics/metrics')
        system_info = self.request_data_from('/system/info')

        """
        Rundeck system info
        """
        rundeck_system_info = InfoMetricFamily('rundeck_system', 'Rundeck system info')
        rundeck_system_info.add_metric([], {x: str(y) for x, y in system_info['system']['rundeck'].items()})
        yield rundeck_system_info

        """
        Rundeck system stats
        """
        for system_stats in self.get_system_stats(system_info):
            yield system_stats

        """
        Rundeck counters
        """
        for counters in self.get_counters(metrics):
            yield counters

        """
        Rundeck projects executions info
        """
        if self.args.rundeck_projects_executions:
            endpoint = '/projects'

            if self.args.rundeck_projects_filter:
                projects = [{"name": x} for x in self.args.rundeck_projects_filter]
            else:
                if self.args.rundeck_projects_executions_cache:
                    projects = self.cached_request_data_from(endpoint)
                else:
                    projects = self.request_data_from(endpoint)

            with ThreadPoolExecutor() as threadpool:

                project_executions = threadpool.map(self.get_project_executions, projects, time_range)

                for executions in project_executions:
                    for execution in executions:
                        if execution is not None:
                            yield(execution)
Esempio n. 13
0
    def test_info_timestamps(self):
        families = text_string_to_metric_families("""# TYPE a info
# HELP a help
a_info{a="1",foo="bar"} 1 1
a_info{a="2",foo="bar"} 1 0
# EOF
""")
        imf = InfoMetricFamily("a", "help")
        imf.add_sample("a_info", {"a": "1", "foo": "bar"}, 1, Timestamp(1, 0))
        imf.add_sample("a_info", {"a": "2", "foo": "bar"}, 1, Timestamp(0, 0))
        self.assertEqual([imf], list(families))
Esempio n. 14
0
 def get_metric_exporter_info(self):
     """ Information about the exporter """
     m = InfoMetricFamily(
         'crypto_exporter',
         f'Information about {__package__}',
         labels=['exchange', 'version', 'build']
     )
     m.add_metric(
         value={'version': f'{constants.VERSION}', 'build': f'{constants.BUILD}'},
         labels=[f'{self.exchange.exchange}'],
     )
     return m
    def _process_info(data: Union[Dict, List[Dict]],
                      label: str) -> List[InfoMetricFamily]:
        i = InfoMetricFamily(f'patroni_{label}', f'{label} info')

        # to ensure we have an iterable of dicts
        # the info datasets are different, some are lists of dicts,
        # some are dict only
        if not isinstance(data, (list, tuple)):
            data = [data]

        for dataset in data:
            i.add_metric([], {k: str(v) for k, v in dataset.items()})
        return [i]
Esempio n. 16
0
	def collect(self, describing=False):
		if not describing: 
			cli = CoAPAirClient(self.ip)
			status = cli.get_status()

			if "name" not in status:
				return
			labels = [self.ip, status["name"]]

		label_names = ["device_hostname", "name"]

		device_info = InfoMetricFamily('air_purifier_device_info', 'Air Purifier Device Information', labels=label_names)
		if not describing:
			device_info.add_metric(labels, {
				"type": status["type"],
				"mode": status["mode"],
				"model": status["modelid"],
				"software_version": status["swversion"],
				"wifi_version": status["WifiVersion"],
				"product_id": status["ProductId"],
				"device_id": status["DeviceId"],
				"status_type": status["StatusType"],
				"connect_type": status["ConnectType"],
			})
		yield device_info

		def gauge(name, desc, field_name, xfrm=lambda x: x):
			if not describing and field_name not in status:
				return None
			g = GaugeMetricFamily("air_purifier_" + name, "Air Purifiier " + desc, labels=label_names)
			if not describing:
				g.add_metric(labels, xfrm(status[field_name]))
			yield g

		yield from gauge("runtime", "running time", "runtime", lambda x: x/1000)
		yield from gauge("on", "powered on", "pwr")

		def fan_speed_xfrm(om):
			if om == "s":
				fan_speed = 0
			elif om == "t":
				fan_speed = 9
			else:
				fan_speed = int(om)
			return fan_speed
		yield from gauge("fan_speed", "fan speed setting", "om", fan_speed_xfrm)
		yield from gauge("pm25", "PM 2.5 level ug/m3","pm25")
		yield from gauge("iaql", "Indoor Air Quality Index", "iaql")
		yield from gauge("pre_filter_time_til_clean", "Pre filter hours remaining", "fltsts0")
		yield from gauge("hepa_filter_time_til_replace", "Pre filter hours remaining", "fltsts1")
		yield from gauge("carbon_filter_time_til_replace", "Carbon filter hours remaining", "fltsts2")
    def get_info_metrics(self, result):
        metric = InfoMetricFamily(
            'dkron_info',
            'Dkron job info',
            labels=["jobname"])

        for job in result:
            name = job['name']
            # If there's a null result, we want to export a zero.
            owner = job.get('owner')
            owner_email = job.get('owner_email')
            metric.add_metric([name], {'owner': owner, 'owner_email': owner_email})
            # job_status = job['status']
        return metric
Esempio n. 18
0
    def __init__(self, metric: Iterable[Metric]):
        """Computes the feature metadata from a list of collected feature histograms.

        :param metric: A list of Prometheus metrics returned from FeatureHistogramCollector
        :type metric: Iterable[Metric]
        """
        self.metric = InfoMetricFamily(
            name="baseline_metrics",
            documentation="Metadata about the baseline training metrics",
            labels=["feature_name", "metric_name", "metric_type"],
        )
        for m in metric:
            start = m.documentation.find(":") + 1
            name = m.documentation[start:].strip()
            self.metric.add_metric(labels=[name, m.name, m.type], value={})
Esempio n. 19
0
    def generate_infos(self, calling_class, vrops_entity_name, labelnames):
        if not isinstance(labelnames, list):
            print("Can't generate Gauges without label list, called from",
                  calling_class)
            return {}
        properties_yaml = self.read_collector_config()['properties']
        if 'info_metrics' in properties_yaml[calling_class]:
            infos = dict()
            for property_pair in properties_yaml[calling_class][
                    'info_metrics']:
                property_suffix = property_pair['metric_suffix']
                infos[property_suffix] = {
                    'info':
                    InfoMetricFamily('vrops_' + vrops_entity_name + '_' +
                                     property_suffix.lower(),
                                     'vrops-exporter',
                                     labels=labelnames),
                    'property':
                    property_pair['property']
                }
            return infos

        if os.environ['DEBUG'] >= '1':
            print("No Info metric type generated, from", calling_class)
        return {}
Esempio n. 20
0
  def add_node_metrics(self):
    self.get_node_data()
    if self.node_data:
      labels          = ['type']
      metric_family   = GaugeMetricFamily

      metric_name     = 'storj_node'
      data            = self.node_data
      documentation   = 'Storj node info'
      keys            = ['nodeID','wallet','lastPinged','upToDate','version','allowedVersion','startedAt']
      yield from self.dict_to_metric(data, metric_name, documentation, InfoMetricFamily, keys, labels) 

      metric_name     = 'storj_total_diskspace'
      data            = self.node_data.get('diskSpace', None)
      documentation   = 'Storj total diskspace metrics'
      keys            = ['used','available','trash']
      yield from self.dict_to_metric(data, metric_name, documentation, metric_family, keys, labels)

      data            = self.node_data.get('bandwidth', None)
      metric_name     = 'storj_total_bandwidth'
      documentation   = 'Storj total bandwidth metrics'
      keys            = ['used','available']
      yield from self.dict_to_metric(data, metric_name, documentation, metric_family, keys, labels)

      ## to be deprecated
      for key in ['nodeID','wallet','lastPinged','upToDate','version','allowedVersion','startedAt']:
        if key in self.node_data:
          value = str(self.node_data[key])
          metric = InfoMetricFamily('storj_' + key, 'Storj ' + key, value={key : value})
          yield metric
Esempio n. 21
0
 def _reset_metrics(self):
     # create all the metrics objects that we'll fill in elsewhere
     global metric_objs
     metric_objs = {'cmd_gather': GaugeMetricFamily('weka_gather_seconds', 'Time spent gathering statistics',
                                                    labels=["cluster"]),
                    'wekainfo': InfoMetricFamily('weka', "Information about the Weka cluster"),
                    'wekauptime': GaugeMetricFamily('weka_uptime', "Weka cluster uptime", labels=["cluster"])}
     for name, parms in self.CLUSTERSTATS.items():
         metric_objs["cluster_stat_" + name] = GaugeMetricFamily(name, parms[0], labels=parms[1])
     for name, parms in self.INFOSTATS.items():
         metric_objs[name] = GaugeMetricFamily(name, parms[0], labels=parms[1])
     metric_objs['weka_protection'] = GaugeMetricFamily('weka_protection', 'Weka Data Protection Status',
                                                        labels=["cluster", 'numFailures'])
     metric_objs['weka_rebuild'] = GaugeMetricFamily('weka_rebuild', 'Weka Rebuild Progress',
                                                        labels=["cluster"])
     metric_objs['weka_fs'] = GaugeMetricFamily('weka_fs', 'Filesystem information', labels=['cluster', 'name', 'stat'])
     metric_objs['weka_stats_gauge'] = GaugeMetricFamily('weka_stats',
                                                         'WekaFS statistics. For more info refer to: https://docs.weka.io/usage/statistics/list-of-statistics',
                                                         labels=['cluster', 'host_name', 'host_role', 'node_id',
                                                                 'node_role', 'category', 'stat', 'unit'])
     metric_objs['weka_io_histogram'] = GaugeHistogramMetricFamily("weka_blocksize",
                                                                   "weka blocksize distribution histogram",
                                                                   labels=['cluster', 'host_name', 'host_role',
                                                                           'node_id', 'node_role', 'category',
                                                                           'stat', 'unit'])
     metric_objs['alerts'] = GaugeMetricFamily('weka_alerts', 'Alerts from Weka cluster',
                                               labels=['cluster', 'type', 'title', 'host_name', 'host_id', 'node_id',
                                                       'drive_id'])
     metric_objs['drives'] = GaugeMetricFamily('weka_drives', 'Weka cluster drives',
                                               labels=['cluster', 'host_name', 'host_id', 'node_id', 'drive_id',
                                                       'vendor', 'model', 'serial', 'size', 'status', 'life'])
Esempio n. 22
0
    def generate_infos(self, calling_class, vrops_entity_name, labelnames):
        if not isinstance(labelnames, list):
            logger.error(
                f'Cannot generate Gauges without label list, called from {calling_class}'
            )
            return {}
        properties_yaml = self.read_collector_config()['properties']
        if 'info_metrics' in properties_yaml[calling_class]:
            infos = dict()
            for property_pair in properties_yaml[calling_class][
                    'info_metrics']:
                property_suffix = property_pair['metric_suffix']
                infos[property_suffix] = {
                    'info':
                    InfoMetricFamily('vrops_' + vrops_entity_name + '_' +
                                     property_suffix.lower(),
                                     'vrops-exporter',
                                     labels=labelnames),
                    'property':
                    property_pair['property']
                }
            return infos

        logger.info(f'No info metric type generated, from {calling_class}')
        return {}
Esempio n. 23
0
 def describe(self):
     if 'Stats' in self.__class__.__name__:
         statkey_yaml = self.read_collector_config()['statkeys']
         for statkey_pair in statkey_yaml[self.__class__.__name__]:
             statkey_suffix = statkey_pair['metric_suffix']
             yield GaugeMetricFamily(
                 'vrops_' + self.vrops_entity_name + '_' +
                 statkey_suffix.lower(), 'vrops-exporter')
     if 'Properties' in self.__class__.__name__:
         properties_yaml = self.read_collector_config()['properties']
         if 'number_metrics' in properties_yaml[self.__class__.__name__]:
             for num in properties_yaml[
                     self.__class__.__name__]['number_metrics']:
                 yield GaugeMetricFamily(
                     'vrops_' + self.vrops_entity_name + '_' +
                     num['metric_suffix'].lower(), 'vrops-exporter')
         if 'enum_metrics' in properties_yaml[self.__class__.__name__]:
             for enum in properties_yaml[
                     self.__class__.__name__]['enum_metrics']:
                 yield UnknownMetricFamily(
                     'vrops_' + self.vrops_entity_name + '_' +
                     enum['metric_suffix'].lower(), 'vrops-exporter')
         if 'info_metrics' in properties_yaml[self.__class__.__name__]:
             for info in properties_yaml[
                     self.__class__.__name__]['info_metrics']:
                 yield InfoMetricFamily(
                     'vrops_' + self.vrops_entity_name + '_' +
                     info['metric_suffix'].lower(), 'vrops-exporter')
Esempio n. 24
0
    def test_simple_info(self):
        families = text_string_to_metric_families("""# TYPE a info
# HELP a help
a_info{foo="bar"} 1
# EOF
""")
        self.assertEqual([InfoMetricFamily("a", "help", {'foo': 'bar'})], list(families))
 def create_info_collector(name, info, dicts, labels=[]):
     labels.append('routerboard_name')
     if type(dicts) is list:
         collector = InfoMetricFamily(f'routeros_{name}', info)
         for d in dicts:
             labels_values = {}
             for label in labels:
                 if d.get(label):
                     labels_values[label] = d.get(label)
                 else:
                     labels_values[label] = ''
             collector.add_metric(labels, labels_values)
         return collector
     else:
         raise Exception(
             f'{type(dicts)} is not a dictionary or a list of dictionaries.'
         )
Esempio n. 26
0
    def collect(self):
        info = self.rpc.getinfo()
        info_labels = {k: v for k, v in info.items() if isinstance(v, str)}
        node_info_fam = InfoMetricFamily(
            'lightning_node',
            'Static node information',
            labels=info_labels.keys(),
        )
        node_info_fam.add_metric(info_labels, info_labels)
        yield node_info_fam

        blockheight = info['blockheight']
        yield GaugeMetricFamily(
            'lightning_node_blockheight',
            "Current Bitcoin blockheight on this node.",
            value=blockheight,
        )
Esempio n. 27
0
 def collect(self):
     info = InfoMetricFamily('xxxx', 'xxxxxx')
     info.add_metric(labels='version',
                     value={
                         'version': 'xxxxx',
                         'loglevel': 'xxx',
                         'root': 'xxxx',
                         'workers': 'xxxx',
                         'ip': 'xxxxx',
                         'port': 'xxx',
                         'config_name': 'xxxx',
                         'mode': 'xx',
                         'debug': 'xxx',
                         'node': 'xxx',
                         'pod': 'xxx',
                         'pid': str(os.getpid())
                     })
     yield info
Esempio n. 28
0
    def collect(self):
        headers = {
            'Authorization': 'token {}'.format(os.environ.get("TOKEN", ""))
        }

        for repo in self.repos:
            name = repo.replace('/', '_').replace('-', '_')

            if time.time() - self.time > self.cache_timeout:
                self.cache = {}
                self.time = time.time()

            if name not in self.cache:
                try:
                    response = requests.get(url=self.url.format(repo),
                                            headers=headers,
                                            verify=False,
                                            stream=False,
                                            timeout=5)
                except requests.Timeout:
                    continue
                except requests.ConnectionError:
                    continue

                self.cache[name] = response.json()

            metric_counter = CounterMetricFamily(
                "repo__{}__tags_".format(name),
                "Repo `{}` tags total".format(name),
                labels=['tags'])
            metric_counter.add_metric([name], len(self.cache[name]))
            yield metric_counter

            metric_info = InfoMetricFamily("repo__{}__tag".format(name),
                                           "Repo `{}` tag".format(name))
            metric_info.add_metric(
                ["tag"], {
                    'name':
                    self.cache[name][0]['name']
                    if len(self.cache[name]) else 'inf'
                })
            yield metric_info
Esempio n. 29
0
    def collect(self):

        start = time.time()

        # Perform REST API call to fetch data
        data = call_rest_api('/mgmt/status/default/IPMISelEvents', self.ip,
                             self.port, self.session, self.timeout)

        if data == '':
            return

        # Update Prometheus metrics
        for ise in data['IPMISelEvents']:
            i = InfoMetricFamily('mqa_ipmi_sel_events',
                                 'MQ Appliance IPMI SEL events information')
            i.add_metric(
                [
                    'appliance', 'index', 'timestamp', 'recordType',
                    'sensorType', 'sensorNumber', 'sensorName',
                    'eventReadingTypeCode', 'eventData', 'eventDirection',
                    'extra'
                ], {
                    'appliance': self.appliance,
                    'index': str(ise['Index']),
                    'timestamp': ise['Timestamp'],
                    'recordType': ise['RecordType'],
                    'sensorType': ise['SensorType'],
                    'sensorNumber': ise['SensorNumber'],
                    'sensorName': ise['SensorName'],
                    'eventReadingTypeCode': ise['EventReadingTypeCode'],
                    'eventData': ise['EventData2'],
                    'eventDirection': ise['EventDirection'],
                    'extra': ise['Extra']
                })
            yield i

        g = GaugeMetricFamily(
            'mqa_exporter_ipmi_sel_events_elapsed_time_seconds',
            'Exporter eleapsed time to collect ipmi sel events metrics',
            labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g
Esempio n. 30
0
    def array_info(self):
        """Assemble a simple information metric defining the scraped system."""
        data = self.connection.get()

        yield InfoMetricFamily('purefa',
                               'FlashArray system information',
                               value={
                                   'array_name': data['array_name'],
                                   'system_id': data['id'],
                                   'version': data['version']
                               })
Esempio n. 31
0
    def _info(self):
        """Assemble a simple information metric defining the scraped system."""
        info = self.fb.get_array_info()

        self.info = InfoMetricFamily('purefb',
                                     'FlashBlade system information',
                                     value={
                                         'array_name': info.name,
                                         'system_id': info.id,
                                         'os': info.os,
                                         'version': info.version
                                     })