diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..d714246 --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +TRANSMISSION_ADDR=http://localhost:9091 +TRANSMISSION_PASSWORD= +TRANSMISSION_USERNAME= +WEB_ADDR=:19091 +WEB_PATH=/metrics diff --git a/.gitignore b/.gitignore index 8390d84..b07b78b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/.env /transmission-exporter *.o diff --git a/README.md b/README.md index b5e9ae2..7fef856 100644 --- a/README.md +++ b/README.md @@ -19,12 +19,6 @@ ENV Variable | Description | TRANSMISSION_USERNAME | Transmission username, no default | | TRANSMISSION_PASSWORD | Transmission password, no default | -### Build - - make - -For development we encourage you to use `make install` instead, it's faster. - ### Docker docker pull metalmatze/transmission-exporter @@ -49,6 +43,14 @@ Example `docker-compose.yml` with Transmission also running in docker. environment: TRANSMISSION_ADDR: http://transmission:9091 +### Development + + make + +For development we encourage you to use `make install` instead, it's faster. + +Now simply copy the `.env.example` to `.env`, like `cp .env.example .env` and set your preferences. +Now you're good to go. ### Original authors of the Transmission package Tobias Blom (https://github.com/tubbebubbe/transmission) diff --git a/cmd/transmission-exporter/main.go b/cmd/transmission-exporter/main.go index 8543cbd..11f8371 100644 --- a/cmd/transmission-exporter/main.go +++ b/cmd/transmission-exporter/main.go @@ -5,6 +5,7 @@ import ( "net/http" arg "github.com/alexflint/go-arg" + "github.com/joho/godotenv" transmission "github.com/metalmatze/transmission-exporter" "github.com/prometheus/client_golang/prometheus" ) @@ -21,6 +22,11 @@ type Config struct { func main() { log.Println("starting transmission-exporter") + err := godotenv.Load() + if err != nil { + log.Println("no .env present") + } + c := Config{ WebPath: "/metrics", WebAddr: ":19091",