(self)
Collects resources usage of each process defined under the
        `process` subsection of the config file
Collects resources usage of each process defined under the
        `process` subsection of the config file
Collects resources usage of each process defined under the process subsection of the config file
def collect(self):
        """
        Collects resources usage of each process defined under the
        `process` subsection of the config file
        """
        if not psutil:
            self.log.error('Unable to import psutil')
            self.log.error('No process resource metrics retrieved')
            return None

        for process in psutil.process_iter():
            self.collect_process_info(process)

        # publish results
        for pg_name, counters in self.processes_info.iteritems():
            if counters:
                metrics = (
                    ("%s.%s" % (pg_name, key), value)
                    for key, value in counters.iteritems())
            else:
                if self.processes[pg_name]['count_workers']:
                    metrics = (('%s.workers_count' % pg_name, 0), )
                else:
                    metrics = ()

            [self.publish(*metric) for metric in metrics]
            # reinitialize process info
            self.processes_info[pg_name] = {}
def collect ( self ) : if not psutil : self . log . error ( 'Unable to import psutil' ) self . log . error ( 'No process resource metrics retrieved' ) return None for process in psutil . process_iter ( ) : self . collect_process_info ( process ) # publish results for pg_name , counters in self . processes_info . iteritems ( ) : if counters : metrics = ( ( "%s.%s" % ( pg_name , key ) , value ) for key , value in counters . iteritems ( ) ) else : if self . processes [ pg_name ] [ 'count_workers' ] : metrics = ( ( '%s.workers_count' % pg_name , 0 ) , ) else : metrics = ( ) [ self . publish ( * metric ) for metric in metrics ] # reinitialize process info self . processes_info [ pg_name ] = { }