HRVST Ch 26 The Landing

Zephyr turned and wanted to remember. She breathed in, held each breath, and exhaled. She listened to and looked at as much of the forest as she could. He might have expected that but I don’t know if…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Monitoring your home network with InfluxDB on Raspberry Pi with Docker

I’ve moved away from medium due to its content policies.

This is now available here:

.

.

.

.

.

Over a year ago I was having all sorts of networking problems at home, major packet loss, complete networking outages and more. They were spurious, unpredictable and hard to diagnose. I wasn’t sure if it was my desktop/laptop, phone, wireless, or my internet provider.

So I decided to put a Raspberry Pi 2 on my network with InfluxDB, telegraf and grafana with some network monitors in place. I need historical data because the issues I was seeing were sporadic.

I’ve used it over the past year to debug many issues and this year I’m polishing it up with a new setup on a Raspberry Pi 3.

These instructions are set for a Mac and a Pi 2 or 3 using raspbian 9 Stretch. This expects you know the basics of running Linux and a Raspberry Pi.

First we download Etcher and the raspbian image. We use this to drop the image in the SD card we use in the Pi. We want the lite image, however the full image may work just fine as well.

Next for a Pi3 we need to connect it to the wifi.

Then we enable SSH to remotely connect to the Pi.

After that we can now remotely connect.

Now that the Pi is setup time to install our software packages.

Shortcut is

Check that docker is running

Now when running this I got this error:

After that, reboot.

And now we’ve got influxdb running

Now we need to follow the rest of the instructions to initialize the influxdb database

We have to use the arm32v7 version

Now let’s generate a config file we can mount into the container

And we can modify it as needed, we won’t do that quite yet though, but now we can run the container mounted with the local config file

More recently there are now 3rd party grafana docker containers on docker hub which makes this considerably easier

Now we can test by hitting the grafana endpoint and logging in with admin:admin

Voila

But adding the data source fails. Trying to run the container with the existing influxdb networked container fails as well.

This is a subtetly of docker networking and docker has several modes of networking. In this case we are going to just use host based networking for simplicity.

So far we’ve done the basics of booting the three software packages together to ensure that has worked but now we need to reconfigure them to work together and to start on boot. After that we can start customizing our configuration.

First we need to stop all the containers we have running. The first steps were just to make sure everything ran.

Since we are only planning on running monitoring on this pi, we can just use docker host networking.

Start influxdb using host networking.

And run telegraf

First let’s create some persistent storage for grafana

And then run grafana with the persistent storage

Before we get to the monitoring we should verify the install is working.

First we can tail all the docker logs

Influx

Telegraf

Grafana

If all is well we can then setup Grafana. There are other tests we can run here to verify and I might add them later.

When loading up grafana at http:<ip>:3000 we are presented with the front page again and can move on to configuring a basic influx datasource

With the data source setup we can now setup a new dashboard. To test things out we will graph performance of the Pi itself, then add our networking monitoring graphs.

Hitting the edit button on the Panel Title allows us to edit it.

And we can get a simple graph together of average CPU as a test.

With the above we should now have a working monitoring setup, we just need to add some checks to it.

With influxdb and telegraf this is pretty easy right out of the box. In the telegraf.conf file (initially mapped right in the pi user home dir) we are going to change a few of the inputs.

Scrolling through the default file you will see settings regarding the agent, outputs aggregators and inputs. You’ll also notice that most of the items are commented out except our existing host metrics like [[inputs.cpu]] which we used to graph above.

Next we want to modify [[inputs.ping]]

Here we setup ping monitoring to some popular sites, our DNS servers and something on our local network. If you are using ethernet instead of wifi (standard on Pi2) then you’ll want to change the interface to “eth0”

With the note in the ping plugin comments we also need to allow pings

Otherwise we will see something like this in our telegraf log:

After changing the configuration we just restart telegraf.

We can setup a new dashboard for ping response time.

We can also add one for packet loss

And finally DNS

Now we’ve got monitoring in place and a dashboard setup to review it as needed. For about $50 we’ve now got a flexible monitoring solution that can be plugged in pretty much anywhere on your network to give you another view of network performance.

Now whenever I have a networking issue I can load up these graphs to get the Pi’s view of what is happening. Turns out I had several different issues going on and sometimes it was ISP, sometimes wireless and sometimes my local device.

Add a comment

Related posts:

2020 Salute to Armed Forces Day

Major League Baseball has once again teamed up with all 30 clubs to support active duty military, veterans, and military families with funding for transition services, mental health, and quality of…

My Top 3 Apps for iPad

Tablets are no longer devices just for games and entertainment. After you set up your iPad, you’ll want to download some apps to get the full iPad experience. GoodNotes lets you take beautiful…

Why training is better than recruiting

I was recently reading a report from the Chartered Institute of Personnel and Development (CIPD) about the current outlook for the labour market. Each quarter, the CIPD publishes extensive data on…