(self, conntrack_path, use_sudo_conntrack, tags)
Parse the output of conntrack -S
        Add the parsed metrics
Parse the output of conntrack -S
        Add the parsed metrics
Parse the output of conntrack - S Add the parsed metrics
def _add_conntrack_stats_metrics(self, conntrack_path, use_sudo_conntrack, tags):
        """
        Parse the output of conntrack -S
        Add the parsed metrics
        """
        try:
            cmd = [conntrack_path, "-S"]
            if use_sudo_conntrack:
                cmd.insert(0, "sudo")
            output, _, _ = get_subprocess_output(cmd, self.log)
            # conntrack -S sample:
            # cpu=0 found=27644 invalid=19060 ignore=485633411 insert=0 insert_failed=1 \
            #       drop=1 early_drop=0 error=0 search_restart=39936711
            # cpu=1 found=21960 invalid=17288 ignore=475938848 insert=0 insert_failed=1 \
            #       drop=1 early_drop=0 error=0 search_restart=36983181

            lines = output.splitlines()

            for line in lines:
                cols = line.split()
                cpu_num = cols[0].split('=')[-1]
                cpu_tag = ['cpu:{}'.format(cpu_num)]
                cols = cols[1:]

                for cell in cols:
                    metric, value = cell.split('=')
                    self.monotonic_count('system.net.conntrack.{}'.format(metric), int(value), tags=tags + cpu_tag)
        except SubprocessOutputEmptyError:
            self.log.debug("Couldn't use %s to get conntrack stats", conntrack_path)
def _add_conntrack_stats_metrics ( self , conntrack_path , use_sudo_conntrack , tags ) : try : cmd = [ conntrack_path , "-S" ] if use_sudo_conntrack : cmd . insert ( 0 , "sudo" ) output , _ , _ = get_subprocess_output ( cmd , self . log ) # conntrack -S sample: # cpu=0 found=27644 invalid=19060 ignore=485633411 insert=0 insert_failed=1 \ #       drop=1 early_drop=0 error=0 search_restart=39936711 # cpu=1 found=21960 invalid=17288 ignore=475938848 insert=0 insert_failed=1 \ #       drop=1 early_drop=0 error=0 search_restart=36983181 lines = output . splitlines ( ) for line in lines : cols = line . split ( ) cpu_num = cols [ 0 ] . split ( '=' ) [ - 1 ] cpu_tag = [ 'cpu:{}' . format ( cpu_num ) ] cols = cols [ 1 : ] for cell in cols : metric , value = cell . split ( '=' ) self . monotonic_count ( 'system.net.conntrack.{}' . format ( metric ) , int ( value ) , tags = tags + cpu_tag ) except SubprocessOutputEmptyError : self . log . debug ( "Couldn't use %s to get conntrack stats" , conntrack_path )