Pihole disabled timer

Where can I find the disabled timer when the pihole is disabled for certain amount of time.
For example, after executing:
pihole disable 30m
I would like to know, programmatically, when the pihole will be re-enabled and/or this is a temporary disable and not an indefinite one. I could not find any information on this topic.
Thank you,

If you disable from the web admin GUI, there is a countdown timer. In this example, I disabled for 30 seconds and took the screen capture about halfway through:

That's the exact data I am looking for, but I need to be able to pull it either from REST API or CLI or a file. Is there a way? I also noticed that when pihole is disabled from CLI (pihole disable 30s) the web interface does not have a counter.

The code to disable/enable blocking is here:

1 Like

rdwebdesign Thank you very much!!, I think I got it.
So you start a script pihole-reenable.sh with argument in seconds when its a temporary disable.
I guess if I can parse the output of ps command correctly I can calculate the end time.

Any other, more elegant suggestions?

I assume if I modify the enable/disable portion of the script to echo the start and end time to a log/temp file, my changes will be overwritten on pihole update?

If you plan to enable/disable via web interface, PHP saves a file with the time...
but this file only exists when disabling via web interface.

The PHP code is here:

1 Like

Thanks again, the idea was to disable it via command line. However, looks like I can leverage an API call and get the same behavior as using web interface.
If you do not mind, what is the full path for the following file.
file_put_contents('../custom_disable_timer', ($timestamp + $disable) * 1000);

It is set on /var/www/html/custom_disable_timer.

The file holds the final timestamp (in milliseconds).

in some cases the file exists even after pi-hole is automatically re-enabled.
You need to read the contents and compare the timestamp to be sure if pi-hole is disabled or not.

1 Like

I ended up searching for the pid of pihole-reenable.sh process and gathering the timeout value from /proc/[pid]/cmdline (I found its easier to parse compared to ps output). Subtracting process running time from the timeout value, gives me a good indication on how many seconds left till re-enable will occur.

Thanks for all the info rdwebdesign

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.