mirror of
https://github.com/eko/pihole-exporter.git
synced 2024-11-26 11:55:26 +01:00
Teach pihole-exporter how to bind to a specific interface.
This commit is contained in:
parent
7095927491
commit
62f51680c5
@ -195,6 +195,9 @@ scrape_configs:
|
||||
# WEBPASSWORD / api token defined on the PI-Hole interface at `/etc/pihole/setupVars.conf`
|
||||
-pihole_api_token string (optional)
|
||||
|
||||
# Address to be used for the exporter
|
||||
-bind_addr string (optional) (default "0.0.0.0")
|
||||
|
||||
# Port to be used for the exporter
|
||||
-port string (optional) (default "9617")
|
||||
```
|
||||
|
@ -24,6 +24,8 @@ type Config struct {
|
||||
PIHolePort uint16 `config:"pihole_port"`
|
||||
PIHolePassword string `config:"pihole_password"`
|
||||
PIHoleApiToken string `config:"pihole_api_token"`
|
||||
BindAddr string `config:"bind_addr"`
|
||||
Port uint16 `config:"port"`
|
||||
}
|
||||
|
||||
type EnvConfig struct {
|
||||
@ -32,6 +34,7 @@ type EnvConfig struct {
|
||||
PIHolePort []uint16 `config:"pihole_port"`
|
||||
PIHolePassword []string `config:"pihole_password"`
|
||||
PIHoleApiToken []string `config:"pihole_api_token"`
|
||||
BindAddr string `config:"bind_addr"`
|
||||
Port uint16 `config:"port"`
|
||||
Timeout time.Duration `config:"timeout"`
|
||||
}
|
||||
@ -43,6 +46,7 @@ func getDefaultEnvConfig() *EnvConfig {
|
||||
PIHolePort: []uint16{80},
|
||||
PIHolePassword: []string{},
|
||||
PIHoleApiToken: []string{},
|
||||
BindAddr: "0.0.0.0",
|
||||
Port: 9617,
|
||||
Timeout: 5 * time.Second,
|
||||
}
|
||||
|
@ -20,10 +20,10 @@ type Server struct {
|
||||
|
||||
// NewServer method initializes a new HTTP server instance and associates
|
||||
// the different routes that will be used by Prometheus (metrics) or for monitoring (readiness, liveness).
|
||||
func NewServer(port uint16, clients []*pihole.Client) *Server {
|
||||
func NewServer(addr string, port uint16, clients []*pihole.Client) *Server {
|
||||
mux := http.NewServeMux()
|
||||
httpServer := &http.Server{
|
||||
Addr: ":" + strconv.Itoa(int(port)),
|
||||
Addr: addr + ":" + strconv.Itoa(int(port)),
|
||||
Handler: mux,
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user