-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (36 loc) · 941 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
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"github.com/bpicode/fritzctl/fritz"
"github.com/ferencovonmatterhorn/fritzdect-prom-exporter/pkg/collector"
"github.com/ferencovonmatterhorn/fritzdect-prom-exporter/pkg/config"
"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
"net/http"
)
func main() {
c, err := config.Parse()
if err != nil {
log.Error(err)
return
}
log.Infof("%s", c)
con := fritz.NewHomeAuto(fritz.SkipTLSVerify(), fritz.Credentials(c.Credentials.Username, c.Credentials.Password))
if err := con.Login(); err != nil {
log.Error(err)
return
}
errChan := make(chan error, 1)
go func(ch chan<- error) {
ch <- collector.CollectMetrics(con)
}(errChan)
log.Debug("starting http endpoint")
http.Handle("/metrics", promhttp.Handler())
go func(ch chan<- error) {
ch <- http.ListenAndServe(":2112", nil)
}(errChan)
err = <-errChan
if err != nil {
log.Error(err)
return
}
}