Skip to content

Commit

Permalink
feat: allows to bind on localhost or specific IP address (#11)
Browse files Browse the repository at this point in the history
Adds the `-metrics.listen-addr` flag

* [Add] metrics.addr config option

* [Fix] Remove .exe in documentation

* [Fix] Rename metrics.addr to metrics.listen-addr
  • Loading branch information
M0NsTeRRR authored Mar 9, 2021
1 parent ce1825d commit 7a47935
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"flag"
"net/http"

"github.com/prometheus/common/log"
Expand All @@ -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))
}

0 comments on commit 7a47935

Please sign in to comment.