mirror of
https://github.com/rwinkhart/uni-nut.git
synced 2026-08-29 21:26:40 -04:00
27 lines
645 B
Go
27 lines
645 B
Go
// Command nut_exporter exports UPSs on one or more NUT servers to
|
|
// Prometheus.
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
"log"
|
|
"net/http"
|
|
"strings"
|
|
|
|
"honnef.co/go/nut/nutcollector"
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
|
)
|
|
|
|
func main() {
|
|
fHosts := flag.String("h", "localhost", "Space-separated list of hosts to collect")
|
|
fListen := flag.String("l", ":9230", "Address and port to listen on")
|
|
flag.Parse()
|
|
|
|
c := nutcollector.New(strings.Fields(*fHosts))
|
|
prometheus.MustRegister(c)
|
|
http.Handle("/metrics", promhttp.Handler())
|
|
log.Fatal(http.ListenAndServe(*fListen, nil))
|
|
}
|