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 <pavel.borzenkov@gmail.com>
This commit is contained in:
Pavel Borzenkov 2016-01-15 15:16:12 +03:00
commit 21d473ffd4
2 changed files with 13 additions and 16 deletions

View file

@ -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
}