aboutsummaryrefslogtreecommitdiff
path: root/collector/ntp.go
diff options
context:
space:
mode:
authorBen Ye <yb532204897@gmail.com>2019-12-31 11:19:37 -0500
committerBen Kochie <superq@gmail.com>2019-12-31 17:19:37 +0100
commit2477c5c67dff7e7655a9d466450235e9c9eac193 (patch)
tree198cb44d48f454df765984bc614e1b1972a646e8 /collector/ntp.go
parenta80b7d0bc5ee93e704bab22e7592ed8b7d65899e (diff)
downloadprometheus_node_collector-2477c5c67dff7e7655a9d466450235e9c9eac193.tar.bz2
prometheus_node_collector-2477c5c67dff7e7655a9d466450235e9c9eac193.tar.xz
prometheus_node_collector-2477c5c67dff7e7655a9d466450235e9c9eac193.zip
switch to go-kit/log (#1575)
Signed-off-by: yeya24 <yb532204897@gmail.com>
Diffstat (limited to 'collector/ntp.go')
-rw-r--r--collector/ntp.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/collector/ntp.go b/collector/ntp.go
index 9b3c5a2..ea3a69e 100644
--- a/collector/ntp.go
+++ b/collector/ntp.go
@@ -22,6 +22,7 @@ import (
22 "time" 22 "time"
23 23
24 "github.com/beevik/ntp" 24 "github.com/beevik/ntp"
25 "github.com/go-kit/kit/log"
25 "github.com/prometheus/client_golang/prometheus" 26 "github.com/prometheus/client_golang/prometheus"
26 "gopkg.in/alecthomas/kingpin.v2" 27 "gopkg.in/alecthomas/kingpin.v2"
27) 28)
@@ -47,6 +48,7 @@ var (
47 48
48type ntpCollector struct { 49type ntpCollector struct {
49 stratum, leap, rtt, offset, reftime, rootDelay, rootDispersion, sanity typedDesc 50 stratum, leap, rtt, offset, reftime, rootDelay, rootDispersion, sanity typedDesc
51 logger log.Logger
50} 52}
51 53
52func init() { 54func init() {
@@ -57,7 +59,7 @@ func init() {
57// Default definition of "local" is: 59// Default definition of "local" is:
58// - collector.ntp.server address is a loopback address (or collector.ntp.server-is-mine flag is turned on) 60// - collector.ntp.server address is a loopback address (or collector.ntp.server-is-mine flag is turned on)
59// - the server is reachable with outgoin IP_TTL = 1 61// - the server is reachable with outgoin IP_TTL = 1
60func NewNtpCollector() (Collector, error) { 62func NewNtpCollector(logger log.Logger) (Collector, error) {
61 ipaddr := net.ParseIP(*ntpServer) 63 ipaddr := net.ParseIP(*ntpServer)
62 if !*ntpServerIsLocal && (ipaddr == nil || !ipaddr.IsLoopback()) { 64 if !*ntpServerIsLocal && (ipaddr == nil || !ipaddr.IsLoopback()) {
63 return nil, fmt.Errorf("only IP address of local NTP server is valid for --collector.ntp.server") 65 return nil, fmt.Errorf("only IP address of local NTP server is valid for --collector.ntp.server")
@@ -112,6 +114,7 @@ func NewNtpCollector() (Collector, error) {
112 "NTPD sanity according to RFC5905 heuristics and configured limits.", 114 "NTPD sanity according to RFC5905 heuristics and configured limits.",
113 nil, nil, 115 nil, nil,
114 ), prometheus.GaugeValue}, 116 ), prometheus.GaugeValue},
117 logger: logger,
115 }, nil 118 }, nil
116} 119}
117 120