Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Massimiliano Pippi committed Jun 27, 2016
1 parent 9b68dca commit 8a69267
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions checks.d/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# stdlib
import re
import socket
from collections import defaultdict

# project
from checks import AgentCheck
Expand Down Expand Up @@ -558,13 +559,12 @@ def _cx_state_psutil(self):
"""
Collect metrics about connections state using psutil
"""
metrics = dict.fromkeys(self.CX_STATE_GAUGE.values(), 0)
metrics = defaultdict(int)
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:
print(protocol, status)
self.log.warning('Metric not found for: %s,%s', protocol, status)
else:
metrics[metric] += 1
Expand Down

0 comments on commit 8a69267

Please sign in to comment.