Add readme

This commit is contained in:
Galorhallen 2021-12-18 00:25:23 +01:00
parent fc19ac5d29
commit 8170a4c0f7
2 changed files with 45 additions and 6 deletions

View file

@ -76,6 +76,33 @@ $ docker run \
ekofr/pihole-exporter:latest
```
A single instance of pihole-exporter can monitor multiple pi-holes instances.
To do so, you can specify a list of hostnames, protocols, passwords/API tokens and ports by separating them with commas in their respective environment variable:
```
$ docker run \
-e 'PIHOLE_PROTOCOL="http,http,http" \
-e 'PIHOLE_HOSTNAME="192.168.1.2,192.168.1.3,192.168.1.4"' \
-e "PIHOLE_API_TOKEN="$API_TOKEN1,$API_TOKEN2,$API_TOKEN3" \
-e "PIHOLE_PORT="8080,8081,8080" \
-e 'INTERVAL=30s' \
-e 'PORT=9617' \
ekofr/pihole-exporter:latest
```
If port, protocol and API token/password is the same for all instances, you can specify them only once:
```
$ docker run \
-e 'PIHOLE_PROTOCOL=",http" \
-e 'PIHOLE_HOSTNAME="192.168.1.2,192.168.1.3,192.168.1.4"' \
-e "PIHOLE_API_TOKEN="$API_TOKEN" \
-e "PIHOLE_PORT="8080" \
-e 'INTERVAL=30s' \
-e 'PORT=9617' \
ekofr/pihole-exporter:latest
```
### From sources
Optionally, you can download and build it from the sources. You have to retrieve the project sources by using one of the following way:

View file

@ -97,15 +97,27 @@ func (c EnvConfig) Split() []Config {
PIHolePort: c.PIHolePort[i],
}
if c.PIHoleApiToken != nil && len(c.PIHoleApiToken) > 0 {
if c.PIHoleApiToken[i] != "" {
config.PIHoleApiToken = c.PIHoleApiToken[i]
if c.PIHoleApiToken != nil {
if len(c.PIHoleApiToken) == 1 {
if c.PIHoleApiToken[0] != "" {
config.PIHoleApiToken = c.PIHoleApiToken[0]
}
} else if len(c.PIHoleApiToken) > 1 {
if c.PIHoleApiToken[i] != "" {
config.PIHoleApiToken = c.PIHoleApiToken[i]
}
}
}
if c.PIHolePassword != nil && len(c.PIHolePassword) > 0 {
if c.PIHolePassword[i] != "" {
config.PIHolePassword = c.PIHolePassword[i]
if c.PIHolePassword != nil {
if len(c.PIHolePassword) == 1 {
if c.PIHolePassword[0] != "" {
config.PIHolePassword = c.PIHolePassword[0]
}
} else if len(c.PIHolePassword) > 1 {
if c.PIHolePassword[i] != "" {
config.PIHolePassword = c.PIHolePassword[i]
}
}
}