Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
simplify chrony and add some tests (#712)
Browse files Browse the repository at this point in the history
* simplify chrony and add some tests

* update charts

* update readme

* fix ref_measurement_time on chrony restart

* update go.d.conf

* update plugin readme

* fix tests

* fix reviewdog warnings

* fix readme
  • Loading branch information
ilyam8 authored Jul 12, 2022
1 parent 4b44358 commit d653897
Show file tree
Hide file tree
Showing 13 changed files with 948 additions and 656 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Go.d.plugin is shipped with [`Netdata`](https://github.com/netdata/netdata).
| [activemq](https://github.com/netdata/go.d.plugin/tree/master/modules/activemq) | `ActiveMQ` |
| [apache](https://github.com/netdata/go.d.plugin/tree/master/modules/apache) | `Apache` |
| [bind](https://github.com/netdata/go.d.plugin/tree/master/modules/bind) | `ISC Bind` |
| [chrony](https://github.com/netdata/go.d.plugin/tree/master/modules/chrony) | `Chrony` |
| [cockroachdb](https://github.com/netdata/go.d.plugin/tree/master/modules/cockroachdb) | `CockroachDB` |
| [consul](https://github.com/netdata/go.d.plugin/tree/master/modules/consul) | `Consul` |
| [coredns](https://github.com/netdata/go.d.plugin/tree/master/modules/coredns) | `CoreDNS` |
Expand Down
2 changes: 1 addition & 1 deletion config/go.d.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ modules:
# activemq: yes
# apache: yes
# bind: yes
# chrony: no
# chrony: yes
# cockroachdb: yes
# consul: yes
# coredns: yes
Expand Down
7 changes: 0 additions & 7 deletions config/go.d/chrony.conf
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@
# Syntax:
# address: 127.0.0.1:53
#
# - protocol
# DNS query transport protocol. Valid options: udp, tcp, tcp-tls.
# Syntax:
# protocol: udp
#
# - timeout
# DNS query timeout (dial, write and read) in seconds.
# Syntax:
Expand All @@ -90,10 +85,8 @@

jobs:
- name: local
protocol: udp
address: '127.0.0.1:323'
timeout: 1

# - name: remote
# protocol: udp
# address: '203.0.113.0:323'
96 changes: 77 additions & 19 deletions modules/chrony/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,77 @@
# chrony monitoring with Netdata

[`chrony`](https://chrony.tuxfamily.org/) is a versatile implementation of the Network Time Protocol (NTP).

The modules will monitor local host `chrony` server.

This module use golang to collect chrony and produces:
* stratum
* frequency
* last offset
* RMS offset
* residual freq
* root delay
* root dispersion
* skew
* leap status
* update interval
* current correction
* current source server address
<!--
title: "Chrony monitoring with Netdata"
custom_edit_url: https://github.com/netdata/go.d.plugin/edit/master/modules/chrony/README.md
sidebar_label: "Chrony"
-->

# Chrony monitoring with Netdata

[chrony](https://chrony.tuxfamily.org/) is a versatile implementation of the Network Time Protocol (NTP).

This module monitors the system's clock performance and peers activity status using Chrony communication protocol v6.

## Charts

It produces the following charts:

- Distance to the reference clock
- Current correction
- Network path delay to stratum-1
- Dispersion accumulated back to stratum-1
- Offset on the last clock update
- Long-term average of the offset value
- Frequency
- Residual frequency
- Skew
- Interval between the last two clock updates
- Time since the last measurement
- Leap status
- Peers activity

## Configuration

Edit the `go.d/chrony.conf` configuration file using `edit-config` from the
Netdata [config directory](https://learn.netdata.cloud/docs/configure/nodes), which is typically at `/etc/netdata`.

```bash
cd /etc/netdata # Replace this path with your Netdata config directory, if different
sudo ./edit-config go.d/chrony.conf
```

Configuration example:

```yaml
jobs:
- name: local
address: '127.0.0.1:323'
timeout: 1

- name: remote
address: '203.0.113.0:323'
timeout: 3
```
For all available options please see
module [configuration file](https://github.com/netdata/go.d.plugin/blob/master/config/go.d/chrony.conf).
---
## Troubleshooting
To troubleshoot issues with the `chrony` collector, run the `go.d.plugin` with the debug option enabled. The
output should give you clues as to why the collector isn't working.

First, navigate to your plugins directory, usually at `/usr/libexec/netdata/plugins.d/`. If that's not the case on your
system, open `netdata.conf` and look for the setting `plugins directory`. Once you're in the plugin's directory, switch
to the `netdata` user.

```bash
cd /usr/libexec/netdata/plugins.d/
sudo -u netdata -s
```

You can now run the `go.d.plugin` to debug the collector:

```bash
./go.d.plugin -d -m chrony
```
156 changes: 79 additions & 77 deletions modules/chrony/charts.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,146 +4,148 @@ package chrony

import (
"github.com/netdata/go.d.plugin/agent/module"
"net"
"github.com/netdata/go.d.plugin/modules/chrony/client"
)

const scaleFactor = client.ScaleFactor

var charts = module.Charts{
{
ID: "running",
Title: "chrony is functional and can be monitored",
Units: "hop",
Type: module.Area,
Ctx: "chrony.running",
Dims: module.Dims{
{ID: "running", Name: "running", Algo: module.Absolute, Div: 1, Mul: 1},
},
},
{
ID: "stratum",
Title: "distance from reference clock",
Title: "Distance to the reference clock",
Units: "level",
Type: module.Area,
Fam: "stratum",
Ctx: "chrony.stratum",
Dims: module.Dims{
{ID: "stratum", Name: "stratum", Algo: module.Absolute, Div: 1, Mul: 1},
{ID: "stratum", Name: "stratum"},
},
},
{
ID: "leap_status",
// LEAP_Normal = 0,
// LEAP_InsertSecond = 1,
// LEAP_DeleteSecond = 2,
// LEAP_Unsynchronised = 3
Title: "Leap status can be Normal, Insert second, Delete second or Not synchronised.",
Units: "hop",
Ctx: "chrony.leap_status",
ID: "current_correction",
Title: "Current correction",
Units: "seconds",
Fam: "correction",
Ctx: "chrony.current_correction",
Dims: module.Dims{
{ID: "leap_status", Name: "leap_status", Algo: module.Absolute, Div: 1, Mul: 1},
{ID: "current_correction", Div: scaleFactor},
},
},
{
ID: "root_delay",
Title: "the total of the network path delays to the stratum-1 computer",
Title: "Network path delay to stratum-1",
Units: "seconds",
Type: module.Area,
Fam: "root",
Ctx: "chrony.root_delay",
Dims: module.Dims{
{ID: "root_delay", Name: "root_delay", Algo: module.Absolute, Div: scaleFactor, Mul: 1},
{ID: "root_delay", Div: scaleFactor},
},
},
{
ID: "root_dispersion",
Title: "total dispersion accumulated through all the computers back to the stratum-1 computer",
Title: "Dispersion accumulated back to stratum-1",
Units: "seconds",
Type: module.Area,
Fam: "root",
Ctx: "chrony.root_dispersion",
Dims: module.Dims{
{ID: "root_dispersion", Name: "root_dispersion", Algo: module.Absolute, Div: scaleFactor, Mul: 1},
{ID: "root_dispersion", Div: scaleFactor},
},
},
{
ID: "skew",
Title: "estimated error bound on the frequency",
Units: "ppm",
Type: module.Area,
Ctx: "chrony.skew",
ID: "last_offset",
Title: "Offset on the last clock update",
Units: "seconds",
Fam: "offset",
Ctx: "chrony.last_offset",
Dims: module.Dims{
{ID: "last_offset", Name: "offset", Div: scaleFactor},
},
},
{
ID: "rms_offset",
Title: "Long-term average of the offset value",
Units: "seconds",
Fam: "offset",
Ctx: "chrony.rms_offset",
Dims: module.Dims{
{ID: "skew", Name: "skew", Algo: module.Absolute, Div: scaleFactor, Mul: 1},
{ID: "rms_offset", Name: "offset", Div: scaleFactor},
},
},
{
ID: "frequency",
Title: "the rate by which the system’s clock would be would be wrong",
Title: "Frequency",
Units: "ppm",
Type: module.Area,
Fam: "frequency",
Ctx: "chrony.frequency",
Dims: module.Dims{
{ID: "frequency", Name: "frequency", Algo: module.Absolute, Div: scaleFactor, Mul: 1},
{ID: "frequency", Div: scaleFactor},
},
},
{
ID: "offset",
Title: "the offset between clock update",
Units: "seconds",
Type: module.Area,
Ctx: "chrony.offset",
ID: "residual_frequency",
Title: "Residual frequency",
Units: "ppm",
Fam: "frequency",
Ctx: "chrony.residual_frequency",
Dims: module.Dims{
{ID: "last_offset", Name: "last", Algo: module.Absolute, Div: scaleFactor, Mul: 1},
{ID: "rms_offset", Name: "rms", Algo: module.Absolute, Div: scaleFactor, Mul: 1},
{ID: "residual_frequency", Div: scaleFactor},
},
},
{
ID: "update_interval",
Title: "last clock update interval",
Units: "seconds",
Type: module.Area,
Ctx: "chrony.update_interval",
ID: "skew",
Title: "Skew",
Units: "ppm",
Fam: "frequency",
Ctx: "chrony.skew",
Dims: module.Dims{
{ID: "update_interval", Name: "update_interval", Algo: module.Absolute, Div: scaleFactor, Mul: 1},
{ID: "skew", Div: scaleFactor},
},
},
{
ID: "current_correction",
Title: "last clock update interval",
ID: "update_interval",
Title: "Interval between the last two clock updates",
Units: "seconds",
Type: module.Area,
Ctx: "chrony.current_correction",
Fam: "updates",
Ctx: "chrony.update_interval",
Dims: module.Dims{
{ID: "current_correction", Name: "current_correction", Algo: module.Absolute, Div: scaleFactor, Mul: 1},
{ID: "update_interval", Div: scaleFactor},
},
},
{
ID: "ref_timestamp",
Title: "last clock update interval",
ID: "ref_measurement_time",
Title: "Time since the last measurement",
Units: "seconds",
Type: module.Line,
Ctx: "chrony.ref_timestamp",
Fam: "updates",
Ctx: "chrony.ref_measurement_time",
Dims: module.Dims{
{ID: "ref_timestamp", Name: "ref_timestamp", Algo: module.Absolute, Div: 1, Mul: 1},
{ID: "ref_measurement_time"},
},
},
{
ID: "activity",
Title: "activity status",
Units: "count",
Ctx: "chrony.activity",
Type: module.Area,
ID: "leap_status",
Title: "Leap status",
Units: "status",
Fam: "leap status",
Ctx: "chrony.leap_status",
Dims: module.Dims{
{ID: "online_sources", Name: "online_sources", Algo: module.Absolute, Div: 1, Mul: 1},
{ID: "offline_sources", Name: "offline_sources", Algo: module.Absolute, Div: 1, Mul: 1},
{ID: "burst_online_sources", Name: "burst_online_sources", Algo: module.Absolute, Div: 1, Mul: 1},
{ID: "burst_offline_sources", Name: "burst_offline_sources", Algo: module.Absolute, Div: 1, Mul: 1},
{ID: "unresolved_sources", Name: "unresolved_sources", Algo: module.Absolute, Div: 1, Mul: 1},
{ID: "leap_status_normal", Name: "normal"},
{ID: "leap_status_insert_second", Name: "insert_second"},
{ID: "leap_status_delete_second", Name: "delete_second"},
{ID: "leap_status_unsynchronised", Name: "unsynchronised"},
},
},
{
ID: "source",
Title: "Activity Source Server",
Units: "hop",
Ctx: "chrony.source",
Type: module.Area,
ID: "activity",
Title: "Peers activity",
Units: "sources",
Fam: "activity",
Ctx: "chrony.activity",
Type: module.Stacked,
Dims: module.Dims{
{ID: net.IPv4zero.String(), Name: net.IPv4zero.String(), Algo: module.Absolute, Div: 1, Mul: 1},
{ID: "online_sources", Name: "online"},
{ID: "offline_sources", Name: "offline"},
{ID: "burst_online_sources", Name: "burst_online"},
{ID: "burst_offline_sources", Name: "burst_offline"},
{ID: "unresolved_sources", Name: "unresolved"},
},
},
}
Loading

0 comments on commit d653897

Please sign in to comment.