forked from runcong/ssh_monitor_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
36 lines (27 loc) · 761 Bytes
/
main.go
File metadata and controls
36 lines (27 loc) · 761 Bytes
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
package main
import (
"flag"
"log"
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
var listenAddress = flag.String(
"listen-address",
":8080",
"The address to listen on for HTTP requests.")
var reg = prometheus.NewRegistry()
func registerMetrics() {
reg.MustRegister(ssh_mon_status)
}
func main() {
registerMetrics()
flag.Parse()
log.Printf("Starting Server: %s", *listenAddress)
// http.Handle("/metrics", promhttp.Handler())
http.Handle("/metrics", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
go check_ssh_status()
promhttp.HandlerFor(reg, promhttp.HandlerOpts{}).ServeHTTP(w, r)
}))
log.Fatal(http.ListenAndServe(*listenAddress, nil))
}