From a730cff002be735a0180917b8a8b87adb21a348d Mon Sep 17 00:00:00 2001 From: Julius Volz Date: Thu, 5 Mar 2015 17:02:17 +0100 Subject: [PATCH] Remove memprofile file, add pprof HTTP endpoint instead. --- node_exporter.go | 46 ++++++++++++++-------------------------------- 1 file changed, 14 insertions(+), 32 deletions(-) diff --git a/node_exporter.go b/node_exporter.go index 0c41acf7..b0dcbc35 100644 --- a/node_exporter.go +++ b/node_exporter.go @@ -6,9 +6,9 @@ import ( "fmt" "io/ioutil" "net/http" + _ "net/http/pprof" "os" "os/signal" - "runtime/pprof" "strings" "sync" "syscall" @@ -171,37 +171,19 @@ func main() { password: *authPass, } } - go func() { - http.Handle(*metricsPath, handler) - http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte(` - Node Exporter - -

Node Exporter

-

Metrics

- - `)) - }) - err := http.ListenAndServe(*listenAddress, nil) - if err != nil { - glog.Fatal(err) - } - }() - for { - select { - case <-sigUsr1: - glog.Infof("got signal") - if *memProfile != "" { - glog.Infof("Writing memory profile to %s", *memProfile) - f, err := os.Create(*memProfile) - if err != nil { - glog.Fatal(err) - } - pprof.WriteHeapProfile(f) - f.Close() - } - } + http.Handle(*metricsPath, handler) + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte(` + Node Exporter + +

Node Exporter

+

Metrics

+ + `)) + }) + err = http.ListenAndServe(*listenAddress, nil) + if err != nil { + glog.Fatal(err) } - }