# Redirect output of pihole-FTL cache dump to database

**URL:** <https://discourse.pi-hole.net/t/redirect-output-of-pihole-ftl-cache-dump-to-database/24365>\
**Category:** Feature Requests\
**Created:** [October 6, 2019, 11:42am UTC](https://discourse.pi-hole.net/t/redirect-output-of-pihole-ftl-cache-dump-to-database/24365 "2019-10-06T11:42:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpgpi250](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/jpgpi250/32/286_2.png) [@jpgpi250](https://discourse.pi-hole.net/u/jpgpi250)\
**Post date:** [October 6, 2019, 11:42am UTC](https://discourse.pi-hole.net/t/redirect-output-of-pihole-ftl-cache-dump-to-database/24365/1 "2019-10-06T11:42:15Z")

</div>

Currently, the result of the following commands dump the content of the cache into the pihole log.

```auto
pi@raspberrypi:~ $ ps -e | grep pihole-FTL
 2859 ? 00:00:14 pihole-FTL
pi@raspberrypi:~ $ sudo kill -10 2859

```

This is the SIGUSR1 signal, see [Linux signal man](http://man7.org/linux/man-pages/man7/signal.7.html) for values, see the [dnsmasq man](http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html) for an explanation, quote:

```auto
Enable a full cache dump on receipt of SIGUSR1

```

The (partial) result, currently in the pihole log:

```auto
Oct 6 13:21:56 dnsmasq[2859]: geoffreyhand.co.uk 0.0.0.0 4F I H
Oct 6 13:21:56 dnsmasq[2859]: explosiondigital.com.ve 0.0.0.0 4F I H
Oct 6 13:21:56 dnsmasq[2859]: 8199wnsr.com 0.0.0.0 4F I H
Oct 6 13:21:56 dnsmasq[2859]: www.alarm-error-q3zdam25n.stre 0.0.0.0 4F I H
Oct 6 13:21:56 dnsmasq[2859]: gmviagens.com.br F I H
Oct 6 13:21:56 dnsmasq[2859]: www.lotusapps.net 0.0.0.0 4F I H
Oct 6 13:21:56 dnsmasq[2859]: ifasthost.eu F I H

```

**feature request** : redirect the output of the cache dump to a database (cachedump.sql) to allow for sqlite3 queries on the cache.

I'm using phpliteadmin, see old topic [here](https://discourse.pi-hole.net/t/browsing-the-ftl-database/14465), updated installation instructions [here](http://users.telenet.be/MySQLplaylist/pi-hole.pdf) (chapter 20 / section 3 - new version and php-mbstring required) to explore and query the sqlite3 databases.

---

<div class="post-metadata">

**Author:** ![jfb](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/jfb/32/4332_2.png) [@jfb](https://discourse.pi-hole.net/u/jfb)\
**Post date:** [October 6, 2019, 2:55pm UTC](https://discourse.pi-hole.net/t/redirect-output-of-pihole-ftl-cache-dump-to-database/24365/3 "2019-10-06T14:55:45Z")

</div>

If you have the output in hand, can you not convert it to the database format you desire?

---

<div class="post-metadata">

**Author:** ![DL6ER](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/dl6er/32/281_2.png) [@DL6ER](https://discourse.pi-hole.net/u/DL6ER)\
**Post date:** [October 20, 2019, 9:09am UTC](https://discourse.pi-hole.net/t/redirect-output-of-pihole-ftl-cache-dump-to-database/24365/4 "2019-10-20T09:09:07Z")

</div>

I guess you request this feature to avoid the cache being dumped to a text file that goes onto the SD card, is that correct?  
If so, let me suggest an alternative that is already available in the current version of FTL: Put the log file on a RAM disk.

If this is not your main concern, then I'd like to know **what do you want to achieve with this SQL file?** What is the advantage for users to be able to store the content of the cache in a database? This will surely take some time as well as SQL injections are obviously more expensive than simple `fprintf(...)` calls dumping into a text file.

---

<div class="post-metadata">

**Author:** ![jpgpi250](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/jpgpi250/32/286_2.png) [@jpgpi250](https://discourse.pi-hole.net/u/jpgpi250)\
**Post date:** [October 20, 2019, 9:45am UTC](https://discourse.pi-hole.net/t/redirect-output-of-pihole-ftl-cache-dump-to-database/24365/5 "2019-10-20T09:45:10Z")

</div>

I've dumped the cache, it goes to the pihole log, which is already on [ramdisk](https://discourse.pi-hole.net/t/make-location-of-pihole-log-files-configurable/20636).  
This dump contains all entries, including the 0.0.0.0 replies. The idea is, to have pihole-FTL write the valid content (NOT _0.0.0.0_ or _::_) to an additional database (only if instructed by the command sudo kill -10). The entries in this database could than be used to generate an unbound prefill configuration file (not part of pihole, customization for advanced users), ensuring the data is available for use in the unbound cache at all time, thus speeding up the response time.

As I indicated, I'm currently trying to achieve this, using the [unbound + Redis](https://discourse.pi-hole.net/t/pihole-ftl-unbound-with-cache-db-module-options-redis/24676) configuration, not yet sure this is benificial...

---

<div class="post-metadata">

**Author:** ![DL6ER](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/dl6er/32/281_2.png) [@DL6ER](https://discourse.pi-hole.net/u/DL6ER)\
**Post date:** [October 20, 2019, 10:01am UTC](https://discourse.pi-hole.net/t/redirect-output-of-pihole-ftl-cache-dump-to-database/24365/6 "2019-10-20T10:01:22Z")

</div>

> [@jpgpi250](#):
>
> The idea is, to have pihole-FTL write the valid content (NOT _0.0.0.0_ or _::_ ) to an additional database (only if instructed by the command sudo kill -10).

Okay, so the request would be for an additional effort during cache dumping. Acknowledged.

> [@jpgpi250](#):
>
> not yet sure this is benificial…

Okay, no worries. Let's wait for how the other discussion evolves before continuing here. This is neither an approval nor dismissal of this feature request. There is just no point in discussing something we are not sure yet if it will -- at all -- be used in the future.
