diff options
author | Wing924 <weihe924stephen@gmail.com> | 2018-03-19 11:54:55 +0900 |
---|---|---|
committer | Wing924 <weihe924stephen@gmail.com> | 2018-03-19 11:54:55 +0900 |
commit | 51175f94a3302ffe99f8058cb7e155af7d497099 (patch) | |
tree | fd123ccff46f00a94ada58018f10f8408d2d5f07 | |
parent | 78f2feee95f01429615a0027ab1efa0345a8f1ed (diff) | |
parent | 0446e3a468b1becb174426cb08b1278283a586cd (diff) |
Merge branch 'master' into hist_web_log
-rw-r--r-- | conf.d/health.d/backend.conf | 2 | ||||
-rw-r--r-- | conf.d/python.d.conf | 1 | ||||
-rw-r--r-- | conf.d/python.d/ntpd.conf | 23 | ||||
-rw-r--r-- | configs.signatures | 4 | ||||
-rw-r--r-- | python.d/README.md | 11 | ||||
-rw-r--r-- | python.d/ntpd.chart.py | 17 | ||||
-rw-r--r-- | src/backends.c | 36 | ||||
-rw-r--r-- | web/dashboard_info.js | 102 |
8 files changed, 180 insertions, 16 deletions
diff --git a/conf.d/health.d/backend.conf b/conf.d/health.d/backend.conf index 9c193e7b92..7af100d8f4 100644 --- a/conf.d/health.d/backend.conf +++ b/conf.d/health.d/backend.conf @@ -27,7 +27,7 @@ units: metrics calc: abs($lost) every: 10s - crit: $this != 0 + crit: ($this != 0) || ($status == $CRITICAL && abs($sent) == 0) delay: down 5m multiplier 1.5 max 1h info: number of metrics lost due to repeating failures to contact the backend server to: dba diff --git a/conf.d/python.d.conf b/conf.d/python.d.conf index b250385ae0..bb57738bb0 100644 --- a/conf.d/python.d.conf +++ b/conf.d/python.d.conf @@ -56,6 +56,7 @@ go_expvar: no # nginx: yes # nginx_plus: yes # nsd: yes +# ntpd: yes # nginx_log has been replaced by web_log nginx_log: no diff --git a/conf.d/python.d/ntpd.conf b/conf.d/python.d/ntpd.conf index fcb02f9eb8..7adc4074b4 100644 --- a/conf.d/python.d/ntpd.conf +++ b/conf.d/python.d/ntpd.conf @@ -58,7 +58,10 @@ # # host: 'localhost' # the host to query # port: '123' # the UDP port where `ntpd` listens -# show_peers: no # use `yes` to show peer charts +# show_peers: no # use `yes` to show peer charts. enabling this +# # option is recommended only for debugging, as +# # it could possibly imply memory leaks if the +# # peers change frequently. # peer_filter: '127\..*' # regex to exclude peers # # by default local peers are hidden # # use `''` to show all peers. @@ -68,3 +71,21 @@ # ---------------------------------------------------------------------- # AUTO-DETECTION JOBS # only one of them will run (they have the same name) + +localhost: + name: 'local' + host: 'localhost' + port: '123' + show_peers: no + +localhost_ipv4: + name: 'local' + host: '127.0.0.1' + port: '123' + show_peers: no + +localhost_ipv6: + name: 'local' + host: '::1' + port: '123' + show_peers: no diff --git a/configs.signatures b/configs.signatures index 2a8729f109..de065bf438 100644 --- a/configs.signatures +++ b/configs.signatures @@ -111,6 +111,7 @@ declare -A configs_signatures=( ['29485dc362202095d3d80e4f744d0538']='health_alarm_notify.conf' ['297160ae7ee01a547ed14f857b4f2c8d']='health.d/memcached.conf' ['298504f331c55dff4055321ff3a7b5cc']='health.d/web_log.conf' + ['29c37d59e8801dffd18617738c1b4b71']='python.d.conf' ['29f97e10b92333790fbe0d2a3617b736']='health_alarm_notify.conf' ['2a0794fd43eadf30a51805bc9ba2c64d']='python.d/hddtemp.conf' ['2acae80dbdbe536a160f5b216bac84bc']='python.d/samba.conf' @@ -259,6 +260,7 @@ declare -A configs_signatures=( ['61b7ed36f35e7bd930f5f7f91694a112']='charts.d/postfix.conf' ['621f10b257a11add5ff5aff41e9662e3']='health.d/memcached.conf' ['623771eecb3c277fc728b5304793f93b']='health.d/cpu.conf' + ['6265b7465e38839c3543190e638156aa']='python.d/ntpd.conf' ['6319e4ae3810e9eabb61e852e1305785']='python.d.conf' ['632c28d714c87a4969d11cf36a5edaa8']='health.d/web_log.conf' ['636d032928ea0f4741eab264fb49c099']='apps_groups.conf' @@ -496,6 +498,7 @@ declare -A configs_signatures=( ['b7d769ce86a7aebba01315da5c0799e6']='health.d/ram.conf' ['b81b8f331161b0d48e03f6fbf6b6d062']='health.d/memcached.conf' ['b846ca1f99fa6a65303b58186f47d7a4']='python.d/squid.conf' + ['b854fcb711ee4d052741de5fc888682e']='health.d/backend.conf' ['b8969be5b3ceb4a99477937119bd4323']='python.d.conf' ['b8aff60806fb6829a4e72a824e655375']='health.d/beanstalkd.conf' ['b8b87574fd496a66ede884c5336493bd']='python.d/phpfpm.conf' @@ -605,6 +608,7 @@ declare -A configs_signatures=( ['e1822c48067954e26649f7ad5fdb71f5']='health.d/softnet.conf' ['e1a8bf99d36683c10225100f207a2b59']='python.d/web_log.conf' ['e22f30680148a29d9738bd4bfe8b252c']='health_alarm_notify.conf' + ['e2e7adf66a28b8277f55e246b007f25a']='python.d/ntpd.conf' ['e2f3388c06726154c10ec22bad5bc7ec']='fping.conf' ['e3023092e3b2bbb5351e0fe6682f4fe9']='health_alarm_notify.conf' ['e3112d8e06fa77888aab02e8fcd22e25']='apps_groups.conf' diff --git a/python.d/README.md b/python.d/README.md index 5df1ec726f..b67e56acee 100644 --- a/python.d/README.md +++ b/python.d/README.md @@ -1543,10 +1543,10 @@ Configuration is not needed. # ntpd -Module monitors the system variables of the local `ntpd` daemon (optional incl. variables of the polled peers) using the NTP Control Message Protocol via UDP socket, similar to `ntpq`. +Module monitors the system variables of the local `ntpd` daemon (optional incl. variables of the polled peers) using the NTP Control Message Protocol via UDP socket, similar to `ntpq`, the [standard NTP query program](http://doc.ntp.org/current-stable/ntpq.html). **Requirements:** - * Version of `ntpd` must be 2.0+ + * Version: `NTPv4` * Local interrogation allowed in `/etc/ntp.conf` (default): ``` @@ -1591,12 +1591,15 @@ update_every: 10 host: 'localhost' port: '123' show_peers: yes +# hide peers with source address in ranges 127.0.0.0/8 and 192.168.0.0/16 peer_filter: '(127\..*)|(192\.168\..*)' +# check for new/changed peers every 60 updates +peer_rescan: 60 ``` Sample (multiple jobs): -Note: `ntp.conf` on host `otherhost` must be configured to allow queries from our local host by including a line like `restrict <IP> nomodify notrap nopeer`. +Note: `ntp.conf` on the host `otherhost` must be configured to allow queries from our local host by including a line like `restrict <IP> nomodify notrap nopeer`. ```yaml local: @@ -1606,7 +1609,7 @@ otherhost: host: 'otherhost' ``` -If no configuration is given, module will attempt to connect to `ntpd` on `::1:123` or `127.0.0.1:123` and show charts for the systemvars. Use `show_peers: yes` to also show the charts for configured peers. Local peers (127.*) are hidden by default, use `peer_filter: ''` to show all. +If no configuration is given, module will attempt to connect to `ntpd` on `::1:123` or `127.0.0.1:123` and show charts for the systemvars. Use `show_peers: yes` to also show the charts for configured peers. Local peers in the range `127.0.0.0/8` are hidden by default, use `peer_filter: ''` to show all peers. --- diff --git a/python.d/ntpd.chart.py b/python.d/ntpd.chart.py index a2c5ad75d9..05209da871 100644 --- a/python.d/ntpd.chart.py +++ b/python.d/ntpd.chart.py @@ -86,7 +86,7 @@ CHARTS = { ['rootdisp', 'dispersion', 'absolute', 1, PRECISION] ]}, 'sys_stratum': { - 'options': [None, 'Stratum (1-15)', '1', 'system', 'ntpd.sys_stratum', 'line'], + 'options': [None, 'Stratum (1-15)', 'stratum', 'system', 'ntpd.sys_stratum', 'line'], 'lines': [ ['stratum', 'stratum', 'absolute', 1, PRECISION] ]}, @@ -135,15 +135,15 @@ PEER_CHARTS = { 'lines': [ ]}, 'peer_stratum': { - 'options': [None, 'Stratum (1-15)', '1', 'peers', 'ntpd.peer_stratum', 'line'], + 'options': [None, 'Stratum (1-15)', 'stratum', 'peers', 'ntpd.peer_stratum', 'line'], 'lines': [ ]}, 'peer_hmode': { - 'options': [None, 'Host mode (1-6)', '1', 'peers', 'ntpd.peer_hmode', 'line'], + 'options': [None, 'Host mode (1-6)', 'hmode', 'peers', 'ntpd.peer_hmode', 'line'], 'lines': [ ]}, 'peer_pmode': { - 'options': [None, 'Peer mode (1-5)', '1', 'peers', 'ntpd.peer_pmode', 'line'], + 'options': [None, 'Peer mode (1-5)', 'pmode', 'peers', 'ntpd.peer_pmode', 'line'], 'lines': [ ]}, 'peer_hpoll': { @@ -225,7 +225,6 @@ class Service(SocketService): SocketService.__init__(self, configuration=configuration, name=name) self.order = list(ORDER) self.definitions = dict(CHARTS) - self.definitions.update(PEER_CHARTS) self.port = 'ntp' self.dgram_socket = True @@ -236,6 +235,9 @@ class Service(SocketService): self.show_peers = self.configuration.get('show_peers', False) self.peer_rescan = self.configuration.get('peer_rescan', 60) + if self.show_peers: + self.definitions.update(PEER_CHARTS) + def check(self): """ Checks if we can get valid systemvars. @@ -341,6 +343,11 @@ class Service(SocketService): srcadr = srcadr.group(2) if self.peer_filter.search(srcadr): continue + stratum = re.search(r'(stratum)=([^,]+)', raw_peer_data) + if not stratum: + continue + if int(stratum.group(2)) > 15: + continue new_peer = Peer(idx=peer_id, name=srcadr) new_peers.append(new_peer) diff --git a/src/backends.c b/src/backends.c index ff4359fba3..1360638f29 100644 --- a/src/backends.c +++ b/src/backends.c @@ -347,9 +347,24 @@ static inline int format_dimension_collected_json_plaintext( (void)before; (void)options; + const char *tags_pre = "", *tags_post = "", *tags = host->tags; + if(!tags) tags = ""; + + if(*tags) { + if(*tags == '{' || *tags == '[' || *tags == '"') { + tags_pre = "\"host_tags\":"; + tags_post = ","; + } + else { + tags_pre = "\"host_tags\":\""; + tags_post = "\","; + } + } + buffer_sprintf(b, "{" "\"prefix\":\"%s\"," "\"hostname\":\"%s\"," + "%s%s%s" "\"chart_id\":\"%s\"," "\"chart_name\":\"%s\"," @@ -362,9 +377,10 @@ static inline int format_dimension_collected_json_plaintext( "\"name\":\"%s\"," "\"value\":" COLLECTED_NUMBER_FORMAT "," - "\"timestamp\": %u}\n", + "\"timestamp\": %u}\n", prefix, hostname, + tags_pre, tags, tags_post, st->id, st->name, @@ -400,9 +416,24 @@ static inline int format_dimension_stored_json_plaintext( calculated_number value = backend_calculate_value_from_stored_data(st, rd, after, before, options, &first_t, &last_t); if(!isnan(value)) { + const char *tags_pre = "", *tags_post = "", *tags = host->tags; + if(!tags) tags = ""; + + if(*tags) { + if(*tags == '{' || *tags == '[' || *tags == '"') { + tags_pre = "\"host_tags\":"; + tags_post = ","; + } + else { + tags_pre = "\"host_tags\":\""; + tags_post = "\","; + } + } + buffer_sprintf(b, "{" "\"prefix\":\"%s\"," "\"hostname\":\"%s\"," + "%s%s%s" "\"chart_id\":\"%s\"," "\"chart_name\":\"%s\"," @@ -418,7 +449,8 @@ static inline int format_dimension_stored_json_plaintext( "\"timestamp\": %u}\n", prefix, hostname, - + tags_pre, tags, tags_post, + st->id, st->name, st->family, diff --git a/web/dashboard_info.js b/web/dashboard_info.js index e68736e74a..e2864b0a81 100644 --- a/web/dashboard_info.js +++ b/web/dashboard_info.js @@ -358,7 +358,7 @@ netdataDashboard.menu = { 'ntpd': { title: 'ntpd', icon: '<i class="fas fa-clock"></i>', - info: 'Provides statistics for the internal variables of the Network Time Protocol daemon <b><a href="http://www.ntp.org/">ntpd</a></b> including the configured peers.' + info: 'Provides statistics for the internal variables of the Network Time Protocol daemon <b><a href="http://www.ntp.org/">ntpd</a></b> and optional including the configured peers (if enabled in the module configuration). The module presents the performance metrics as shown by <b><a href="http://doc.ntp.org/current-stable/ntpq.html">ntpq</a></b> (the standard NTP query program) using NTP mode 6 UDP packets to communicate with the NTP server.' } }; @@ -513,12 +513,12 @@ netdataDashboard.submenu = { 'ntpd.system': { title: 'system', - info: 'Statistics of the internal system variables as shown by <a href="http://doc.ntp.org/current-stable/ntpq.html">ntpq</a> (standard NTP query program).' + info: 'Statistics of the system variables as shown by the readlist billboard <code>ntpq -c rl</code>. System variables are assigned an association ID of zero and can also be shown in the readvar billboard <code>ntpq -c "rv 0"</code>. These variables are used in the <a href="http://doc.ntp.org/current-stable/discipline.html">Clock Discipline Algorithm</a>, to calculate the lowest and most stable offset.' }, 'ntpd.peers': { title: 'peers', - info: 'Statistics of the peer variables for each peer as shown by <a href="http://doc.ntp.org/current-stable/ntpq.html">ntpq</a> (standard NTP query program).' + info: 'Statistics of the peer variables for each peer configured in <code>/etc/ntp.conf</code> as shown by the readvar billboard <code>ntpq -c "rv <association>"</code>, while each peer is assigned a nonzero association ID as shown by <code>ntpq -c "apeers"</code>. The module periodically scans for new/changed peers (default: every 60s). <b>ntpd</b> selects the best possible peer from the available peers to synchronize the clock. A minimum of at least 3 peers is required to properly identify the best possible peer.' } }; @@ -1962,6 +1962,102 @@ netdataDashboard.context = { 'rabbitmq.disk_space': { info: 'Total amount of disk space consumed by the message store(s). See <code><a href="https://www.rabbitmq.com/production-checklist.html#resource-limits-disk-space" target=_"blank">Disk Space Limits</a></code> for further details.', colors: NETDATA.colors[3] + }, + + // ------------------------------------------------------------------------ + // ntpd + + 'ntpd.sys_offset': { + info: 'For hosts without any time critical services an offset of < 100 ms should be acceptable even with high network latencies. For hosts with time critical services an offset of about 0.01 ms or less can be achieved by using peers with low delays and configuring optimal <b>poll exponent</b> values.', + colors: NETDATA.colors[4] + }, + + 'ntpd.sys_jitter': { + info: 'The jitter statistics are exponentially-weighted RMS averages. The system jitter is defined in the NTPv4 specification; the clock jitter statistic is computed by the clock discipline module.' + }, + + 'ntpd.sys_frequency': { + info: 'The frequency offset is shown in ppm (parts per million) relative to the frequency of the system. The frequency correction needed for the clock can vary significantly between boots and also due to external influences like temperature or radiation.', + colors: NETDATA.colors[2], + height: 0.6 + }, + + 'ntpd.sys_wander': { + info: 'The wander statistics are exponentially-weighted RMS averages.', + colors: NETDATA.colors[3], + height: 0.6 + }, + + 'ntpd.sys_rootdelay': { + info: 'The rootdelay is the round-trip delay to the primary reference clock, similar to the delay shown by the <code>ping</code> command. A lower delay should result in a lower clock offset.', + colors: NETDATA.colors[1] + }, + + 'ntpd.sys_stratum': { + info: 'The distance in "hops" to the primary reference clock', + colors: NETDATA.colors[5], + height: 0.3 + }, + + 'ntpd.sys_tc': { + info: 'Time constants and poll intervals are expressed as exponents of 2. The default poll exponent of 6 corresponds to a poll interval of 64 s. For typical Internet paths, the optimum poll interval is about 64 s. For fast LANs with modern computers, a poll exponent of 4 (16 s) is appropriate. The <a href="http://doc.ntp.org/current-stable/poll.html">poll process</a> sends NTP packets at intervals determined by the clock discipline algorithm.', + height: 0.5 + }, + + 'ntpd.sys_precision': { + colors: NETDATA.colors[6], + height: 0.2 + }, + + 'ntpd.peer_offset': { + info: 'The offset of the peer clock relative to the system clock in milliseconds. Smaller values here weight peers more heavily for selection after the initial synchronization of the local clock. For a system providing time service to other systems, these should be as low as possible.' + }, + + 'ntpd.peer_delay': { + info: 'The round-trip time (RTT) for communication with the peer, similar to the delay shown by the <code>ping</code> command. Not as critical as either the offset or jitter, but still factored into the selection algorithm (because as a general rule, lower delay means more accurate time). In most cases, it should be below 100ms.' + }, + + 'ntpd.peer_dispersion': { + info: 'This is a measure of the estimated error between the peer and the local system. Lower values here are better.' + }, + + 'ntpd.peer_jitter': { + info: 'This is essentially a remote estimate of the peer\'s <code>system_jitter</code> value. Lower values here weight highly in favor of peer selection, and this is a good indicator of overall quality of a given time server (good servers will have values not exceeding single digit milliseconds here, with high quality stratum one servers regularly having sub-millisecond jitter).' + }, + + 'ntpd.peer_xleave': { + info: 'This variable is used in interleaved mode (used only in NTP symmetric and broadcast modes). See <a href="http://doc.ntp.org/current-stable/xleave.html">NTP Interleaved Modes</a>.' + }, + + 'ntpd.peer_rootdelay': { + info: 'For a stratum 1 server, this is the access latency for the reference clock. For lower stratum servers, it is the sum of the <code>peer_delay</code> and <code>peer_rootdelay</code> for the system they are syncing off of. Similarly to <code>peer_delay</code>, lower values here are technically better, but have limited influence in peer selection.' + }, + + 'ntpd.peer_rootdisp': { + info: 'Is the same as <code>peer_rootdelay</code>, but measures accumulated <code>peer_dispersion</code> instead of accumulated <code>peer_delay</code>.' + }, + + 'ntpd.peer_hmode': { + info: 'The <code>peer_hmode</code> and <code>peer_pmode</code> variables give info about what mode the packets being sent to and received from a given peer are. Mode 1 is symmetric active (both the local system and the remote peer have each other declared as peers in <code>/etc/ntp.conf</code>), Mode 2 is symmetric passive (only one side has the other declared as a peer), Mode 3 is client, Mode 4 is server, and Mode 5 is broadcast (also used for multicast and manycast operation).', + height: 0.2 + }, + + 'ntpd.peer_pmode': { + height: 0.2 + }, + + 'ntpd.peer_hpoll': { + info: 'The <code>peer_hpoll</code> and <code>peer_ppoll</code> variables are log2 representations of the polling interval in seconds.', + height: 0.5 + }, + + 'ntpd.peer_ppoll': { + height: 0.5 + }, + + 'ntpd.peer_precision': { + height: 0.2 } + // ------------------------------------------------------------------------ }; |