From a814d7f8da1c4971e3cd6226848520055b2f396e Mon Sep 17 00:00:00 2001 From: Tobias Schmidt Date: Wed, 15 Apr 2015 23:38:53 -0400 Subject: [PATCH 1/2] Document how to enable logging Not everyone might have experience with glog's default settings, this change intends to make the start for new users easier. --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 6cd449dd..38affb73 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,12 @@ collectors. make ./node_exporter +The node_exporter uses the [glog][glog] library for logging. With the default +parameters, nothing will be logged. Use `-logtostderr` to enable logging to +stderr and `--help` to see more options about logging. + +[glog]: https://godoc.org/github.com/golang/glog + ## Running tests make test From 626900fe21ba129548eec0304c1648533ac6a1a9 Mon Sep 17 00:00:00 2001 From: Tobias Schmidt Date: Wed, 15 Apr 2015 23:51:09 -0400 Subject: [PATCH 2/2] Log version at startup --- Makefile | 1 + node_exporter.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/Makefile b/Makefile index ad0d9c82..55d45aac 100644 --- a/Makefile +++ b/Makefile @@ -13,5 +13,6 @@ VERSION := 0.8.0 TARGET := node_exporter +GOFLAGS := -ldflags "-X main.Version $(VERSION)" include Makefile.COMMON diff --git a/node_exporter.go b/node_exporter.go index b0dcbc35..19ac81fe 100644 --- a/node_exporter.go +++ b/node_exporter.go @@ -22,6 +22,9 @@ import ( const subsystem = "exporter" var ( + // set at build time + Version = "0.0.0.dev" + configFile = flag.String("config.file", "", "Path to config file.") memProfile = flag.String("debug.memprofile-file", "", "Write memory profile to this file upon receipt of SIGUSR1.") listenAddress = flag.String("web.listen-address", ":9100", "Address on which to expose metrics and web interface.") @@ -137,6 +140,7 @@ func loadCollectors(file string) (map[string]collector.Collector, error) { func main() { flag.Parse() + if *printCollectors { fmt.Printf("Available collectors:\n") for n, _ := range collector.Factories { @@ -182,6 +186,8 @@ func main() { `)) }) + + glog.Infof("Starting node_exporter v%s at %s", Version, *listenAddress) err = http.ListenAndServe(*listenAddress, nil) if err != nil { glog.Fatal(err)