@cryptotaxi247 / netdata-1 / commits / 6fcd770b8

Add dashboard info for portcheck plugin. Rearranged error codes

Chris committed Feb 20, 2018 at 20:12 UTC 6fcd770b8609de110b827ab443ed8cfc09a4c634
2 files changed +36 -11
python.d/portcheck.chart.py
+15 -11
@@ -24,9 +24,9 @@ CHARTS = {
24 ]}
25 }
26
27 -SOCKET_FAILED = 1
28 -CONNECTION_FAILED = 2
29 -CONNECTION_TIMED_OUT = 3
27 +CONNECTION_FAILED = 1
28 +CONNECTION_TIMED_OUT = 2
29 +SOCKET_FAILED = 3
30
31 TCP_DIMENSION_CONNECT_PREFIX = 'tcp_connect_'
32 TCP_DIMENSION_ERROR_PREFIX = 'tcp_error_'
@@ -78,14 +78,18 @@ class Service(SimpleService):
78
79 for port in self.ports:
80 success = False
81 - for socket_config in socket.getaddrinfo(self.host, port, socket.AF_UNSPEC, socket.SOCK_STREAM):
82 - # use first working socket
83 - sock = self._create_socket(socket_config)
84 - if sock is not None:
85 - self._connect2socket(data, socket_config, sock)
86 - self._disconnect(sock)
87 - success = True
88 - break
81 + try:
82 + for socket_config in socket.getaddrinfo(self.host, port, socket.AF_UNSPEC, socket.SOCK_STREAM):
83 + # use first working socket
84 + sock = self._create_socket(socket_config)
85 + if sock is not None:
86 + self._connect2socket(data, socket_config, sock)
87 + self._disconnect(sock)
88 + success = True
89 + break
90 + except socket.gaierror:
91 + success = False
92 + pass
93
94 # We could not connect
95 if not success:
web/dashboard_info.js
+21
@@ -219,6 +219,12 @@ netdataDashboard.menu = {
219 info: 'Performance metrics for <b>PHP-FPM</b>, an alternative FastCGI implementation for PHP.'
220 },
221
222 + 'portcheck': {
223 + title: 'Port Check',
224 + icon: '<i class="fas fa-heartbeat"></i>',
225 + info: 'Service availability and latency monitoring using port checks.'
226 + },
227 +
228 'postfix': {
229 title: 'postfix',
230 icon: '<i class="fas fa-envelope"></i>',
@@ -1718,6 +1724,21 @@ netdataDashboard.context = {
1724 valueRange: "[0, null]"
1725 },
1726
1727 + // ------------------------------------------------------------------------
1728 + // Port check
1729 +
1730 + 'portcheck.latency': {
1731 + info: 'The <code>Latency</code> describes the time spent opening and closing a socket. No data is sent or received. ' +
1732 + 'A response time of <code>0.0 ms</code> indicates a connection error.'
1733 + },
1734 +
1735 + 'portcheck.error': {
1736 + valueRange: "[0, 3]",
1737 + info: 'The <code>Error</code> is returned by the plugin when it could not connect to the host/port. It is one of: ' +
1738 + '<code>0</code> (connection successful), <code>1</code> (port closed), <code>2</code> (host or port timeout), <code>3</code> (hostname lookup failed). ' +
1739 + 'The error code is most useful for 3rd-party apps and alarms.'
1740 + },
1741 +
1742 // ------------------------------------------------------------------------
1743
1744 'chrony.system': {