From 7a47935d6931a02b60380d519eddc734759217e1 Mon Sep 17 00:00:00 2001 From: Ludovic Ortega Date: Tue, 9 Mar 2021 11:30:49 +0100 Subject: [PATCH] feat: allows to bind on localhost or specific IP address (#11) Adds the `-metrics.listen-addr` flag * [Add] metrics.addr config option * [Fix] Remove .exe in documentation * [Fix] Rename metrics.addr to metrics.listen-addr --- README.md | 10 ++++++++++ main.go | 8 ++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f5419c7..d7d481c 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,16 @@ Download from [releases](https://github.com/fffonion/tplink-plug-exporter/releas docker run -d -p 9233:9233 fffonion/tplink-plug-exporter ``` +### Usage +Use the -h flag to see full usage: + +``` +$ tplink-plug-exporter -h +Usage of tplink-plug-exporter: + -metrics.listen-addr string + listen address for tplink-plug exporter (default ":9233") +``` + ## Grafana dashboard Search for `Kasa` inside grafana or install from https://grafana.com/grafana/dashboards/10957 diff --git a/main.go b/main.go index 4918748..87b0c06 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "flag" "net/http" "github.com/prometheus/common/log" @@ -9,7 +10,10 @@ import ( ) func main() { + var metricsAddr = flag.String("metrics.listen-addr", ":9233", "listen address for tplink-plug exporter") + + flag.Parse() s := exporter.NewHttpServer() - log.Infoln("Accepting Prometheus Requests on :9233") - log.Fatal(http.ListenAndServe(":9233", s)) + log.Infof("Accepting Prometheus Requests on %s", *metricsAddr) + log.Fatal(http.ListenAndServe(*metricsAddr, s)) }