From 21d473ffd463572829c6fc2efac34c54fd31b2d3 Mon Sep 17 00:00:00 2001 From: Pavel Borzenkov Date: Fri, 15 Jan 2016 15:16:12 +0300 Subject: [PATCH] Fix compilation without conntrack collector Entry collector uses readUintFromFile() function which is defined by conntrack collector. Thus, it is impossible to build node_exporter w/o conntrack collector. Fix this by factoring out the function into helper.go file. Signed-off-by: Pavel Borzenkov --- collector/conntrack_linux.go | 16 ---------------- collector/helper.go | 13 +++++++++++++ 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/collector/conntrack_linux.go b/collector/conntrack_linux.go index 943155b4..3f435718 100644 --- a/collector/conntrack_linux.go +++ b/collector/conntrack_linux.go @@ -16,10 +16,6 @@ package collector import ( - "io/ioutil" - "strconv" - "strings" - "github.com/prometheus/client_golang/prometheus" ) @@ -67,15 +63,3 @@ func (c *conntrackCollector) Update(ch chan<- prometheus.Metric) (err error) { return nil } - -func readUintFromFile(path string) (uint64, error) { - data, err := ioutil.ReadFile(path) - if err != nil { - return 0, err - } - value, err := strconv.ParseUint(strings.TrimSpace(string(data)), 10, 64) - if err != nil { - return 0, err - } - return value, nil -} diff --git a/collector/helper.go b/collector/helper.go index 64205de3..271c6260 100644 --- a/collector/helper.go +++ b/collector/helper.go @@ -15,6 +15,7 @@ package collector import ( "fmt" + "io/ioutil" "strconv" "strings" ) @@ -29,3 +30,15 @@ func splitToInts(str string, sep string) (ints []int, err error) { } return ints, nil } + +func readUintFromFile(path string) (uint64, error) { + data, err := ioutil.ReadFile(path) + if err != nil { + return 0, err + } + value, err := strconv.ParseUint(strings.TrimSpace(string(data)), 10, 64) + if err != nil { + return 0, err + } + return value, nil +}