diff options
author | Julius Volz <julius.volz@gmail.com> | 2015-05-28 21:21:44 +0200 |
---|---|---|
committer | Julius Volz <julius.volz@gmail.com> | 2015-05-28 21:34:02 +0200 |
commit | e65bc868fcb1a7b59b0981f1b6827429ce4c3f6c (patch) | |
tree | 43c647d4513d97cb84496036c41e8d29ed44702f /node_exporter.go | |
parent | 9f046cd88e5804cafee9c898247272c074a08273 (diff) | |
download | prometheus_node_collector-e65bc868fcb1a7b59b0981f1b6827429ce4c3f6c.tar.bz2 prometheus_node_collector-e65bc868fcb1a7b59b0981f1b6827429ce4c3f6c.tar.xz prometheus_node_collector-e65bc868fcb1a7b59b0981f1b6827429ce4c3f6c.zip |
Switch logging from glog to github.com/prometheus/log.
Diffstat (limited to 'node_exporter.go')
-rw-r--r-- | node_exporter.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/node_exporter.go b/node_exporter.go index 7c7911a..dcd6bb4 100644 --- a/node_exporter.go +++ b/node_exporter.go | |||
@@ -13,8 +13,9 @@ import ( | |||
13 | "syscall" | 13 | "syscall" |
14 | "time" | 14 | "time" |
15 | 15 | ||
16 | "github.com/golang/glog" | ||
17 | "github.com/prometheus/client_golang/prometheus" | 16 | "github.com/prometheus/client_golang/prometheus" |
17 | "github.com/prometheus/log" | ||
18 | |||
18 | "github.com/prometheus/node_exporter/collector" | 19 | "github.com/prometheus/node_exporter/collector" |
19 | ) | 20 | ) |
20 | 21 | ||
@@ -93,10 +94,10 @@ func Execute(name string, c collector.Collector, ch chan<- prometheus.Metric) { | |||
93 | var result string | 94 | var result string |
94 | 95 | ||
95 | if err != nil { | 96 | if err != nil { |
96 | glog.Infof("ERROR: %s failed after %fs: %s", name, duration.Seconds(), err) | 97 | log.Infof("ERROR: %s failed after %fs: %s", name, duration.Seconds(), err) |
97 | result = "error" | 98 | result = "error" |
98 | } else { | 99 | } else { |
99 | glog.Infof("OK: %s success after %fs.", name, duration.Seconds()) | 100 | log.Infof("OK: %s success after %fs.", name, duration.Seconds()) |
100 | result = "success" | 101 | result = "success" |
101 | } | 102 | } |
102 | scrapeDurations.WithLabelValues(name, result).Observe(duration.Seconds()) | 103 | scrapeDurations.WithLabelValues(name, result).Observe(duration.Seconds()) |
@@ -135,12 +136,12 @@ func main() { | |||
135 | } | 136 | } |
136 | collectors, err := loadCollectors() | 137 | collectors, err := loadCollectors() |
137 | if err != nil { | 138 | if err != nil { |
138 | glog.Fatalf("Couldn't load collectors: %s", err) | 139 | log.Fatalf("Couldn't load collectors: %s", err) |
139 | } | 140 | } |
140 | 141 | ||
141 | glog.Infof("Enabled collectors:") | 142 | log.Infof("Enabled collectors:") |
142 | for n, _ := range collectors { | 143 | for n, _ := range collectors { |
143 | glog.Infof(" - %s", n) | 144 | log.Infof(" - %s", n) |
144 | } | 145 | } |
145 | 146 | ||
146 | nodeCollector := NodeCollector{collectors: collectors} | 147 | nodeCollector := NodeCollector{collectors: collectors} |
@@ -152,7 +153,7 @@ func main() { | |||
152 | handler := prometheus.Handler() | 153 | handler := prometheus.Handler() |
153 | if *authUser != "" || *authPass != "" { | 154 | if *authUser != "" || *authPass != "" { |
154 | if *authUser == "" || *authPass == "" { | 155 | if *authUser == "" || *authPass == "" { |
155 | glog.Fatal("You need to specify -auth.user and -auth.pass to enable basic auth") | 156 | log.Fatal("You need to specify -auth.user and -auth.pass to enable basic auth") |
156 | } | 157 | } |
157 | handler = &basicAuthHandler{ | 158 | handler = &basicAuthHandler{ |
158 | handler: prometheus.Handler().ServeHTTP, | 159 | handler: prometheus.Handler().ServeHTTP, |
@@ -172,9 +173,9 @@ func main() { | |||
172 | </html>`)) | 173 | </html>`)) |
173 | }) | 174 | }) |
174 | 175 | ||
175 | glog.Infof("Starting node_exporter v%s at %s", Version, *listenAddress) | 176 | log.Infof("Starting node_exporter v%s at %s", Version, *listenAddress) |
176 | err = http.ListenAndServe(*listenAddress, nil) | 177 | err = http.ListenAndServe(*listenAddress, nil) |
177 | if err != nil { | 178 | if err != nil { |
178 | glog.Fatal(err) | 179 | log.Fatal(err) |
179 | } | 180 | } |
180 | } | 181 | } |