(self, lines, tcp_states, state_col, protocol=None, ip_version=None)
return metrics
Parse the output of the command that retrieves the connection state (either `ss` or `netstat`)
        Returns a dict metric_name -> value
Parse the output of the command that retrieves the connection state (either `ss` or `netstat`)
        Returns a dict metric_name -> value
Parse the output of the command that retrieves the connection state ( either ss or netstat ) Returns a dict metric_name - > value
def _parse_linux_cx_state(self, lines, tcp_states, state_col, protocol=None, ip_version=None):
        """
        Parse the output of the command that retrieves the connection state (either `ss` or `netstat`)
        Returns a dict metric_name -> value
        """
        metrics = self._get_metrics()
        for l in lines:
            cols = l.split()
            if cols[0].startswith('tcp') or protocol == 'tcp':
                proto = "tcp{0}".format(ip_version) if ip_version else ("tcp4", "tcp6")[cols[0] == "tcp6"]
                if cols[state_col] in tcp_states:
                    metric = self.cx_state_gauge[proto, tcp_states[cols[state_col]]]
                    metrics[metric] += 1
            elif cols[0].startswith('udp') or protocol == 'udp':
                proto = "udp{0}".format(ip_version) if ip_version else ("udp4", "udp6")[cols[0] == "udp6"]
                metric = self.cx_state_gauge[proto, 'connections']
                metrics[metric] += 1

        return metrics
def _parse_linux_cx_state ( self , lines , tcp_states , state_col , protocol = None , ip_version = None ) : metrics = self . _get_metrics ( ) for l in lines : cols = l . split ( ) if cols [ 0 ] . startswith ( 'tcp' ) or protocol == 'tcp' : proto = "tcp{0}" . format ( ip_version ) if ip_version else ( "tcp4" , "tcp6" ) [ cols [ 0 ] == "tcp6" ] if cols [ state_col ] in tcp_states : metric = self . cx_state_gauge [ proto , tcp_states [ cols [ state_col ] ] ] metrics [ metric ] += 1 elif cols [ 0 ] . startswith ( 'udp' ) or protocol == 'udp' : proto = "udp{0}" . format ( ip_version ) if ip_version else ( "udp4" , "udp6" ) [ cols [ 0 ] == "udp6" ] metric = self . cx_state_gauge [ proto , 'connections' ] metrics [ metric ] += 1 return metrics