(self)
Collect interrupt data
Collect interrupt data
Collect interrupt data
def collect(self):
        """
        Collect interrupt data
        """
        if not os.access(self.PROC, os.R_OK):
            return False

        # Open PROC file
        file = open(self.PROC, 'r')

        # Get data
        for line in file:

            if not line.startswith('softirq'):
                continue

            data = line.split()

            metric_name = 'total'
            metric_value = int(data[1])
            metric_value = int(self.derivative(
                metric_name,
                long(metric_value), counter))
            self.publish(metric_name, metric_value)

            for i in range(2, len(data)):
                metric_name = str(i - 2)
                metric_value = int(data[i])
                metric_value = int(self.derivative(
                    metric_name,
                    long(metric_value), counter))
                self.publish(metric_name, metric_value)

        # Close file
        file.close()
def collect ( self ) : if not os . access ( self . PROC , os . R_OK ) : return False # Open PROC file file = open ( self . PROC , 'r' ) # Get data for line in file : if not line . startswith ( 'softirq' ) : continue data = line . split ( ) metric_name = 'total' metric_value = int ( data [ 1 ] ) metric_value = int ( self . derivative ( metric_name , long ( metric_value ) , counter ) ) self . publish ( metric_name , metric_value ) for i in range ( 2 , len ( data ) ) : metric_name = str ( i - 2 ) metric_value = int ( data [ i ] ) metric_value = int ( self . derivative ( metric_name , long ( metric_value ) , counter ) ) self . publish ( metric_name , metric_value ) # Close file file . close ( )