-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
38 lines (32 loc) · 884 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
package main
import (
"flag"
"log"
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
const (
namespace = "dockerhub_ratelimit"
)
var (
addr = flag.String("listen", "0.0.0.0:9768", "The address to listen on for HTTP requests.")
username = flag.String("username", "", "Username for use in authentication")
password = flag.String("password", "", "Password for use in authentication")
)
func main() {
flag.Parse()
c := Collector{
username: *username,
password: *password,
}
prometheus.MustRegister(c)
http.Handle("/metrics", promhttp.Handler())
log.Printf("starting exporter on %s", *addr)
if len(*username) > 0 {
log.Printf("metrics for DockerHub user '%s'", *username)
} else {
log.Println("metrics for DockerHub user 'Anonymous'")
}
log.Fatal(http.ListenAndServe(*addr, nil))
}