-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
54 lines (45 loc) · 1.46 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"flag"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
"net/http"
)
var (
bindAddr = flag.String("telemetry.addr", ":9353", "host:port for ceph exporter")
asokPath = flag.String("asok.path", "/var/run/ceph", "path to ceph admin socket direcotry")
queryInterval = flag.Int("query.interval", 15, "How often should daemon read asok metrics (in seconds0")
logLevel = flag.String("log.level", "info", "Logging level")
healthCollector = flag.Bool("health.collector", false, "Collect health status from ceph monitor")
cephConfigFile = flag.String("config.file", "/etc/ceph/ceph.conf", "Path to ceph config file")
)
func main() {
flag.Parse()
switch *logLevel {
case "debug":
log.SetLevel(log.DebugLevel)
case "info":
log.SetLevel(log.InfoLevel)
default:
log.SetLevel(log.InfoLevel)
}
go CollectTimer(*queryInterval)
ceph := newCephCollector()
prometheus.MustRegister(ceph)
http.Handle("/metrics", promhttp.Handler())
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
_, err := w.Write([]byte(`<html>
<head><title>Ceph Exporter</title></head>
<body>
<h1>Ceph Exporter</h1>
<p><a href='metrics'>Metrics</a></p>
</body>
</html>`))
if err != nil {
log.Error("HTTP write failed: ", err)
}
})
log.Info("Listening on: ", *bindAddr)
log.Fatal(http.ListenAndServe(*bindAddr, nil))
}