Prometheus collector to collect stats from mirror.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.6 KiB

package main
import (
const Namespace = "mirror"
func main() {
// Define command line flags
var (
listenAddress = flag.String("net.listen-address", ":2400", "Address to listen on for web and metrics interface")
metricsPath = flag.String("net.telemetry-path", "/metrics", "Path to expose metrics on")
nginxAccessLogPath = flag.String("nginx.access-log", "/var/log/nginx/access.log", "Path to nginx access log")
proftpdTransferLogPath = flag.String("proftpd.transfer-log", "/var/log/proftpd/xferlog", "Path to proftpd transfer log")
nginxExporter, err := NewNginxExporter(*nginxAccessLogPath)
if err != nil {
proftpdExporter, err := NewProftpdExporter(*proftpdTransferLogPath)
if err != nil {
go nginxExporter.Monitor()
go proftpdExporter.Monitor()
http.Handle(*metricsPath, prometheus.Handler())
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`<!doctype html>
<meta charset="utf-8">
<title>Mirror Exporter</title>
<h1>Mirror Exporter</h1>
<p><a href="` + *metricsPath + `">Metrics</a></p>
log.Printf("Exporter started.. Listening on %s, metrics available at %s", *listenAddress, *metricsPath)
log.Fatal(http.ListenAndServe(*listenAddress, nil))