PiHole - Script to check DNS service response status - Internet up status


As the title says running Pihole 5.3.1 on RPI3+, have hooked up the small TFT LCD and running PADD (and also tried PHAD) script on it to keep rotating the pihole statistics screen.

It happens sometimes that PiHole freezes (internally) due to various reasons. While I do intend to fix the root cause of freezes - which could be multiple , I also want to be able to quickly identify the internet outage at home network is not due to ISP backend being down, but to due to PIHole DNS service not responding. So when I am not at home, I can still guide the family to reboot or pinpoint the effort to troubleshoot a particular device.

I have Wifi Router, Pihole, Untangle Home UTM and ISP FiberLink Unit connected as a high level topology for the home network.

I have a ThingM Blink programmable USB light connected to PiHole, which can be controlled by its own binaries executable via Pihole SSH command line.

While being a total noob at scripting, I was looking for some help. Can have a cron script on PiHole

  1. Checking the DNS service status every "X" min, and if there is no response from DNS (FTL DNS i guess),

  2. Runs a command to flash the USB light as Red

  3. Returns to Green when the service becomes available again.

  4. IF service doesnt resume by "X" min, then reboot PiHole.

If possible could there be some way to have a condition in the script to check if the DNS service is down (or frozen) on Pihole itself , or there is internet outage from backend ISP Fiber unit, in the latter case we can also select some other color to blink the USB light.

This visual indication setup would certainly be useful for the similar lot like mine, to pinpoint the direction of the issue.

Thanks for your guidance and responses.