(self, tags=None)
Collect metrics about connections state using psutil
Collect metrics about connections state using psutil
Collect metrics about connections state using psutil
def _cx_state_psutil(self, tags=None):
        """
        Collect metrics about connections state using psutil
        """
        metrics = defaultdict(int)
        tags = [] if tags is None else tags
        for conn in psutil.net_connections():
            protocol = self._parse_protocol_psutil(conn)
            status = self.tcp_states['psutil'].get(conn.status)
            metric = self.cx_state_gauge.get((protocol, status))
            if metric is None:
                self.log.warning('Metric not found for: %s,%s', protocol, status)
            else:
                metrics[metric] += 1

        for metric, value in iteritems(metrics):
            self.gauge(metric, value, tags=tags)
def _cx_state_psutil ( self , tags = None ) : metrics = defaultdict ( int ) tags = [ ] if tags is None else tags for conn in psutil . net_connections ( ) : protocol = self . _parse_protocol_psutil ( conn ) status = self . tcp_states [ 'psutil' ] . get ( conn . status ) metric = self . cx_state_gauge . get ( ( protocol , status ) ) if metric is None : self . log . warning ( 'Metric not found for: %s,%s' , protocol , status ) else : metrics [ metric ] += 1 for metric , value in iteritems ( metrics ) : self . gauge ( metric , value , tags = tags )