Add ntp connection status metric
Also add new ntp-server dimension Change-Id: I0caf4ccc51693d0008fa509526a633280955cd6a Closes-Bug: #1616434
This commit is contained in:
parent
63bd7586e7
commit
1a9d3a8616
@ -1189,7 +1189,8 @@ The NTP checks return the following metrics:
|
|||||||
|
|
||||||
| Metric Name | Dimensions | Semantics |
|
| Metric Name | Dimensions | Semantics |
|
||||||
| ----------- | ---------- | --------- |
|
| ----------- | ---------- | --------- |
|
||||||
| ntp.offset | hostname | Time offset in seconds |
|
| ntp.offset | hostname, ntp_server | Time offset in seconds |
|
||||||
|
| ntp.connection_status | hostname, ntp_server | Value of ntp server connection status (0=Healthy) |
|
||||||
|
|
||||||
## Postfix Checks
|
## Postfix Checks
|
||||||
This section describes the Postfix checks that can be performed by the Agent. The Postfix checks gathers metrics on the Postfix. The Postfix checks requires a configuration file called postfix.yaml to be available in the agent conf.d configuration directory. The config file must contain the name, directory and queue that you are interested in monitoring.
|
This section describes the Postfix checks that can be performed by the Agent. The Postfix checks gathers metrics on the Postfix. The Postfix checks requires a configuration file called postfix.yaml to be available in the agent conf.d configuration directory. The config file must contain the name, directory and queue that you are interested in monitoring.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP
|
# (C) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
|
||||||
|
|
||||||
import ntplib
|
import ntplib
|
||||||
|
|
||||||
@ -22,11 +22,12 @@ class NtpCheck(AgentCheck):
|
|||||||
'version': int(instance.get('version', DEFAULT_NTP_VERSION)),
|
'version': int(instance.get('version', DEFAULT_NTP_VERSION)),
|
||||||
'timeout': float(instance.get('timeout', DEFAULT_TIMEOUT)),
|
'timeout': float(instance.get('timeout', DEFAULT_TIMEOUT)),
|
||||||
}
|
}
|
||||||
|
dimensions['ntp_server'] = req_args['host']
|
||||||
try:
|
try:
|
||||||
ntp_stats = ntplib.NTPClient().request(**req_args)
|
ntp_stats = ntplib.NTPClient().request(**req_args)
|
||||||
except ntplib.NTPException:
|
except ntplib.NTPException as err:
|
||||||
self.log.error("Could not connect to NTP Server")
|
self.log.error("Could not connect to NTP Server: %s" % err)
|
||||||
raise
|
self.gauge('ntp.connection_status', 1, dimensions=dimensions)
|
||||||
else:
|
else:
|
||||||
ntp_offset = ntp_stats.offset
|
ntp_offset = ntp_stats.offset
|
||||||
|
|
||||||
@ -34,3 +35,4 @@ class NtpCheck(AgentCheck):
|
|||||||
# case the agent host's clock is messed up.
|
# case the agent host's clock is messed up.
|
||||||
ntp_ts = ntp_stats.recv_time
|
ntp_ts = ntp_stats.recv_time
|
||||||
self.gauge('ntp.offset', ntp_offset, timestamp=ntp_ts, dimensions=dimensions)
|
self.gauge('ntp.offset', ntp_offset, timestamp=ntp_ts, dimensions=dimensions)
|
||||||
|
self.gauge('ntp.connection_status', 0, timestamp=ntp_ts, dimensions=dimensions)
|
||||||
|
Loading…
Reference in New Issue
Block a user