add option to disable dns lookup for chronyc
This commit is contained in:
parent
1ef5599361
commit
6094bc3639
|
@ -5,6 +5,7 @@
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
- [#1247](https://github.com/influxdata/telegraf/pull/1247): rollbar input plugin. Thanks @francois2metz and @cduez!
|
- [#1247](https://github.com/influxdata/telegraf/pull/1247): rollbar input plugin. Thanks @francois2metz and @cduez!
|
||||||
|
- [#1265](https://github.com/influxdata/telegraf/pull/1265): Make dns lookups for chrony configurable. Thanks @zbindenren!
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ is computed for the new frequency, with weights depending on these accuracies. I
|
||||||
measurements from the reference source follow a consistent trend, the residual will be
|
measurements from the reference source follow a consistent trend, the residual will be
|
||||||
driven to zero over time.
|
driven to zero over time.
|
||||||
- Skew - This is the estimated error bound on the frequency.
|
- Skew - This is the estimated error bound on the frequency.
|
||||||
- Root delay -This is the total of the network path delays to the stratum-1 computer
|
- Root delay - This is the total of the network path delays to the stratum-1 computer
|
||||||
from which the computer is ultimately synchronised. In certain extreme situations, this
|
from which the computer is ultimately synchronised. In certain extreme situations, this
|
||||||
value can be negative. (This can arise in a symmetric peer arrangement where the computers’
|
value can be negative. (This can arise in a symmetric peer arrangement where the computers’
|
||||||
frequencies are not tracking each other and the network delay is very short relative to the
|
frequencies are not tracking each other and the network delay is very short relative to the
|
||||||
|
@ -56,7 +56,8 @@ Delete second or Not synchronised.
|
||||||
```toml
|
```toml
|
||||||
# Get standard chrony metrics, requires chronyc executable.
|
# Get standard chrony metrics, requires chronyc executable.
|
||||||
[[inputs.chrony]]
|
[[inputs.chrony]]
|
||||||
# no configuration
|
## If true, chronyc tries to perform a DNS lookup for the time server.
|
||||||
|
# dns_lookup = false
|
||||||
```
|
```
|
||||||
|
|
||||||
### Measurements & Fields:
|
### Measurements & Fields:
|
||||||
|
|
|
@ -20,7 +20,8 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Chrony struct {
|
type Chrony struct {
|
||||||
path string
|
DNSLookup bool `toml:"dns_lookup"`
|
||||||
|
path string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Chrony) Description() string {
|
func (*Chrony) Description() string {
|
||||||
|
@ -28,14 +29,24 @@ func (*Chrony) Description() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Chrony) SampleConfig() string {
|
func (*Chrony) SampleConfig() string {
|
||||||
return ""
|
return `
|
||||||
|
## If true, chronyc tries to perform a DNS lookup for the time server.
|
||||||
|
# dns_lookup = false
|
||||||
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Chrony) Gather(acc telegraf.Accumulator) error {
|
func (c *Chrony) Gather(acc telegraf.Accumulator) error {
|
||||||
if len(c.path) == 0 {
|
if len(c.path) == 0 {
|
||||||
return errors.New("chronyc not found: verify that chrony is installed and that chronyc is in your PATH")
|
return errors.New("chronyc not found: verify that chrony is installed and that chronyc is in your PATH")
|
||||||
}
|
}
|
||||||
cmd := execCommand(c.path, "tracking")
|
|
||||||
|
flags := []string{}
|
||||||
|
if !c.DNSLookup {
|
||||||
|
flags = append(flags, "-n")
|
||||||
|
}
|
||||||
|
flags = append(flags, "tracking")
|
||||||
|
|
||||||
|
cmd := execCommand(c.path, flags...)
|
||||||
out, err := internal.CombinedOutputTimeout(cmd, time.Second*5)
|
out, err := internal.CombinedOutputTimeout(cmd, time.Second*5)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to run command %s: %s - %s", strings.Join(cmd.Args, " "), err, string(out))
|
return fmt.Errorf("failed to run command %s: %s - %s", strings.Join(cmd.Args, " "), err, string(out))
|
||||||
|
|
Loading…
Reference in New Issue