2021-02-05 23:49:47 +01:00
|
|
|
package main
|
|
|
|
|
2021-02-06 00:01:00 +01:00
|
|
|
import (
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
const namespace = "fail2ban"
|
|
|
|
|
|
|
|
var up = prometheus.NewDesc(
|
|
|
|
prometheus.BuildFQName(namespace, "", "up"),
|
|
|
|
"Was the last fail2ban query successful.",
|
|
|
|
nil, nil,
|
|
|
|
)
|
|
|
|
|
|
|
|
type Exporter struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
|
|
|
|
ch <- up
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
|
|
|
|
ch <- prometheus.MustNewConstMetric(
|
|
|
|
up, prometheus.GaugeValue, 1,
|
|
|
|
)
|
|
|
|
}
|
2021-02-05 23:49:47 +01:00
|
|
|
|
|
|
|
func main() {
|
2021-02-06 00:01:00 +01:00
|
|
|
log.Print("starting fail2ban exporter")
|
|
|
|
|
|
|
|
exporter := &Exporter{}
|
|
|
|
prometheus.MustRegister(exporter)
|
|
|
|
|
|
|
|
http.Handle("/metrics", promhttp.Handler())
|
|
|
|
log.Fatal(http.ListenAndServe(":9101", nil))
|
2021-02-05 23:49:47 +01:00
|
|
|
}
|