Bad file descriptor output when using chronometer

Hi,

I have noticed that pihole-c gives no result in terminal anymore.
It results in an endless error message:

pihole-r (without renewing settings) does not help. Any ideas?

Thanks, Frank

What is the output of

echo ">stats" | nc -v 127.0.0.1 4711

on the device you wanted to run the Chronometer on?

Hi,

output seems ok:

pi@raspberrypi:~ $ echo ">stats" | nc -v 127.0.0.1 4711
Connection to 127.0.0.1 4711 port [tcp/*] succeeded!
domains_being_blocked 133454
dns_queries_today 4022
ads_blocked_today 794
ads_percentage_today 19.741423
unique_domains 1108
queries_forwarded 2801
queries_cached 427
clients_ever_seen 12
unique_clients 12
status enabled
---EOM---

Okay, I wrote a small script for you, please save it as e.g. script.sh:

pihole-FTL() {
  ftl_port=$(cat /var/run/pihole-FTL.port 2> /dev/null)
  if [[ -n "$ftl_port" ]]; then
    # Open connection to FTL
    exec 3<>"/dev/tcp/localhost/$ftl_port"

    # Test if connection is open
    if { "true" >&3; } 2> /dev/null; then
      # Send command to FTL
      echo -e ">$1" >&3

      # Read input
      read -r -t 1 LINE <&3
      until [[ ! $? ]] || [[ "$LINE" == *"EOM"* ]]; do
         echo "$LINE" >&1
         read -r -t 1 LINE <&3
      done

      # Close connection
      exec 3>&-
      exec 3<&-
   fi
  else
    echo "0"
  fi
}

pihole-FTL "stats"

Then mark it as executable (chmod u+x script.sh) and run it (./script.sh). What is the output?

Hi,

oops, I changed 127.0.0.1 in etc/hosts from localhost to RaspberryPi to change the name in dashboard.
This works but was the mistake that lead to the error described. Changed it back to localhost and now chronometer works well again.

Thanks for your effort DL6ER, sorry! :roll_eyes:

1 Like

Okay, no worries. I'll submit a pull request exchanging localhost by hard-coded 127.0.01 to avoid having this problem again.

https://github.com/pi-hole/pi-hole/pull/1880