pi-hole-raspberry-pi.txt 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <!--
  2. title: "Monitor Pi-hole (and a Raspberry Pi) with Netdata"
  3. sidebar_label: "Monitor Pi-hole (and a Raspberry Pi) with Netdata"
  4. description: "Monitor Pi-hole metrics, plus Raspberry Pi system metrics, in minutes and completely for free with Netdata's open-source monitoring agent."
  5. image: /img/seo/guides/monitor/netdata-pi-hole-raspberry-pi.png
  6. custom_edit_url: https://github.com/netdata/netdata/edit/master/docs/guides/monitor/pi-hole-raspberry-pi.md
  7. learn_status: "Published"
  8. learn_rel_path: "Miscellaneous"
  9. -->
  10. # Monitor Pi-hole (and a Raspberry Pi) with Netdata
  11. import { OneLineInstallWget } from '@site/src/components/OneLineInstall/'
  12. Between intrusive ads, invasive trackers, and vicious malware, many techies and homelab enthusiasts are advancing their
  13. networks' security and speed with a tiny computer and a powerful piece of software: [Pi-hole](https://pi-hole.net/).
  14. Pi-hole is a DNS sinkhole that prevents unwanted content from even reaching devices on your home network. It blocks ads
  15. and malware at the network, instead of using extensions/add-ons for individual browsers, so you'll stop seeing ads in
  16. some of the most intrusive places, like your smart TV. Pi-hole can even [improve your network's speed and reduce
  17. bandwidth](https://discourse.pi-hole.net/t/will-pi-hole-slow-down-my-network/2048).
  18. Most Pi-hole users run it on a [Raspberry Pi](https://www.raspberrypi.org/products/raspberry-pi-4-model-b/) (hence the
  19. name), a credit card-sized, super-capable computer that costs about $35.
  20. And to keep tabs on how both Pi-hole and the Raspberry Pi are working to protect your network, you can use the
  21. open-source [Netdata monitoring agent](https://github.com/netdata/netdata).
  22. To get started, all you need is a [Raspberry Pi](https://www.raspberrypi.org/products/raspberry-pi-4-model-b/) with
  23. Raspbian installed. This guide uses a Raspberry Pi 4 Model B and Raspbian GNU/Linux 10 (buster). This guide assumes
  24. you're connecting to a Raspberry Pi remotely over SSH, but you could also complete all these steps on the system
  25. directly using a keyboard, mouse, and monitor.
  26. ## Why monitor Pi-hole and a Raspberry Pi with Netdata?
  27. Netdata helps you monitor and troubleshoot all kinds of devices and the applications they run, including IoT devices
  28. like the Raspberry Pi and applications like Pi-hole.
  29. After a two-minute installation and with zero configuration, you'll be able to see all of Pi-hole's metrics, including
  30. the volume of queries, connected clients, DNS queries per type, top clients, top blocked domains, and more.
  31. With Netdata installed, you can also monitor system metrics and any other applications you might be running. By default,
  32. Netdata collects metrics on CPU usage, disk IO, bandwidth, per-application resource usage, and a ton more. With the
  33. Raspberry Pi used for this guide, Netdata automatically collects about 1,500 metrics every second!
  34. ![Real-time Pi-hole monitoring with
  35. Netdata](https://user-images.githubusercontent.com/1153921/90447745-c8fe9600-e098-11ea-8a57-4f07339f002b.png)
  36. ## Install Netdata
  37. Let's start by installing Netdata first so that it can start collecting system metrics as soon as possible for the most
  38. possible historic data.
  39. > ⚠️ Don't install Netdata using `apt` and the default package available in Raspbian. The Netdata team does not maintain
  40. > this package, and can't guarantee it works properly.
  41. On Raspberry Pis running Raspbian, the best way to install Netdata is our one-line kickstart script. This script asks
  42. you to install dependencies, then compiles Netdata from source via [GitHub](https://github.com/netdata/netdata).
  43. <OneLineInstallWget/>
  44. Once installed on a Raspberry Pi 4 with no accessories, Netdata starts collecting roughly 1,500 metrics every second and
  45. populates its dashboard with more than 250 charts.
  46. Open your browser of choice and navigate to `http://NODE:19999/`, replacing `NODE` with the IP address of your Raspberry
  47. Pi. Not sure what that IP is? Try running `hostname -I | awk '{print $1}'` from the Pi itself.
  48. You'll see Netdata's dashboard and a few hundred real-time, interactive charts. Feel free to explore, but let's turn our attention to installing Pi-hole.
  49. ## Install Pi-Hole
  50. Like Netdata, Pi-hole has a one-line script for simple installation. From your Raspberry Pi, run the following:
  51. ```bash
  52. curl -sSL https://install.pi-hole.net | bash
  53. ```
  54. The installer will help you set up Pi-hole based on the topology of your network. Once finished, you should set up your
  55. devices—or your router for system-wide sinkhole protection—to [use Pi-hole as their DNS
  56. service](https://discourse.pi-hole.net/t/how-do-i-configure-my-devices-to-use-pi-hole-as-their-dns-server/245). You've
  57. finished setting up Pi-hole at this point.
  58. As far as configuring Netdata to monitor Pi-hole metrics, there's nothing you actually need to do. Netdata's [Pi-hole
  59. collector](/src/go/plugin/go.d/collector/pihole/README.md) will autodetect the new service
  60. running on your Raspberry Pi and immediately start collecting metrics every second.
  61. Restart Netdata with `sudo systemctl restart netdata`, which will then recognize that Pi-hole is running and start a
  62. per-second collection job. When you refresh your Netdata dashboard or load it up again in a new tab, you'll see a new
  63. entry in the menu for **Pi-hole** metrics.
  64. ## Use Netdata to explore and monitor your Raspberry Pi and Pi-hole
  65. By the time you've reached this point in the guide, Netdata has already collected a ton of valuable data about your
  66. Raspberry Pi, Pi-hole, and any other apps/services you might be running. Even a few minutes of collecting 1,500 metrics
  67. per second adds up quickly.
  68. You can now use Netdata's synchronized charts to zoom, highlight, scrub through time, and discern how an anomaly in one
  69. part of your system might affect another.
  70. ![The Netdata dashboard in
  71. action](https://user-images.githubusercontent.com/1153921/80827388-b9fee100-8b98-11ea-8f60-0d7824667cd3.gif)
  72. ### Storing historical metrics on your Raspberry Pi
  73. By default, Netdata allocates 256 MiB in disk space to store historical metrics inside the [database
  74. engine](/src/database/engine/README.md). On the Raspberry Pi used for this guide, Netdata collects 1,500 metrics every
  75. second, which equates to storing 3.5 days worth of historical metrics.
  76. You can increase this allocation by editing `netdata.conf` and increasing the `dbengine multihost disk space` setting to
  77. more than 256.
  78. ```yaml
  79. [global]
  80. dbengine multihost disk space = 512
  81. ```
  82. Use our [database sizing
  83. calculator](/docs/netdata-agent/configuration/optimizing-metrics-database/change-metrics-storage.md#calculate-the-system-resources-ram-disk-space-needed-to-store-metrics)
  84. and the [Database configuration documentation](/src/database/README.md) to help you determine the right
  85. setting for your Raspberry Pi.