-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
36 lines (29 loc) · 999 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
// SPDX-FileCopyrightText: 2021 Sascha Brawer <sascha@brawer.ch>
// SPDX-License-Identifier: MIT
package main
import (
"context"
"flag"
"net/http"
"os"
"strconv"
"strings"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
func main() {
var portFlag = flag.Int("port", 0, "port for serving HTTP requests")
var domainsFlag = flag.String("hosts", "codesearch.wmcloud.org,query.wikidata.org,toolforge.org,wmcloud.org", "comma-separated list of internet domains whose TLS certificate expiration dates we monitor")
flag.Parse()
port := *portFlag
if port == 0 {
port, _ = strconv.Atoi(os.Getenv("PORT"))
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
certmon := NewCertMon(strings.Split(*domainsFlag, ","), ctx)
prometheus.MustRegister(certExpirations)
http.HandleFunc("/", certmon.HandleStatus)
http.Handle("/metrics", promhttp.Handler())
http.ListenAndServe(":"+strconv.Itoa(port), nil)
}