package main import ( "flag" "fmt" "net/http" "os" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/common/log" ) const version string = "1.0.0" var ( showVersion = flag.Bool("version", false, "Print version information.") listenAddress = flag.String("web.listen-address", ":9324", "Address on which to expose metrics and web interface.") metricsPath = flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics.") birdSocket = flag.String("bird.socket", "/var/run/bird.ctl", "Socket to communicate with bird routing daemon") bird6Socket = flag.String("bird.socket6", "/var/run/bird6.ctl", "Socket to communicate with bird6 routing daemon") birdEnabled = flag.Bool("bird.ipv4", true, "Get protocols from bird") bird6Enabled = flag.Bool("bird.ipv6", true, "Get protocols from bird6") ) func init() { flag.Usage = func() { fmt.Println("Usage: bird_exporter [ ... ]\n\nParameters:") fmt.Println() flag.PrintDefaults() } } func main() { flag.Parse() if *showVersion { printVersion() os.Exit(0) } startServer() } func printVersion() { fmt.Println("bird_exporter") fmt.Printf("Version: %s\n", version) fmt.Println("Author(s): Daniel Czerwonk") fmt.Println("Metric exporter for bird routing daemon") } func startServer() { log.Infof("Starting bird exporter (Version: %s)\n", version) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte(`