def collect(self):

        start = time.time()

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

        # Update Prometheus metrics
        for efs in data['EnvironmentalFanSensors']:

            g = GaugeMetricFamily(
                'mqa_environmental_fan_sensors_fan_speed_rpm',
                'The speed of the fan in revolutions per minute (RPM)',
                labels=['appliance', 'fanID', 'readingStatus'])
            g.add_metric([self.appliance, efs['FanID'], efs['ReadingStatus']],
                         efs['FanSpeed'])
            yield g

            g = GaugeMetricFamily(
                'mqa_environmental_fan_sensors_fan_speed_lower_critical_threshold_rpm',
                'The lowest allowable reading of the fan speed sensor',
                labels=['appliance', 'fanId', 'readingStatus'])
            g.add_metric([self.appliance, efs['FanID'], efs['ReadingStatus']],
                         efs['LowerCriticalThreshold'])
            yield g

        g = GaugeMetricFamily(
            'mqa_exporter_environmental_fan_sensors_elapsed_time_seconds',
            'Exporter eleapsed time to collect environmental fan sensors metrics',
            labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g
    def collect(self):

        start = time.time()

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

        # Update Prometheus metrics
        g = GaugeMetricFamily(
            'mqa_system_memory_memory_usage',
            'The instantaneous memory usage as a percentage of the total memory',
            labels=['appliance'])
        g.add_metric([self.appliance],
                     data['SystemMemoryStatus']['MemoryUsage'])
        yield g

        c = CounterMetricFamily(
            'mqa_system_memory_memory_bytes_total',
            'The total memory of the system in bytes. The total memory equals the amount of installed memory minus the amount of reserved memory',
            labels=['appliance'])
        c.add_metric([self.appliance],
                     data['SystemMemoryStatus']['TotalMemory'] * 1000000)
        yield c

        g = GaugeMetricFamily(
            'mqa_system_memory_memory_bytes_used',
            'The amount of memory in bytes that is currently in use. The used memory equals the amount of total memory minus the amount of free memory. The used memory does not include any hold memory',
            labels=['appliance'])
        g.add_metric([self.appliance],
                     data['SystemMemoryStatus']['UsedMemory'] * 1000000)
        yield g

        g = GaugeMetricFamily(
            'mqa_system_memory_memory_bytes_free',
            'The amount of memory in bytes that is currently not in use and is therefore available. The free memory value includes any hold memory that is not currently in use',
            labels=['appliance'])
        g.add_metric([self.appliance],
                     data['SystemMemoryStatus']['FreeMemory'] * 1000000)
        yield g

        g = GaugeMetricFamily(
            'mqa_exporter_system_memory_elapsed_time_seconds',
            'Exporter eleapsed time to collect system_memory metrics',
            labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g
Пример #3
0
    def collect(self):

        start = time.time()

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

        # Update Prometheus metrics
        g = GaugeMetricFamily(
            'mqa_system_cpu_usage',
            'The instantaneous CPU usage as a percentage of the CPU load',
            labels=['appliance'])
        g.add_metric([self.appliance], data['SystemCpuStatus']['CpuUsage'])
        yield g

        g = GaugeMetricFamily('mqa_system_cpu_load_avg_1m',
                              'The average CPU load over the last minute',
                              labels=['appliance'])
        g.add_metric([self.appliance], data['SystemCpuStatus']['CpuLoadAvg1'])
        yield g

        g = GaugeMetricFamily('mqa_system_cpu_load_avg_5m',
                              'The average CPU load over 5 minutes',
                              labels=['appliance'])
        g.add_metric([self.appliance], data['SystemCpuStatus']['CpuLoadAvg5'])
        yield g

        g = GaugeMetricFamily('mqa_system_cpu_load_avg_15m',
                              'The average CPU load over 15 minutes',
                              labels=['appliance'])
        g.add_metric([self.appliance], data['SystemCpuStatus']['CpuLoadAvg15'])
        yield g

        g = GaugeMetricFamily(
            'mqa_exporter_system_cpu_elapsed_time_seconds',
            'Exporter eleapsed time to collect system cpu metrics',
            labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g
Пример #4
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
Пример #5
0
    def collect(self):

        start = time.time()

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

        if data == '':
            return

        failureNotifications = []

        if type(data['FailureNotificationStatus2']) is dict:
            failureNotifications.append(data['FailureNotificationStatus2'])
        else:
            failureNotifications = data['FailureNotificationStatus2']

        # Update Prometheus metrics
        for fn in failureNotifications:

            i = InfoMetricFamily('mqa_failure_notification',
                                 'MQ Appliance failure notifications')
            i.add_metric(
                ['appliance', 'date', 'reason', 'uploadStatus', 'location'], {
                    'appliance': self.appliance,
                    'date': fn['Date'],
                    'reason': fn['Reason'],
                    'uploadStatus': fn['UploadStatus'],
                    'location': fn['Location']
                })
            yield i

        g = GaugeMetricFamily(
            'mqa_exporter_failure_notification_elapsed_time_seconds',
            'Exporter eleapsed time to collect failure notification metrics',
            labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g
    def collect(self):

        start = time.time()

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

        connections = {}
        users = []

        if type(data['ActiveUsers']) is dict:
            users.append(data['ActiveUsers'])
        else:
            users = data['ActiveUsers']

        # Process active users
        for au in users:

            conn = au['connection']
            if conn in connections:
                count = connections.get(conn)
                count += 1
                connections.update({conn:count})
            else:
                connections.update({conn:1})

        # Update Prometheus metrics
        for conn in connections:
            
            g = GaugeMetricFamily('mqa_active_users_total', 'Total active users connected to the appliance', labels=['appliance', 'connection'])
            g.add_metric([self.appliance, conn], connections.get(conn))
            yield g

        g = GaugeMetricFamily('mqa_exporter_active_users_elapsed_time_seconds', 'Exporter eleapsed time to collect active users metrics', labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g
    def collect(self):

        start = time.time()

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

        # Update Prometheus metrics
        for rss in data['RaidSsdStatus']:

            g = CounterMetricFamily(
                'mqa_raid_ssd_bytes_written_total',
                'The total data in bytes written to the drive since manufacture',
                labels=['appliance', 'diskNumber', 'serialNumber'])
            g.add_metric([self.appliance,
                          str(rss['DiskNumber']), rss['SN']],
                         rss['TotalWritten'] * 1073742000)
            yield g

            g = GaugeMetricFamily(
                'mqa_raid_ssd_life_left',
                'Estimate of the remaining drive lifetime',
                labels=['appliance', 'diskNumber', 'serialNumber'])
            g.add_metric([self.appliance,
                          str(rss['DiskNumber']), rss['SN']], rss['LifeLeft'])
            yield g

        g = GaugeMetricFamily(
            'mqa_exporter_raid_ssd_elapsed_time_seconds',
            'Exporter eleapsed time to collect raid ssd metrics',
            labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g
    def collect(self):

        start = time.time()

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

        # Update Prometheus metrics
        for qm in data['QueueManagersStatus']:

            g = GaugeMetricFamily(
                'mqa_queue_manager_cpu_usage',
                'The instantaneous CPU usage by the queue manager as a percentage of the CPU load',
                labels=['appliance', 'qm', 'status'])
            g.add_metric([self.appliance, qm['Name'], qm['Status']],
                         qm['CpuUsage'])
            yield g

            g = GaugeMetricFamily(
                'mqa_queue_manager_memory_bytes_used',
                'The amount of memory in bytes that is currently in use by the queue manager',
                labels=['appliance', 'qm', 'status'])
            # Memory in MB not MiB
            #g.add_metric([self.appliance, qm['Name']], qm['UsedMemory'] * 1048576)
            g.add_metric([self.appliance, qm['Name'], qm['Status']],
                         qm['UsedMemory'] * 1000000)
            yield g

            g = GaugeMetricFamily(
                'mqa_queue_manager_fs_bytes_used',
                'The amount of file system in bytes that is currently in use by the queue manager',
                labels=['appliance', 'qm', 'status'])
            # Memory in MB not MiB
            #g.add_metric([self.appliance, qm['Name']], qm['UsedFs'] * 1048576)
            g.add_metric([self.appliance, qm['Name'], qm['Status']],
                         qm['UsedFs'] * 1000000)
            yield g

            g = GaugeMetricFamily(
                'mqa_queue_manager_fs_bytes_allocated',
                'The amount of file system in bytes allocated for the queue manager',
                labels=['appliance', 'qm', 'status'])
            # Memory in MB not MiB
            #g.add_metric([self.appliance, qm['Name']], qm['TotalFs'] * 1048576)
            g.add_metric([self.appliance, qm['Name'], qm['Status']],
                         qm['TotalFs'] * 1000000)
            yield g

            i = InfoMetricFamily('mqa_queue_manager',
                                 'MQ Appliance queue manager information')
            i.add_metric(
                [
                    'appliance', 'qm', 'status', 'haRole', 'haStatus',
                    'drRole', 'drStatus'
                ], {
                    'appliance':
                    self.appliance,
                    'qm':
                    qm['Name'],
                    'status':
                    qm['Status'],
                    'haRole':
                    'Unknown' if qm['HaRole'] == '' else qm['HaRole'],
                    'haStatus':
                    'Unknown' if qm['HaStatus'] == '' else qm['HaStatus'],
                    'drRole':
                    'Unknown' if qm['DrRole'] == '' else qm['DrRole'],
                    'drStatus':
                    'Unknown' if qm['DrStatus'] == '' else qm['DrStatus']
                })
            yield i

        g = GaugeMetricFamily(
            'mqa_exporter_queue_managers_elapsed_time_seconds',
            'Exporter eleapsed time to collect queue managers metrics',
            labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g
Пример #9
0
    def collect(self):

        start = time.time()

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

        # Update Prometheus metrics
        for ec in data['EthernetCountersStatus']:

            c = CounterMetricFamily(
                'mqa_ethernet_counters_in_unicast_packets_total',
                'The number of unicast packets received on this interface',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, ec['Name']],
                         0.0 if ec['InUnicastPackets'] == '' else float(
                             ec['InUnicastPackets']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_in_multicast_packets_total',
                'The number of multicast packets received on this interface',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, ec['Name']],
                         0.0 if ec['InMulticastPackets'] == '' else float(
                             ec['InMulticastPackets']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_in_broadcast_packets_total',
                'The number of broadcast packets received on this interface',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, ec['Name']],
                         0.0 if ec['InBroadcastPackets'] == '' else float(
                             ec['InBroadcastPackets']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_out_unicast_packets_total',
                'The number of unicast packets transmitted on this interface',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, ec['Name']],
                         0.0 if ec['OutUnicastPackets'] == '' else float(
                             ec['OutUnicastPackets']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_out_multicast_packets_total',
                'The number of multicast packets transmitted on this interface',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, ec['Name']],
                         0.0 if ec['OutMulticastPackets'] == '' else float(
                             ec['OutMulticastPackets']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_out_broadcast_packets_total',
                'The number of broadcast packets transmitted on this interface',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, ec['Name']],
                         0.0 if ec['OutBroadcastPackets'] == '' else float(
                             ec['OutBroadcastPackets']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_in_octets_total',
                'The number of bytes received on this interface at the MAC level',
                labels=['appliance', 'name'])
            c.add_metric(
                [self.appliance, ec['Name']],
                0.0 if ec['InOctets'] == '' else float(ec['InOctets']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_out_octets_total',
                'The number of bytes transmitted on this interface at the MAC level',
                labels=['appliance', 'name'])
            c.add_metric(
                [self.appliance, ec['Name']],
                0.0 if ec['OutOctets'] == '' else float(ec['OutOctets']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_in_errors_total',
                'The total number of receive errors on this interface',
                labels=['appliance', 'name'])
            c.add_metric(
                [self.appliance, ec['Name']],
                0.0 if ec['InErrors'] == '' else float(ec['InErrors']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_out_errors_total',
                'The total number of transmit errors on this interface',
                labels=['appliance', 'name'])
            c.add_metric(
                [self.appliance, ec['Name']],
                0.0 if ec['OutErrors'] == '' else float(ec['OutErrors']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_out_discards_total',
                'The number of packets not transmitted for flow control reasons',
                labels=['appliance', 'name'])
            c.add_metric(
                [self.appliance, ec['Name']],
                0.0 if ec['OutDiscards'] == '' else float(ec['OutDiscards']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_alignment_errors_total',
                'The number of packets received on this interface that were not an integral number of bytes in length',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, ec['Name']],
                         0.0 if ec['AlignmentErrors'] == '' else float(
                             ec['AlignmentErrors']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_fcs_errors_total',
                'The number of packets received on this interface with an invalid Frame Check Sequence (checksum). This does not include FCS errors on packets that were too long or too short',
                labels=['appliance', 'name'])
            c.add_metric(
                [self.appliance, ec['Name']],
                0.0 if ec['FCSErrors'] == '' else float(ec['FCSErrors']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_single_collision_frames_total',
                'The number of packets successfully transmitted on this interface after a single collision. This can only happen when the interface is running in Half-Duplex mode',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, ec['Name']],
                         0.0 if ec['SingleCollisionFrames'] == '' else float(
                             ec['SingleCollisionFrames']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_multiple_collision_frames_total',
                'The number of packets successfully transmitted on this interface after multiple collisions, but less than 16 collisions. This can only happen when the interface is running in Half-Duplex mode',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, ec['Name']],
                         0.0 if ec['MultipleCollisionFrames'] == '' else float(
                             ec['MultipleCollisionFrames']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_sqe_test_errors_total',
                'The number of times that an SQE test error was encountered. This only can happen when the link is operating in 10BASE-T Half-Duplex',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, ec['Name']],
                         0.0 if ec['SQETestErrors'] == '' else float(
                             ec['SQETestErrors']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_deferred_transmissions_total',
                'The number of frames for which the first transmission attempt was deferred because the medium was busy. This can only happen when the interface is running in Half-Duplex mode',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, ec['Name']],
                         0.0 if ec['DeferredTransmissions'] == '' else float(
                             ec['DeferredTransmissions']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_late_collisions_total',
                'The number of times that a collision was detected later than one slot time after the transmission of a packet. This can only happen when the interface is running in Half-Duplex mode',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, ec['Name']],
                         0.0 if ec['LateCollisions'] == '' else float(
                             ec['LateCollisions']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_excessive_collisions_total',
                'The number of times that transmission of a packet failed because it encountered sixteen collisions in a row. This can only happen when the interface is running in Half-Duplex mode',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, ec['Name']],
                         0.0 if ec['ExcessiveCollisions'] == '' else float(
                             ec['ExcessiveCollisions']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_internal_mac_transmit_errors_total',
                'The number of times that transmission of packets failed due to errors inside the MAC layer of the Ethernet interface. These may be due to temporary resource limitations',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, ec['Name']],
                         0.0 if ec['InternalMacTransmitErrors'] == '' else
                         float(ec['InternalMacTransmitErrors']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_carrier_sense_errors_total',
                'The number transmitted packets during which there were failures of carrier sense. This can only happen when the interface is running in Half-Duplex mode',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, ec['Name']],
                         0.0 if ec['CarrierSenseErrors'] == '' else float(
                             ec['CarrierSenseErrors']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_frame_too_shorts_total',
                'The number of received packets that were shorter than 64 bytes. This can be the result of a collision. Such packages are also known as runts',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, ec['Name']],
                         0.0 if ec['FrameTooShorts'] == '' else float(
                             ec['FrameTooShorts']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_frame_too_longs_total',
                'The number of received packets that were longer than the configured MTU. This can be the result of a collision, as well as due to incompatible configuration',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, ec['Name']],
                         0.0 if ec['FrameTooLongs'] == '' else float(
                             ec['FrameTooLongs']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_internal_mac_receive_errors_total',
                'The number of times that reception of packets failed due to errors inside the MAC layer of the Ethernet interface. These may be due to temporary resource limitations',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, ec['Name']],
                         0.0 if ec['InternalMacReceiveErrors'] == '' else
                         float(ec['InternalMacReceiveErrors']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_in_pause_frames_total',
                'The number of pause frames received',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, ec['Name']],
                         0.0 if ec['InPauseFrames'] == '' else float(
                             ec['InPauseFrames']))
            yield c

            c = CounterMetricFamily(
                'mqa_ethernet_counters_out_pause_frames_total',
                'The number of pause frames transmitted',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, ec['Name']],
                         0.0 if ec['OutPauseFrames'] == '' else float(
                             ec['OutPauseFrames']))
            yield c

        g = GaugeMetricFamily(
            'mqa_exporter_ethernet_counters_elapsed_time_seconds',
            'Exporter eleapsed time to collect ethernet counters metrics',
            labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g
Пример #10
0
    def collect(self):

        start = time.time()

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

        # Update Prometheus metrics
        c = CounterMetricFamily(
            'mqa_mq_resources_storage_bytes_total',
            'The total storage in bytes available for IBM MQ data',
            labels=['appliance'])
        c.add_metric([self.appliance],
                     data['MQSystemResources']['TotalStorage'] * 1000000)
        yield c

        g = GaugeMetricFamily('mqa_mq_resources_storage_bytes_used',
                              'The amount of IBM MQ storage in use in bytes',
                              labels=['appliance'])
        g.add_metric([self.appliance],
                     data['MQSystemResources']['UsedStorage'] * 1000000)
        yield g

        c = CounterMetricFamily(
            'mqa_mq_resources_errors_storage_bytes_total',
            'The total storage in bytes available for IBM MQ error logs',
            labels=['appliance'])
        c.add_metric([self.appliance],
                     data['MQSystemResources']['TotalErrorsStorage'] * 1000000)
        yield c

        g = GaugeMetricFamily(
            'mqa_mq_resources_errors_storage_bytes_used',
            'The amount of IBM MQ error log storage in use in bytes',
            labels=['appliance'])
        g.add_metric([self.appliance],
                     data['MQSystemResources']['UsedErrorsStorage'] * 1000000)
        yield g

        c = CounterMetricFamily(
            'mqa_mq_resources_trace_storage_bytes_total',
            'The total storage in bytes available for IBM MQ trace',
            labels=['appliance'])
        c.add_metric([self.appliance],
                     data['MQSystemResources']['TotalTraceStorage'] * 1000000)
        yield c

        g = GaugeMetricFamily(
            'mqa_mq_resources_trace_storage_bytes_used',
            'The amount of IBM MQ trace storage in bytes in use',
            labels=['appliance'])
        g.add_metric([self.appliance],
                     data['MQSystemResources']['UsedTraceStorage'] * 1000000)
        yield g

        ha_status = data['MQSystemResources']['HAStatus']
        if ha_status == 'Online':
            ha_status_value = 1
        elif ha_status == 'Standby':
            ha_status_value = 2
        else:
            ha_status_value = 0
        g = GaugeMetricFamily(
            'mqa_mq_resources_ha_status',
            'HA status of the appliance (0: HA not set, 1: Online, 2: Standby',
            labels=['appliance'])
        g.add_metric([self.appliance], ha_status_value)
        yield g

        ha_status = data['MQSystemResources']['HAPartner']
        ha_status = ha_status[ha_status.find('(') + 1:ha_status.find(')')]
        if ha_status == 'Online':
            ha_partner_status_value = 1
        elif ha_status == 'Standby':
            ha_partner_status_value = 2
        else:
            ha_partner_status_value = 0
        g = GaugeMetricFamily(
            'mqa_mq_resources_ha_partner_status',
            'HA status of the partner appliance (0: HA not set, 1: Online, 2: Standby',
            labels=['appliance'])
        g.add_metric([self.appliance], ha_partner_status_value)
        yield g

        i = InfoMetricFamily('mqa_mq_resources',
                             'MQ Appliance MQ resources information')
        i.add_metric(
            ['appliance', 'haStatus', 'haPartner'], {
                'appliance': self.appliance,
                'haStatus': data['MQSystemResources']['HAStatus'],
                'haPartner': data['MQSystemResources']['HAPartner']
            })
        yield i

        g = GaugeMetricFamily(
            'mqa_exporter_mq_system_resources_elapsed_time_seconds',
            'Exporter eleapsed time to collect mq system resources metrics',
            labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g
Пример #11
0
    def collect(self):

        start = time.time()

        # Perform REST API call to fetch the list of queue managers
        qm_data = call_rest_api('/ibmmq/rest/v2/admin/qmgr', self.ip,
                                self.port, self.session, self.timeout)
        if qm_data == '':
            return

        command = {
            'type':
            'runCommandJSON',
            'command':
            'display',
            'qualifier':
            'qstatus',
            'name':
            '*',
            'responseParameters': [
                'curdepth', 'ipprocs', 'opprocs', 'curfsize', 'curmaxfs',
                'lgetdate', 'lgettime', 'lputdate', 'lputtime', 'monq',
                'msgage', 'qtime', 'uncom'
            ]
        }

        # For each running queue manager fetch the queues
        total_queue_managers = 0
        total_queues = 0

        for qm in qm_data['qmgr']:

            if qm['state'] == 'running':
                headers = {
                    'Content-type': 'application/json;charset=UTF-8',
                    'ibm-mq-rest-csrf-token': ''
                }
                # v2 call, only available since 9.1.5
                queue_data = call_rest_api(
                    '/ibmmq/rest/v2/admin/action/qmgr/' + qm['name'] + '/mqsc',
                    self.ip, self.port, self.session, self.timeout, 'POST',
                    headers, command)
                if queue_data == '':
                    continue

                total_queue_managers += 1

                # Update Prometheus metrics
                for queue in queue_data['commandResponse']:
                    if queue['completionCode'] == 0:

                        total_queues += 1

                        g = GaugeMetricFamily(
                            'mqa_qm_queue_current_depth',
                            'The current depth of the queue, that is, the number of messages on the queue, including both committed messages and uncommitted messages',
                            labels=['appliance', 'qm', 'queue'])
                        g.add_metric([
                            self.appliance, qm['name'],
                            queue['parameters']['queue']
                        ], queue['parameters']['curdepth'])
                        yield g

                        g = GaugeMetricFamily(
                            'mqa_qm_queue_input_procs',
                            'The number of handles that are currently open for input for the queue (either input-shared or input-exclusive)',
                            labels=['appliance', 'qm', 'queue'])
                        g.add_metric([
                            self.appliance, qm['name'],
                            queue['parameters']['queue']
                        ], queue['parameters']['ipprocs'])
                        yield g

                        g = GaugeMetricFamily(
                            'mqa_qm_queue_output_procs',
                            'The number of handles that are currently open for output for the queue',
                            labels=['appliance', 'qm', 'queue'])
                        g.add_metric([
                            self.appliance, qm['name'],
                            queue['parameters']['queue']
                        ], queue['parameters']['opprocs'])
                        yield g

                        g = GaugeMetricFamily(
                            'mqa_qm_queue_message_age_seconds',
                            'Age, in seconds, of the oldest message on the queue',
                            labels=['appliance', 'qm', 'queue'])
                        g.add_metric([
                            self.appliance, qm['name'],
                            queue['parameters']['queue']
                        ], 0 if queue['parameters']['msgage'] == '' else
                                     queue['parameters']['msgage'])
                        yield g

                        if queue['parameters']['uncom'] == 'YES':
                            uncommitted_messages = 1
                        elif queue['parameters']['uncom'] == 'NO':
                            uncommitted_messages = 0
                        else:
                            uncommitted_messages = queue['parameters']['uncom']

                        g = GaugeMetricFamily(
                            'mqa_qm_queue_uncommitted_messages',
                            'The number of uncommitted changes (puts and gets) pending for the queue',
                            labels=['appliance', 'qm', 'queue'])
                        g.add_metric([
                            self.appliance, qm['name'],
                            queue['parameters']['queue']
                        ], uncommitted_messages)
                        yield g

                        queue_time = queue['parameters']['qtime']

                        if queue_time == ' , ':
                            q_time_small_sample = -1
                            q_time_large_sample = -1
                        else:
                            q_time_small_sample = float(
                                queue_time[:queue_time.find(',')])
                            q_time_large_sample = float(
                                queue_time[queue_time.find(',') + 1:])

                        g = GaugeMetricFamily(
                            'mqa_qm_queue_time_small_sample_seconds',
                            'Interval, in seconds, between messages being put on the queue and then being destructively read. A value based on the last few messages processed',
                            labels=['appliance', 'qm', 'queue'])
                        g.add_metric([
                            self.appliance, qm['name'],
                            queue['parameters']['queue']
                        ], q_time_small_sample / 1000000)
                        yield g

                        g = GaugeMetricFamily(
                            'mqa_qm_queue_time_large_sample_seconds',
                            'Interval, in seconds, between messages being put on the queue and then being destructively read. A value based on a larger sample of the recently processed messages',
                            labels=['appliance', 'qm', 'queue'])
                        g.add_metric([
                            self.appliance, qm['name'],
                            queue['parameters']['queue']
                        ], q_time_large_sample / 1000000)
                        yield g

                        current_file_size = 0
                        current_max_file_size = 0
                        try:
                            # Fields only available since 9.1.5
                            current_file_size = queue['parameters'][
                                'curfsize'] * 1000000
                            g = GaugeMetricFamily(
                                'mqa_qm_queue_current_file_size_bytes',
                                'The current size of the queue file in bytes, rounded up to the nearest megabyte',
                                labels=['appliance', 'qm', 'queue'])
                            g.add_metric([
                                self.appliance, qm['name'],
                                queue['parameters']['queue']
                            ], current_file_size)
                            yield g

                            current_max_file_size = queue['parameters'][
                                'curmaxfs'] * 1000000
                            g = GaugeMetricFamily(
                                'mqa_qm_queue_current_max_file_size_bytes',
                                'The current maximum size in bytes the queue file can grow to, rounded up to the nearest megabyte, given the current block size in use on a queue',
                                labels=['appliance', 'qm', 'queue'])
                            g.add_metric([
                                self.appliance, qm['name'],
                                queue['parameters']['queue']
                            ], current_max_file_size)
                            yield g
                        except KeyError:
                            pass

                        c = CounterMetricFamily(
                            'mqa_qm_queue_last_get_datetime_seconds',
                            'The datetime on which the last message was retrieved from the queue since the queue manager started in epoch seconds',
                            labels=['appliance', 'qm', 'queue'])
                        c.add_metric([
                            self.appliance, qm['name'],
                            queue['parameters']['queue']
                        ],
                                     datetime_to_epoch(
                                         queue['parameters']['lgetdate'] +
                                         ' ' + queue['parameters']['lgettime'],
                                         '%Y-%m-%d %H.%M.%S'))
                        yield c

                        c = CounterMetricFamily(
                            'mqa_qm_queue_last_put_datetime_seconds',
                            'The datetime on which the last message was put to the queue since the queue manager started in epoch seconds',
                            labels=['appliance', 'qm', 'queue'])
                        c.add_metric([
                            self.appliance, qm['name'],
                            queue['parameters']['queue']
                        ],
                                     datetime_to_epoch(
                                         queue['parameters']['lgetdate'] +
                                         ' ' + queue['parameters']['lgettime'],
                                         '%Y-%m-%d %H.%M.%S'))
                        yield c

        g = GaugeMetricFamily(
            'mqa_exporter_queue_managers_queues_elapsed_time_seconds',
            'Exporter eleapsed time to collect queue managers queues metrics',
            labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g

        g = GaugeMetricFamily(
            'mqa_exporter_queue_managers_total',
            'Exporter total number of running queue managers',
            labels=['appliance'])
        g.add_metric([self.appliance], total_queue_managers)
        yield g

        g = GaugeMetricFamily(
            'mqa_exporter_queue_managers_queues_total',
            'Exporter total number of queues for all running queue managers',
            labels=['appliance'])
        g.add_metric([self.appliance], total_queues)
        yield g
Пример #12
0
    def collect(self):

        start = time.time()

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

        # Update Prometheus metrics
        g = GaugeMetricFamily(
            'mqa_environmental_sensors_system_temperature_celsius',
            'Ambient temperature',
            labels=['appliance'])
        g.add_metric([self.appliance],
                     data['EnvironmentalSensors']['systemTemp'])
        yield g

        g = GaugeMetricFamily(
            'mqa_environmental_sensors_cpu_1_temperature_celsius',
            'CPU 1 temperature',
            labels=['appliance'])
        g.add_metric([self.appliance],
                     data['EnvironmentalSensors']['cpu1Temp'])
        yield g

        g = GaugeMetricFamily(
            'mqa_environmental_sensors_cpu_2_temperature_celsius',
            'CPU 2 temperature',
            labels=['appliance'])
        g.add_metric([self.appliance],
                     data['EnvironmentalSensors']['cpu2Temp'])
        yield g

        g = GaugeMetricFamily('mqa_environmental_sensors_cpu_1_fan_speed_rpm',
                              'CPU 1 fan speed',
                              labels=['appliance'])
        g.add_metric([self.appliance], data['EnvironmentalSensors']['cpu1rpm'])
        yield g

        g = GaugeMetricFamily('mqa_environmental_sensors_cpu_2_fan_speed_rpm',
                              'CPU 2 fan speed',
                              labels=['appliance'])
        g.add_metric([self.appliance], data['EnvironmentalSensors']['cpu2rpm'])
        yield g

        g = GaugeMetricFamily(
            'mqa_environmental_sensors_chassis_fan_1_speed_rpm',
            'Chassis fan 1 speed',
            labels=['appliance'])
        g.add_metric([self.appliance],
                     data['EnvironmentalSensors']['chassis1rpm'])
        yield g

        g = GaugeMetricFamily(
            'mqa_environmental_sensors_chassis_fan_2_speed_rpm',
            'Chassis fan 2 speed',
            labels=['appliance'])
        g.add_metric([self.appliance],
                     data['EnvironmentalSensors']['chassis2rpm'])
        yield g

        g = GaugeMetricFamily(
            'mqa_environmental_sensors_chassis_fan_3_speed_rpm',
            'Chassis fan 3 speed',
            labels=['appliance'])
        g.add_metric([self.appliance],
                     data['EnvironmentalSensors']['chassis3rpm'])
        yield g

        g = GaugeMetricFamily('mqa_environmental_sensors_33_voltage',
                              '3.3 voltage',
                              labels=['appliance'])
        g.add_metric([self.appliance],
                     float(data['EnvironmentalSensors']['volt33']))
        yield g

        g = GaugeMetricFamily('mqa_environmental_sensors_5_voltage',
                              '5 voltage',
                              labels=['appliance'])
        g.add_metric([self.appliance],
                     float(data['EnvironmentalSensors']['volt5']))
        yield g

        g = GaugeMetricFamily('mqa_environmental_sensors_12_voltage',
                              '12 voltage',
                              labels=['appliance'])
        g.add_metric([self.appliance],
                     float(data['EnvironmentalSensors']['volt12']))
        yield g

        g = GaugeMetricFamily(
            'mqa_exporter_environmental_sensors_elapsed_time_seconds',
            'Exporter eleapsed time to collect environmental sensors metrics',
            labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g
Пример #13
0
    def collect(self):

        start = time.time()

        # Perform REST API call to fetch the list of queue managers
        qm_data = call_rest_api('/ibmmq/rest/v2/admin/qmgr', self.ip, self.port, self.session, self.timeout)
        if qm_data == '':
            return

        command = {
            'type': 'runCommandJSON',
            'command': 'display',
            'qualifier': 'chstatus',
            'name': '*',
            'responseParameters': ['all']
        }

        # For each running queue manager fetch the channels
        total_queue_managers = 0
        total_channels = 0

        for qm in qm_data['qmgr']:

            if qm['state'] == 'running':
                headers = {'Content-type': 'application/json;charset=UTF-8', 'ibm-mq-rest-csrf-token': ''}
                 # v2 call, only available since 9.1.5
                channel_data = call_rest_api('/ibmmq/rest/v2/admin/action/qmgr/' + qm['name'] + '/mqsc', self.ip, self.port, self.session, self.timeout, 'POST', headers, command)
                if channel_data == '':
                    continue

                total_queue_managers += 1

                # Update Prometheus metrics
                for channel in channel_data['commandResponse']:
                    if channel['completionCode'] == 0:

                        total_channels += 1

                        job_name = channel['parameters']['jobname']
                        if job_name == 0:
                            job_name = '0000000000000000'

                        g = GaugeMetricFamily('mqa_qm_channel_running_state', 'The current status of the channel, 1 if the channel is in RUNNING state, 0 otherwise', labels=['appliance', 'qm', 'channel', 'chlType', 'jobName'])
                        g.add_metric([self.appliance, qm['name'], channel['parameters']['channel'], channel['parameters']['chltype'], job_name], 1 if channel['parameters']['status'] == 'RUNNING' else 0)
                        yield g

                        c = CounterMetricFamily('mqa_qm_channel_start_datetime_seconds', 'The datetime on which the channel started in epoch seconds', labels=['appliance', 'qm', 'channel', 'chlType', 'jobName'])
                        c.add_metric([self.appliance, qm['name'], channel['parameters']['channel'], channel['parameters']['chltype'], job_name], datetime_to_epoch(channel['parameters']['chstada'] + ' ' + channel['parameters']['chstati'], '%Y-%m-%d %H.%M.%S'))
                        yield c

                        c = CounterMetricFamily('mqa_qm_channel_last_message_datetime_seconds', 'The datetime on which the last message was sent on the channel in epoch seconds', labels=['appliance', 'qm', 'channel', 'chlType', 'jobName'])
                        c.add_metric([self.appliance, qm['name'], channel['parameters']['channel'], channel['parameters']['chltype'], job_name], datetime_to_epoch(channel['parameters']['lstmsgda'] + ' ' + channel['parameters']['lstmsgti'], '%Y-%m-%d %H.%M.%S'))
                        yield c

                        c = CounterMetricFamily('mqa_qm_channel_messages', 'The number of messages sent on the channel since it started', labels=['appliance', 'qm', 'channel', 'chlType', 'jobName'])
                        c.add_metric([self.appliance, qm['name'], channel['parameters']['channel'], channel['parameters']['chltype'], job_name], channel['parameters']['msgs'])
                        yield c

                        try:
                            remoteQMgr = channel['parameters']['rqmname']
                        except KeyError:
                            remoteQMgr = ''

                        i = InfoMetricFamily('mqa_qm_channel', 'MQ Appliance channel information')
                        i.add_metric(['appliance', 'qm', 'channel', 'chlType', 'jobName', 'status', 'conName', 
                                      'remoteQMgr', 'remoteProduct', 'remoteVersion'], 
                                    {'appliance': self.appliance, 
                                    'qm': qm['name'], 
                                    'channel': channel['parameters']['channel'],
                                    'chlType': channel['parameters']['chltype'],
                                    'jobName': job_name,
                                    'status': channel['parameters']['status'],
                                    'conName': channel['parameters']['conname'],
                                    'remoteQMgr': remoteQMgr,
                                    'remoteProduct': channel['parameters']['rproduct'],
                                    'remoteVersion': channel['parameters']['rversion']})
                        yield i

        g = GaugeMetricFamily('mqa_exporter_queue_managers_current_channels_count', 'Exporter total number of current channels for all running queue managers', labels=['appliance'])
        g.add_metric([self.appliance], total_channels)
        yield g

        g = GaugeMetricFamily('mqa_exporter_queue_managers_channels_elapsed_time_seconds', 'Exporter eleapsed time to collect queue managers channels metrics', labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g
Пример #14
0
    def collect(self):

        start = time.time()

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

        # Update Prometheus metrics
        g = GaugeMetricFamily('mqa_raid_battery_module_voltage_volts',
                              'The actual voltage of the battery in volts',
                              labels=['appliance', 'controllerID', 'status'])
        g.add_metric([
            self.appliance,
            str(data['RaidBatteryModuleStatus']['ControllerID']),
            str(data['RaidBatteryModuleStatus']['Status'])
        ], data['RaidBatteryModuleStatus']['Voltage'] / 1000)
        yield g

        g = GaugeMetricFamily(
            'mqa_raid_battery_module_current_amperes',
            'The current that flows through the battery terminals in amperes',
            labels=['appliance', 'controllerID', 'status'])
        g.add_metric([
            self.appliance,
            str(data['RaidBatteryModuleStatus']['ControllerID']),
            str(data['RaidBatteryModuleStatus']['Status'])
        ], data['RaidBatteryModuleStatus']['Current'] / 1000)
        yield g

        g = GaugeMetricFamily(
            'mqa_raid_battery_module_temperature_celsius',
            'The temperature of the battery in degrees celsius',
            labels=['appliance', 'controllerID', 'status'])
        g.add_metric([
            self.appliance,
            str(data['RaidBatteryModuleStatus']['ControllerID']),
            str(data['RaidBatteryModuleStatus']['Status'])
        ], data['RaidBatteryModuleStatus']['Temperature'])
        yield g

        g = GaugeMetricFamily(
            'mqa_raid_battery_module_design_capacity_amperes_hour',
            'The designed capacity of the battery in ampere-hour',
            labels=['appliance', 'controllerID', 'status'])
        g.add_metric([
            self.appliance,
            str(data['RaidBatteryModuleStatus']['ControllerID']),
            str(data['RaidBatteryModuleStatus']['Status'])
        ], data['RaidBatteryModuleStatus']['DesignCapacity'] / 1000)
        yield g

        g = GaugeMetricFamily('mqa_raid_battery_module_design_voltage_volts',
                              'The designed voltage of the battery in volts',
                              labels=['appliance', 'controllerID', 'status'])
        g.add_metric([
            self.appliance,
            str(data['RaidBatteryModuleStatus']['ControllerID']),
            str(data['RaidBatteryModuleStatus']['Status'])
        ], data['RaidBatteryModuleStatus']['DesignVoltage'] / 1000)
        yield g

        i = InfoMetricFamily('mqa_raid_battery_module',
                             'MQ Appliance raid battery module information')
        i.add_metric(
            [
                'appliance', 'controllerID', 'batteryType', 'serial', 'name',
                'status'
            ], {
                'appliance':
                self.appliance,
                'controllerID':
                str(data['RaidBatteryModuleStatus']['ControllerID']),
                'batteryType':
                data['RaidBatteryModuleStatus']['BatteryType'],
                'serial':
                data['RaidBatteryModuleStatus']['Serial'],
                'name':
                data['RaidBatteryModuleStatus']['Name'],
                'status':
                data['RaidBatteryModuleStatus']['Status']
            })

        g = GaugeMetricFamily(
            'mqa_exporter_raid_battery_module_elapsed_time_seconds',
            'Exporter eleapsed time to collect raid battery module metrics',
            labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g
Пример #15
0
    def collect(self):

        start = time.time()

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

        # Update Prometheus metrics
        for rpd in data['RaidPhysicalDriveStatus']:

            c = CounterMetricFamily(
                'mqa_raid_physical_drive_progress_percent_total',
                'The current progress percentage of the operation on the physical drive. Operations can be rebuild, copyback, patrol, or clear',
                labels=[
                    'appliance', 'controllerID', 'deviceID', 'arrayID',
                    'logicalDriveID', 'position'
                ])
            c.add_metric([
                self.appliance,
                str(rpd['ControllerID']),
                str(rpd['DeviceID']),
                str(rpd['ArrayID']),
                str(rpd['LogicalDriveID']), rpd['Position']
            ], rpd['ProgressPercent'])
            yield c

            c = CounterMetricFamily(
                'mqa_raid_physical_drive_raw_size_bytes_total',
                'The exact size of the drive in bytes',
                labels=[
                    'appliance', 'controllerID', 'deviceID', 'arrayID',
                    'logicalDriveID', 'position'
                ])
            c.add_metric([
                self.appliance,
                str(rpd['ControllerID']),
                str(rpd['DeviceID']),
                str(rpd['ArrayID']),
                str(rpd['LogicalDriveID']), rpd['Position']
            ], rpd['RawSize'] * 1000000)
            yield c

            c = CounterMetricFamily(
                'mqa_raid_physical_drive_coerced_size_bytes_total',
                'The normalized size in megabytes. The value is rounded down to an even multiple, which allows you to swap drives of the same nominal size but might not be the same raw size',
                labels=[
                    'appliance', 'controllerID', 'deviceID', 'arrayID',
                    'logicalDriveID', 'position'
                ])
            c.add_metric([
                self.appliance,
                str(rpd['ControllerID']),
                str(rpd['DeviceID']),
                str(rpd['ArrayID']),
                str(rpd['LogicalDriveID']), rpd['Position']
            ], rpd['CoercedSize'] * 1000000)
            yield c

            if rpd['Temperature'][:3] == 'n/a':
                temperature_celsius = -1
            else:
                temperature_celsius = int(rpd['Temperature'][:3])
            g = GaugeMetricFamily(
                'mqa_raid_physical_drive_temperature_celsius',
                'The temperature of the hard disk drive in celsius',
                labels=[
                    'appliance', 'controllerID', 'deviceID', 'arrayID',
                    'logicalDriveID', 'position'
                ])
            g.add_metric([
                self.appliance,
                str(rpd['ControllerID']),
                str(rpd['DeviceID']),
                str(rpd['ArrayID']),
                str(rpd['LogicalDriveID']), rpd['Position']
            ], temperature_celsius)
            yield g

            g = GaugeMetricFamily(
                'mqa_raid_physical_drive_failure',
                'If the hard disk failure state shows Yes, replace this drive as soon as possible to avoid possible data loss',
                labels=[
                    'appliance', 'controllerID', 'deviceID', 'arrayID',
                    'logicalDriveID', 'position'
                ])
            g.add_metric([
                self.appliance,
                str(rpd['ControllerID']),
                str(rpd['DeviceID']),
                str(rpd['ArrayID']),
                str(rpd['LogicalDriveID']), rpd['Position']
            ], 0 if rpd['Failure'] == 'No' else 1)
            yield g

            i = InfoMetricFamily(
                'mqa_raid_physical_drive',
                'MQ Appliance raid physical drive information')
            i.add_metric(
                [
                    'appliance', 'controllerID', 'deviceID', 'arrayID',
                    'logicalDriveID', 'logicalDriveName', 'position', 'state',
                    'interfaceType', 'interfaceSpeed', 'sasAddress',
                    'vendorID', 'productID', 'revision', 'specificInfo',
                    'failure'
                ], {
                    'appliance': self.appliance,
                    'controllerID': str(rpd['ControllerID']),
                    'deviceID': str(rpd['DeviceID']),
                    'arrayID': str(rpd['ArrayID']),
                    'logicalDriveID': str(rpd['LogicalDriveID']),
                    'logicalDriveName': rpd['LogicalDriveName'],
                    'position': rpd['Position'],
                    'state': rpd['State'],
                    'interfaceType': rpd['InterfaceType'],
                    'interfaceSpeed': rpd['InterfaceSpeed'],
                    'sasAddress': rpd['SASaddress'],
                    'vendorID': rpd['VendorID'],
                    'productID': rpd['ProductID'],
                    'revision': rpd['Revision'],
                    'specificInfo': rpd['SpecificInfo']
                })
            yield i

        g = GaugeMetricFamily(
            'mqa_exporter_raid_physical_drive_elapsed_time_seconds',
            'Exporter eleapsed time to collect raid physical drive metrics',
            labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g
    def collect(self):

        start = time.time()

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

        # Update Prometheus metrics
        for vs in data['VoltageSensors']:

            if vs['Name'] == 'Power Supply 1 In Voltage':
                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_power_supply_1_in_voltage_volts',
                    'Voltage going in power supply 1 in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['Value'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_power_supply_1_in_lower_critical_thereshold_voltage_volts',
                    'Lower critical threshold of voltage going in power supply 1 in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['LowerCriticalThreshold'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_power_supply_1_in_upper_critical_thereshold_voltage_volts',
                    'Upper critical threshold of voltage going in power supply 1 in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['UpperCriticalThreshold'] / 1000)
                yield g

                continue

            if vs['Name'] == 'Power Supply 1 Out Voltage':
                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_power_supply_1_out_voltage_volts',
                    'Voltage going out power supply 1 in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['Value'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_power_supply_1_out_lower_critical_thereshold_voltage_volts',
                    'Lower critical threshold of voltage going out power supply 1 in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['LowerCriticalThreshold'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_power_supply_1_out_upper_critical_thereshold_voltage_volts',
                    'Upper critical threshold of voltage going out power supply 1 in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['UpperCriticalThreshold'] / 1000)
                yield g

                continue

            if vs['Name'] == 'Power Supply 2 In Voltage':
                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_power_supply_2_in_voltage_volts',
                    'Voltage going in power supply 2 in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['Value'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_power_supply_2_in_lower_critical_thereshold_voltage_volts',
                    'Lower critical threshold of voltage going in power supply 2 in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['LowerCriticalThreshold'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_power_supply_2_in_upper_critical_thereshold_voltage_volts',
                    'Upper critical threshold of voltage going in power supply 2 in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['UpperCriticalThreshold'] / 1000)
                yield g

                continue

            if vs['Name'] == 'Power Supply 2 Out Voltage':
                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_power_supply_2_out_voltage_volts',
                    'Voltage going out power supply 2 in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['Value'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_power_supply_2_out_lower_critical_thereshold_voltage_volts',
                    'Lower critical threshold of voltage going out power supply 2 in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['LowerCriticalThreshold'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_power_supply_2_out_upper_critical_thereshold_voltage_volts',
                    'Upper critical threshold of voltage going out power supply 2 in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['UpperCriticalThreshold'] / 1000)
                yield g

                continue

            if vs['Name'] == 'Voltage +1.5':
                g = GaugeMetricFamily('mqa_voltage_sensor_voltage_15_volts',
                                      'Voltage +1.5 in volts',
                                      labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['Value'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_15_lower_critical_thereshold_voltage_volts',
                    'Lower critical threshold of +1.5 voltage in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['LowerCriticalThreshold'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_15_upper_critical_thereshold_voltage_volts',
                    'Upper critical threshold of +1.5 voltage in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['UpperCriticalThreshold'] / 1000)
                yield g

                continue

            if vs['Name'] == 'Voltage +1.8':
                g = GaugeMetricFamily('mqa_voltage_sensor_voltage_18_volts',
                                      'Voltage +1.8 in volts',
                                      labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['Value'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_18_lower_critical_thereshold_voltage_volts',
                    'Lower critical threshold of +1.8 voltage in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['LowerCriticalThreshold'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_18_upper_critical_thereshold_voltage_volts',
                    'Upper critical threshold of +1.8 voltage in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['UpperCriticalThreshold'] / 1000)
                yield g

                continue

            if vs['Name'] == 'Voltage +12':
                g = GaugeMetricFamily('mqa_voltage_sensor_voltage_12_volts',
                                      'Voltage +12 in volts',
                                      labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['Value'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_12_lower_critical_thereshold_voltage_volts',
                    'Lower critical threshold of +12 voltage in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['LowerCriticalThreshold'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_12_upper_critical_thereshold_voltage_volts',
                    'Upper critical threshold of +12 voltage in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['UpperCriticalThreshold'] / 1000)
                yield g

                continue

            if vs['Name'] == 'Voltage +3.3':
                g = GaugeMetricFamily('mqa_voltage_sensor_voltage_33_volts',
                                      'Voltage +3.3 in volts',
                                      labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['Value'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_33_lower_critical_thereshold_voltage_volts',
                    'Lower critical threshold of +3.3 voltage in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['LowerCriticalThreshold'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_33_upper_critical_thereshold_voltage_volts',
                    'Upper critical threshold of +3.3 voltage +3.3 in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['UpperCriticalThreshold'] / 1000)
                yield g

                continue

            if vs['Name'] == 'Voltage +5':
                g = GaugeMetricFamily('mqa_voltage_sensor_voltage_5_volts',
                                      'Voltage +5 in volts',
                                      labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['Value'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_5_lower_critical_thereshold_voltage_volts',
                    'Lower critical threshold of +5 voltage in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['LowerCriticalThreshold'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_5_upper_critical_thereshold_voltage_volts',
                    'Upper critical threshold of +5 voltage in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['UpperCriticalThreshold'] / 1000)
                yield g

                continue

            if vs['Name'] == 'Voltage +5 Standby':
                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_5_standby_volts',
                    'Voltage +5 standby in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['Value'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_5_standby_lower_critical_thereshold_voltage_volts',
                    'Lower critical threshold of +5 standby voltage in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['LowerCriticalThreshold'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_5_standby_upper_critical_thereshold_voltage_volts',
                    'Upper critical threshold of +5 standby voltage in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['UpperCriticalThreshold'] / 1000)
                yield g

                continue

            if vs['Name'] == 'Voltage Battery':
                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_battery_volts',
                    'Voltage battery in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['Value'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_battery_lower_critical_thereshold_voltage_volts',
                    'Lower critical threshold of battery voltage in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['LowerCriticalThreshold'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_battery_upper_critical_thereshold_voltage_volts',
                    'Upper critical threshold of battery voltage in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['UpperCriticalThreshold'] / 1000)
                yield g

                continue

            if vs['Name'] == 'Voltage CPU1 Core':
                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_cpu_1_core_volts',
                    'Voltage CPU 1 core in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['Value'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_cpu_1_core_lower_critical_thereshold_voltage_volts',
                    'Lower critical threshold of CPU 1 core voltage in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['LowerCriticalThreshold'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_cpu_1_core_upper_critical_thereshold_voltage_volts',
                    'Upper critical threshold of CPU 1 core voltage in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['UpperCriticalThreshold'] / 1000)
                yield g

                continue

            if vs['Name'] == 'Voltage CPU2 Core':
                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_cpu_2_core_volts',
                    'Voltage CPU 2 core in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['Value'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_cpu_2_core_lower_critical_thereshold_voltage_volts',
                    'Lower critical threshold of CPU 2 core voltage in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['LowerCriticalThreshold'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_voltage_sensor_voltage_cpu_2_core_upper_critical_thereshold_voltage_volts',
                    'Upper critical threshold of CPU 2 core voltage in volts',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, vs['ReadingStatus']],
                             vs['UpperCriticalThreshold'] / 1000)
                yield g

                continue

        g = GaugeMetricFamily(
            'mqa_exporter_voltage_sensors_elapsed_time_seconds',
            'Exporter eleapsed time to collect voltage sensors metrics',
            labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g
Пример #17
0
    def collect(self):

        start = time.time()

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

        # Update Prometheus metrics
        for ni in data['NetworkInterfaceStatus']:

            c = CounterMetricFamily(
                'mqa_network_interface_rx_bytes_total',
                'The amount of data successfully received on the interface, which includes MAC framing overhead',
                labels=['appliance', 'name', 'adminStatus', 'operStatus'])
            c.add_metric([
                self.appliance, ni['Name'], ni['AdminStatus'], ni['OperStatus']
            ], ni['RxHCBytes'])
            yield c

            c = CounterMetricFamily(
                'mqa_network_interface_rx_packets_total',
                'The number of packets successfully received on the interface that were passed up to the network layer for processing',
                labels=['appliance', 'name', 'adminStatus', 'operStatus'])
            c.add_metric([
                self.appliance, ni['Name'], ni['AdminStatus'], ni['OperStatus']
            ], ni['RxHCPackets'])
            yield c

            c = CounterMetricFamily(
                'mqa_network_interface_rx_errors_total',
                'The number of packets that could not be received due to errors in the packet or in the hardware',
                labels=['appliance', 'name', 'adminStatus', 'operStatus'])
            c.add_metric([
                self.appliance, ni['Name'], ni['AdminStatus'], ni['OperStatus']
            ], ni['RxErrors2'])
            yield c

            c = CounterMetricFamily(
                'mqa_network_interface_rx_drops_total',
                'The number of received packets that were not in error, but were not passed up to the network layer due to resource constraints',
                labels=['appliance', 'name', 'adminStatus', 'operStatus'])
            c.add_metric([
                self.appliance, ni['Name'], ni['AdminStatus'], ni['OperStatus']
            ], ni['RxDrops2'])
            yield c

            c = CounterMetricFamily(
                'mqa_network_interface_tx_bytes_total',
                'The amount of data successfully transmitted on the interface, which includes MAC framing overhead',
                labels=['appliance', 'name', 'adminStatus', 'operStatus'])
            c.add_metric([
                self.appliance, ni['Name'], ni['AdminStatus'], ni['OperStatus']
            ], ni['TxHCBytes'])
            yield c

            c = CounterMetricFamily(
                'mqa_network_interface_tx_packets_total',
                'The number of packets successfully transmitted on the interface',
                labels=['appliance', 'name', 'adminStatus', 'operStatus'])
            c.add_metric([
                self.appliance, ni['Name'], ni['AdminStatus'], ni['OperStatus']
            ], ni['TxHCPackets'])
            yield c

            c = CounterMetricFamily(
                'mqa_network_interface_tx_errors_total',
                'The number of packets that were not successfully transmitted due to errors on the network or in the hardware',
                labels=['appliance', 'name', 'adminStatus', 'operStatus'])
            c.add_metric([
                self.appliance, ni['Name'], ni['AdminStatus'], ni['OperStatus']
            ], ni['TxErrors2'])
            yield c

            c = CounterMetricFamily(
                'mqa_network_interface_tx_drops_total',
                'The number of packets that were not transmitted because the network layer was generating packets faster than the physical network could accept them',
                labels=['appliance', 'name', 'adminStatus', 'operStatus'])
            c.add_metric([
                self.appliance, ni['Name'], ni['AdminStatus'], ni['OperStatus']
            ], ni['TxDrops2'])
            yield c

            i = InfoMetricFamily(
                'mqa_network_interface',
                'MQ Appliance network interfaces information')
            i.add_metric(
                [
                    'appliance', 'interfaceIndex', 'interfaceType', 'name',
                    'adminStatus', 'operStatus', 'ipType', 'ip',
                    'prefixLength', 'macAddress', 'mtu'
                ], {
                    'appliance': self.appliance,
                    'interfaceIndex': str(ni['InterfaceIndex']),
                    'interfaceType': ni['InterfaceType'],
                    'name': ni['Name'],
                    'adminStatus': ni['AdminStatus'],
                    'operStatus': ni['OperStatus'],
                    'ipType': ni['IPType'],
                    'ip': ni['IP'],
                    'prefixLength': str(ni['PrefixLength']),
                    'macAddress': ni['MACAddress'],
                    'mtu': str(ni['MTU'])
                })
            yield i

        g = GaugeMetricFamily(
            'mqa_exporter_network_interfaces_elapsed_time_seconds',
            'Exporter eleapsed time to collect network interfaces metrics',
            labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g
Пример #18
0
    def collect(self):

        start = time.time()

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

        # Update Prometheus metrics
        g = GaugeMetricFamily(
            'mqa_tcp_connections_established',
            'The number of TCP connections in the established state. Connections in this state have completed all handshakes and can transfer data in either direction',
            labels=['appliance'])
        g.add_metric([self.appliance], data['TCPSummary']['established'])
        yield g

        g = GaugeMetricFamily(
            'mqa_tcp_connections_syn_sent',
            'The number of TCP connections in the syn-sent state. Connections in this state are waiting for a matching connection request after sending a connection request',
            labels=['appliance'])
        g.add_metric([self.appliance], data['TCPSummary']['syn_sent'])
        yield g

        g = GaugeMetricFamily(
            'mqa_tcp_connections_syn_received',
            'The number of TCP connections in the syn-received state. Connections in this state are waiting for a confirming connection request acknowledgment after both receiving and sending a connection request',
            labels=['appliance'])
        g.add_metric([self.appliance], data['TCPSummary']['syn_received'])
        yield g

        g = GaugeMetricFamily(
            'mqa_tcp_connections_fin_wait_1',
            'The number of TCP connections in the fin-wait-1 state. Connections in this state are waiting for a connection termination request from the remote TCP or an acknowledgment of the connection termination request previously sent',
            labels=['appliance'])
        g.add_metric([self.appliance], data['TCPSummary']['fin_wait_1'])
        yield g

        g = GaugeMetricFamily(
            'mqa_tcp_connections_fin_wait_2',
            'The number of TCP connections in the fin-wait-2 state. Connections in this state are waiting for a connection termination request from the remote TCP',
            labels=['appliance'])
        g.add_metric([self.appliance], data['TCPSummary']['fin_wait_2'])
        yield g

        g = GaugeMetricFamily(
            'mqa_tcp_connections_time_wait',
            'The number of TCP connections in the time-wait state. Connections in this state are waiting for enough time to pass to be sure that the remote TCP received the acknowledgment of its connection termination request',
            labels=['appliance'])
        g.add_metric([self.appliance], data['TCPSummary']['time_wait'])
        yield g

        g = GaugeMetricFamily(
            'mqa_tcp_connections_closed',
            'The number of TCP connections in the closed state. This state represents no connection state at all',
            labels=['appliance'])
        g.add_metric([self.appliance], data['TCPSummary']['closed'])
        yield g

        g = GaugeMetricFamily(
            'mqa_tcp_connections_close_wait',
            'The number of TCP connections in the close-wait state. Connections in this state are waiting for a connection termination request from the local user',
            labels=['appliance'])
        g.add_metric([self.appliance], data['TCPSummary']['close_wait'])
        yield g

        g = GaugeMetricFamily(
            'mqa_tcp_connections_last_ack',
            'The number of TCP connections in the last-ack state. Connections in this state are waiting for an acknowledgment of the connection termination request previously sent to the remote TCP (which includes an acknowledgment of its connection termination request)',
            labels=['appliance'])
        g.add_metric([self.appliance], data['TCPSummary']['last_ack'])
        yield g

        g = GaugeMetricFamily(
            'mqa_tcp_connections_listen',
            'The number of TCP connections in the listen state. Connections in the listen state are waiting for a connection request from any remote TCP and port',
            labels=['appliance'])
        g.add_metric([self.appliance], data['TCPSummary']['listen'])
        yield g

        g = GaugeMetricFamily(
            'mqa_tcp_connections_closing',
            'The number of TCP connections in the closing state. Connections in this state are waiting for a connection termination request acknowledgment from the remote TCP',
            labels=['appliance'])
        g.add_metric([self.appliance], data['TCPSummary']['closing'])
        yield g

        g = GaugeMetricFamily(
            'mqa_exporter_tcp_summary_elapsed_time_seconds',
            'Exporter eleapsed time to collect tcp summary metrics',
            labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g
Пример #19
0
    def collect(self):

        start = time.time()

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

        logTargets = []

        if type(data['LogTargetStatus']) is dict:
            logTargets.append(data['LogTargetStatus'])
        else:
            logTargets = data['LogTargetStatus']

        # Update Prometheus metrics
        for lt in logTargets:

            c = CounterMetricFamily(
                'mqa_log_target_events_processed_total',
                'The number of events that this log target processed',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, lt['LogTarget']['value']],
                         lt['EventsProcessed'])
            yield c

            c = CounterMetricFamily(
                'mqa_log_target_events_dropped_total',
                'The number of events that this log target dropped because there are too many pending events',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, lt['LogTarget']['value']],
                         lt['EventsDropped'])
            yield c

            c = CounterMetricFamily(
                'mqa_log_target_events_pending_total',
                'The number of pending events for this log target. These events are waiting to be stored at the destination',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, lt['LogTarget']['value']],
                         lt['EventsPending'])
            yield c

            c = CounterMetricFamily(
                'mqa_log_target_memory_requested_total',
                'The requested memory for this log target. This measurement represents the high watermark of memory requested',
                labels=['appliance', 'name'])
            c.add_metric([self.appliance, lt['LogTarget']['value']],
                         lt['RequestedMemory'])
            yield c

            i = InfoMetricFamily('mqa_log_target',
                                 'MQ Appliance log target information')
            i.add_metric(
                ['appliance', 'name', 'href', 'status', 'errorInfo'], {
                    'appliance': self.appliance,
                    'name': lt['LogTarget']['value'],
                    'href': lt['LogTarget']['href'],
                    'status': lt['Status'],
                    'errorInfo': lt['ErrorInfo']
                })
            yield i

        g = GaugeMetricFamily(
            'mqa_exporter_log_targets_elapsed_time_seconds',
            'Exporter eleapsed time to collect log targets metrics',
            labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g
    def collect(self):

        start = time.time()

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

        # Update Prometheus metrics
        g = GaugeMetricFamily(
            'mqa_file_system_encrypted_bytes_free',
            'Free, or unused and available, encrypted storage space on the appliance',
            labels=['appliance'])
        g.add_metric([self.appliance],
                     data['FilesystemStatus']['FreeEncrypted'] * 1000000)
        yield g

        c = CounterMetricFamily(
            'mqa_file_system_encrypted_bytes_total',
            'Total encrypted storage space on the appliance (the maximum capacity)',
            labels=['appliance'])
        c.add_metric([self.appliance],
                     data['FilesystemStatus']['TotalEncrypted'] * 1000000)
        yield c

        g = GaugeMetricFamily(
            'mqa_file_system_temporary_bytes_free',
            'Free, or unused and available, temporary storage space on the appliance',
            labels=['appliance'])
        g.add_metric([self.appliance],
                     data['FilesystemStatus']['FreeTemporary'] * 1000000)
        yield g

        c = CounterMetricFamily(
            'mqa_file_system_temporary_bytes_total',
            'Total temporary storage space on the appliance',
            labels=['appliance'])
        c.add_metric([self.appliance],
                     data['FilesystemStatus']['TotalTemporary'] * 1000000)
        yield c

        g = GaugeMetricFamily(
            'mqa_file_system_internal_bytes_free',
            'Free, or unused and available, internal storage space on the appliance',
            labels=['appliance'])
        g.add_metric([self.appliance],
                     data['FilesystemStatus']['FreeInternal'] * 1000000)
        yield g

        c = CounterMetricFamily(
            'mqa_file_system_internal_bytes_total',
            'Total internal storage space on the appliance',
            labels=['appliance'])
        c.add_metric([self.appliance],
                     data['FilesystemStatus']['TotalInternal'] * 1000000)
        yield c

        g = GaugeMetricFamily(
            'mqa_exporter_file_system_elapsed_time_seconds',
            'Exporter eleapsed time to collect file system metrics',
            labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g
Пример #21
0
    def collect(self):

        start = time.time()

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

        # Update Prometheus metrics
        for cs in data['CurrentSensors']:

            if cs['Name'] == 'Power Supply 1 In Current':
                g = GaugeMetricFamily(
                    'mqa_current_sensors_power_supply_1_in_current_upper_critical_threshold_amperes',
                    'Upper critical threshold for current going into power supply 1',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, cs['ReadingStatus']],
                             cs['UpperCriticalThreshold'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_current_sensors_power_supply_1_in_current_amperes',
                    'Current going into power supply 1',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, cs['ReadingStatus']],
                             cs['Value'] / 1000)
                yield g

            if cs['Name'] == 'Power Supply 1 Out Current':
                g = GaugeMetricFamily(
                    'mqa_current_sensors_power_supply_1_out_current_upper_critical_threshold_amperes',
                    'Upper critical threshold for current going out power supply 1',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, cs['ReadingStatus']],
                             cs['UpperCriticalThreshold'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_current_sensors_power_supply_1_out_current_amperes',
                    'Current going out power supply 1',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, cs['ReadingStatus']],
                             cs['Value'] / 1000)
                yield g

            if cs['Name'] == 'Power Supply 2 In Current':
                g = GaugeMetricFamily(
                    'mqa_current_sensors_power_supply_2_in_current_upper_critical_threshold_amperes',
                    'Upper critical threshold for current going into power supply 2',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, cs['ReadingStatus']],
                             cs['UpperCriticalThreshold'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_current_sensors_power_supply_2_in_current_amperes',
                    'Current going into power supply 2',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, cs['ReadingStatus']],
                             cs['Value'] / 1000)
                yield g

            if cs['Name'] == 'Power Supply 2 Out Current':
                g = GaugeMetricFamily(
                    'mqa_current_sensors_power_supply_2_out_current_upper_critical_threshold_amperes',
                    'Upper critical threshold for current going out power supply 2',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, cs['ReadingStatus']],
                             cs['UpperCriticalThreshold'] / 1000)
                yield g

                g = GaugeMetricFamily(
                    'mqa_current_sensors_power_supply_2_out_current_amperes',
                    'Current going out power supply 2',
                    labels=['appliance', 'readingStatus'])
                g.add_metric([self.appliance, cs['ReadingStatus']],
                             cs['Value'] / 1000)
                yield g

        g = GaugeMetricFamily(
            'mqa_exporter_current_sensors_elapsed_time_seconds',
            'Exporter eleapsed time to collect current sensors metrics',
            labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g
    def collect(self):

        start = time.time()

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

        if data == '' or data2 == '' or data3 == '':
            return

        # Update Prometheus metrics
        c = CounterMetricFamily(
            'mqa_bootcount',
            'The number of times the firmware image was restarted through an appliance reboot or a firmware reload. The count is from the initial firmware load on the appliance till the current time. The count is independent of firmware version',
            labels=['appliance'])
        c.add_metric([self.appliance], data2['FirmwareStatus']['BootCount'])
        yield c

        uptime_split = data['DateTimeStatus']['uptime2'].split(' ')
        days = int(uptime_split[0])
        hours = int(uptime_split[2][0:2])
        minutes = int(uptime_split[2][3:5])
        seconds = int(uptime_split[2][6:])
        uptime_seconds = days * 86400 + hours * 3600 + minutes * 60 + seconds

        c = CounterMetricFamily(
            'mqa_uptime_seconds',
            'The total amount of time in seconds the appliance has been up since the last reload or reboot. Note that a shutdown and reload resets this counter',
            labels=['appliance'])
        c.add_metric([self.appliance], uptime_seconds)
        yield c

        bootuptime_split = data['DateTimeStatus']['bootuptime2'].split(' ')
        days = int(bootuptime_split[0])
        hours = int(bootuptime_split[2][0:2])
        minutes = int(bootuptime_split[2][3:5])
        seconds = int(bootuptime_split[2][6:])
        bootuptime_seconds = days * 86400 + hours * 3600 + minutes * 60 + seconds

        c = CounterMetricFamily(
            'mqa_bootuptime_seconds',
            'The total amount of time in seconds since the last reboot. Note that this counter is reset by a shutdown and reboot, but not by a shutdown and reload',
            labels=['appliance'])
        c.add_metric([self.appliance], bootuptime_seconds)
        yield c

        c = CounterMetricFamily(
            'mqa_current_datetime_seconds',
            'The current date and time of the MQ Appliance in epoch seconds',
            labels=['appliance'])
        c.add_metric([self.appliance],
                     datetime_to_epoch(data['DateTimeStatus']['time'],
                                       '%a %b %d %H:%M:%S %Y'))
        yield c

        i = InfoMetricFamily('mqa', 'MQ Appliance information')
        i.add_metric(
            [
                'appliance', 'timezone', 'tzspec', 'type', 'installdate',
                'serial', 'version', 'level', 'build', 'builddate',
                'deliverytype', 'watchdogbuild', 'installeddpos',
                'runningdpos', 'xmlaccelerator', 'machinetype', 'modeltype'
            ], {
                'appliance': self.appliance,
                'timezone': data['DateTimeStatus']['timezone'],
                'tzspec': data['DateTimeStatus']['tzspec'],
                'type': data2['FirmwareStatus']['Type'],
                'installdate': data2['FirmwareStatus']['InstallDate'],
                'serial': data3['FirmwareVersion3']['Serial'],
                'version': data3['FirmwareVersion3']['Version'],
                'level': data3['FirmwareVersion3']['Level'],
                'build': data3['FirmwareVersion3']['Build'],
                'builddate': data3['FirmwareVersion3']['BuildDate'],
                'deliverytype': data3['FirmwareVersion3']['DeliveryType'],
                'watchdogbuild': data3['FirmwareVersion3']['WatchdogBuild'],
                'installeddpos': data3['FirmwareVersion3']['InstalledDPOS'],
                'runningdpos': data3['FirmwareVersion3']['RunningDPOS'],
                'xmlaccelerator': data3['FirmwareVersion3']['XMLAccelerator'],
                'machinetype': data3['FirmwareVersion3']['MachineType'],
                'modeltype': data3['FirmwareVersion3']['ModelType']
            })
        yield i

        g = GaugeMetricFamily(
            'mqa_exporter_mqa_information_elapsed_time_seconds',
            'Exporter eleapsed time to collect mqa information metrics',
            labels=['appliance'])
        g.add_metric([self.appliance], time.time() - start)
        yield g