From 7051114b4e5bd755a9a5e43282b5e31850a87c9b Mon Sep 17 00:00:00 2001 From: Dominik Honnef Date: Thu, 29 Dec 2016 17:21:24 +0100 Subject: [PATCH] Add CLI flags to NUT exporter --- cmd/nut_exporter/main.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/nut_exporter/main.go b/cmd/nut_exporter/main.go index 760c277..b3914cf 100644 --- a/cmd/nut_exporter/main.go +++ b/cmd/nut_exporter/main.go @@ -1,7 +1,9 @@ package main import ( + "flag" "net/http" + "strings" "honnef.co/go/nut/nutcollector" @@ -10,8 +12,12 @@ import ( ) func main() { - c := nutcollector.New([]string{"localhost"}) + fHosts := flag.String("h", "localhost", "Space-separated list of hosts to collect") + fListen := flag.String("l", ":9100", "Address and port to listen on") + flag.Parse() + + c := nutcollector.New(strings.Fields(*fHosts)) prometheus.MustRegister(c) http.Handle("/metrics", promhttp.Handler()) - http.ListenAndServe(":9999", nil) + http.ListenAndServe(*fListen, nil) }