wrouesnel / pdns_exporter

a quick and simple powerdns exporter for metrics via the control socket interface
Apache License 2.0
11 stars 5 forks source link

use of closed network connection #1

Open jangrewe opened 6 years ago

jangrewe commented 6 years ago

Hi, i'm running your exporter successfully to monitor my authorative daemon, but i can't get it to work for the recursor. The command line i'm using is:

/usr/local/bin/pdns_exporter.x86_64 -web.listen-address=:9121 -collector.powerdns.socket=recursor:unixgram:/run/pdns_recursor.controlsocket

Which results in this error:

Nov 11 18:55:11 hades pdns_exporter.x86_64[1667]: time="2017-11-11T18:55:11+01:00" level=info msg="PowerDNS Exporter: v0.0.3" source="pdns_exporter.go:502"
Nov 11 18:55:12 hades pdns_exporter.x86_64[1667]: time="2017-11-11T18:55:12+01:00" level=error msg="timeout waiting for powerdns response" source="pdns_exporter.go:436"
Nov 11 18:55:12 hades pdns_exporter.x86_64[1667]: time="2017-11-11T18:55:12+01:00" level=info msg="Registered new exporter for recursor at unixgram:/run/pdns_recursor.controlsocket" source="pdns_exporter.go:521"
Nov 11 18:55:12 hades pdns_exporter.x86_64[1667]: time="2017-11-11T18:55:12+01:00" level=error msg="read: read unixgram /tmp/lsock263480965->/run/pdns_recursor.controlsocket: use of closed network connection" source="pdns_exporter.go:393"
Nov 11 18:55:12 hades pdns_exporter.x86_64[1667]: time="2017-11-11T18:55:12+01:00" level=info msg="Starting pdns_exporter v0.0.3 at :9121" source="pdns_exporter.go:539"

The control socket has already mode 777 (for testing), but it still doesn't work...

ls -l /run/pdns_recursor.controlsocket
srwxrwxrwx 1 root pdns 0 Nov 11 13:56 /run/pdns_recursor.controlsocket
jangrewe commented 6 years ago

Today i also noticed errors like this in my syslog:

Nov 12 11:41:41 hades pdns_recursor[320]: Nov 12 11:41:41 Error dealing with control socket request: Unable to send message over control channel '/tmp/lsock181545485': No such file or directory
wrouesnel commented 6 years ago

The recursor uses Unix datagrams which are kind of weird. The exporter and recursor both need to run as the same user so that the recursor can talk to the reply socket (that name you see in recursor syslog)

rebtoor commented 6 years ago

Hi @wrouesnel, I've got the same issue as @jangrewe

Both pdns_recursor (0.0.3) and pdns_exporter (4.1.1) runs with the same user but the issue is still there. ps output:

UID        PID  PPID  C STIME TTY          TIME CMD
pdns-re+  3331     1  0 14:40 ?        00:00:00 /usr/sbin/pdns_recursor --daemon=no --write-pid=no --disable-syslog --log-timestamp=no
pdns-re+  3336  1821  0 14:40 pts/0    00:00:00 ./pdns_exporter.x86_64 -collector.powerdns.socket recursor:unixgram:/var/run/pdns_recursor.controlsocket -web.listen-address :9121

pdns_exporter stdout:

INFO[0000] PowerDNS Exporter: v0.0.3                     source=pdns_exporter.go:502
ERRO[0001] timeout waiting for powerdns response         source=pdns_exporter.go:436
INFO[0001] Registered new exporter for recursor at unixgram:/var/run/pdns_recursor.controlsocket  source=pdns_exporter.go:521
INFO[0001] Starting pdns_exporter v0.0.3 at :9121        source=pdns_exporter.go:539
ERRO[0001] read: read unixgram /tmp/lsock220475158->/var/run/pdns_recursor.controlsocket: use of closed network connection  source=pdns_exporter.go:393

syslog:

Mar 18 14:40:57 test-host pdns_recursor: Error dealing with control socket request: Unable to send message over control channel '/tmp/lsock220475158': No such file or directory
stmarier commented 6 years ago

Just wanted to note that I'm having the same issue, with the same configs: socket is 777, users match between exporter and recursor

Halytskyi commented 6 years ago

+1 - the same issue. PDNS version 4.1.3, Ubuntu 18.04.

Halytskyi commented 6 years ago

Found some solution. Need:

  1. In recursor.conf define socket-mode=0660. Restart recursor.
  2. Create some dir in /etc/powerdns with pdns owner and run exporter with parameters:
    sudo -u pdns /usr/bin/prometheus-pdns-exporter -collector.powerdns.socket=recursor:unixgram:/var/run/pdns_recursor.controlsocket -collector.tempdir.prefix=/etc/powerdns/lsocks