mirror of
https://github.com/rwinkhart/uni-nut.git
synced 2026-09-05 16:37:15 -04:00
Add CLI flags to NUT exporter
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"honnef.co/go/nut/nutcollector"
|
"honnef.co/go/nut/nutcollector"
|
||||||
|
|
||||||
@@ -10,8 +12,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
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)
|
prometheus.MustRegister(c)
|
||||||
http.Handle("/metrics", promhttp.Handler())
|
http.Handle("/metrics", promhttp.Handler())
|
||||||
http.ListenAndServe(":9999", nil)
|
http.ListenAndServe(*fListen, nil)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user