forked from xperimental/nextcloud-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
28 lines (22 loc) · 788 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package main
import (
"log"
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
func main() {
config, err := parseConfig()
if err != nil {
log.Fatalf("Error in configuration: %s", err)
}
log.Printf("Nextcloud server: %s User: %s", config.InfoURL.Hostname(), config.Username)
collector := newCollector(config.InfoURL, config.Username, config.Password, config.Timeout)
if err := prometheus.Register(collector); err != nil {
log.Fatalf("Failed to register collector: %s", err)
}
http.Handle("/metrics", promhttp.Handler())
http.Handle("/", http.RedirectHandler("/metrics", http.StatusFound))
log.Printf("Listen on %s...", config.ListenAddr)
log.Fatal(http.ListenAndServe(config.ListenAddr, nil))
}