(self, device, host, port, community)
Collect stats from device
Collect stats from device
Collect stats from device
def collect_snmp(self, device, host, port, community):
        """
        Collect stats from device
        """
        # Log
        self.log.info("Collecting ServerTech PDU statistics from: %s" % device)

        # Set timestamp
        timestamp = time.time()

        inputFeeds = {}

        # Collect PDU input gauge values
        for gaugeName, gaugeOid in self.PDU_SYSTEM_GAUGES.items():
            systemGauges = self.walk(gaugeOid, host, port, community)
            for o, gaugeValue in systemGauges.items():
                # Get Metric Name
                metricName = gaugeName
                # Get Metric Value
                metricValue = float(gaugeValue)
                # Get Metric Path
                metricPath = '.'.join(
                    ['devices', device, 'system', metricName])
                # Create Metric
                metric = Metric(metricPath, metricValue, timestamp, 2)
                # Publish Metric
                self.publish_metric(metric)

        # Collect PDU input feed names
        inputFeedNames = self.walk(
            self.PDU_INFEED_NAMES, host, port, community)
        for o, inputFeedName in inputFeedNames.items():
            # Extract input feed name
            inputFeed = ".".join(o.split(".")[-2:])
            inputFeeds[inputFeed] = inputFeedName

        # Collect PDU input gauge values
        for gaugeName, gaugeOid in self.PDU_INFEED_GAUGES.items():
            inputFeedGauges = self.walk(gaugeOid, host, port, community)
            for o, gaugeValue in inputFeedGauges.items():
                # Extract input feed name
                inputFeed = ".".join(o.split(".")[-2:])

                # Get Metric Name
                metricName = '.'.join([re.sub(r'\.|\\', '_',
                                              inputFeeds[inputFeed]),
                                       gaugeName])

                # Get Metric Value
                if gaugeName == "infeedVolts":
                    # Note: Voltage is in "tenth volts", so divide by 10
                    metricValue = float(gaugeValue) / 10.0
                elif gaugeName == "infeedAmps":
                    # Note: Amps is in "hundredth amps", so divide by 100
                    metricValue = float(gaugeValue) / 100.0
                else:
                    metricValue = float(gaugeValue)

                # Get Metric Path
                metricPath = '.'.join(['devices', device, 'input', metricName])
                # Create Metric
                metric = Metric(metricPath, metricValue, timestamp, 2)
                # Publish Metric
                self.publish_metric(metric)
def collect_snmp ( self , device , host , port , community ) : # Log self . log . info ( "Collecting ServerTech PDU statistics from: %s" % device ) # Set timestamp timestamp = time . time ( ) inputFeeds = { } # Collect PDU input gauge values for gaugeName , gaugeOid in self . PDU_SYSTEM_GAUGES . items ( ) : systemGauges = self . walk ( gaugeOid , host , port , community ) for o , gaugeValue in systemGauges . items ( ) : # Get Metric Name metricName = gaugeName # Get Metric Value metricValue = float ( gaugeValue ) # Get Metric Path metricPath = '.' . join ( [ 'devices' , device , 'system' , metricName ] ) # Create Metric metric = Metric ( metricPath , metricValue , timestamp , 2 ) # Publish Metric self . publish_metric ( metric ) # Collect PDU input feed names inputFeedNames = self . walk ( self . PDU_INFEED_NAMES , host , port , community ) for o , inputFeedName in inputFeedNames . items ( ) : # Extract input feed name inputFeed = "." . join ( o . split ( "." ) [ - 2 : ] ) inputFeeds [ inputFeed ] = inputFeedName # Collect PDU input gauge values for gaugeName , gaugeOid in self . PDU_INFEED_GAUGES . items ( ) : inputFeedGauges = self . walk ( gaugeOid , host , port , community ) for o , gaugeValue in inputFeedGauges . items ( ) : # Extract input feed name inputFeed = "." . join ( o . split ( "." ) [ - 2 : ] ) # Get Metric Name metricName = '.' . join ( [ re . sub ( r'\.|\\' , '_' , inputFeeds [ inputFeed ] ) , gaugeName ] ) # Get Metric Value if gaugeName == "infeedVolts" : # Note: Voltage is in "tenth volts", so divide by 10 metricValue = float ( gaugeValue ) / 10.0 elif gaugeName == "infeedAmps" : # Note: Amps is in "hundredth amps", so divide by 100 metricValue = float ( gaugeValue ) / 100.0 else : metricValue = float ( gaugeValue ) # Get Metric Path metricPath = '.' . join ( [ 'devices' , device , 'input' , metricName ] ) # Create Metric metric = Metric ( metricPath , metricValue , timestamp , 2 ) # Publish Metric self . publish_metric ( metric )