Build Your Own WLAN Pi Health Dashboard
Let's build something together
Last updated
Let's build something together
Last updated
So far, we have looked at pre-built dashboards, in this lab you get to construct your own.
We have a suggested WLAN Pi health monitoring dashboard, this would enable you to keep an eye on key performance indicators of the WLAN Pi. How much space is there left on the SD card? What the CPU load is? What is the CPU temperature, is this WLAN Pi running too hot?
Here are the KPIs we would like to monitor and the proposed placement of the visualization panels.
Navigate to GRAFANA > OPEN GRAFANA IFRAME > "Build your own WLAN Pi Health"
dashboard.\
As you can see, we are not quite there yet. The visionary did not finish their job.\
... know that feeling when you move into a new house?
We already built the Data Stream service for you. As soon as you start it, the backend scripts will collect data and send them to the dashboard every 60 seconds.
Enable the Data Stream
GRAFANA > DATA STREAMS > WLAN Pi Health
\
You should now see CPU Utilisation
in your dashboard\
Now that Grafana is receiving data, it is up to you to add new visualizations.
Next up, add CPU Utilisation
graph.\
Add > Visualization
\
The default Time series
visualization is perfect for our needs.
Rename it to CPU Utilisation
Set Query Type > Live Measurements
Select Channel > stream/pihealth/pihealth
Finally, add Fields >
time
and cpu_util
\
Under Standard Options > Unit > select (Misc) > Percent (0-100)
Click the Apply
button.\
Drag & drop the new graph into position.
It is possible to resize panels by clicking and dragging the bottom right-hand corner.
When you are happy, hit the floppy disk Save
button.\
Open a new browser window, navigate to the WLAN Pi Web UI, and go to COCKPIT
Open Terminal
We can create CPU load with a command entered into Terminal
Type timeout 300 yes
and press the Enter
key\
This will keep saying yes to whatever the question is ๐ and it will stop after 300 seconds.
You can stop the yes command manually using"ctrl + c"
Head back to the Build your own WLAN Pi Health
dashboard and watch the CPU stats for a couple of minutes.
Mr. CPU, don't say yes to everything, it will keep you really busy.
Hopefully, we have helped you understand the concept of dashboards, visualizations and how they can be customised with a few clicks.
You would apply a similar concept to the other missing graphs. Eventually, you will build a dashboard that looks like ours.
Please head over to the Grafana home page, that's GRAFANA > OPEN GRAFANA IFRAME
Open the complete dashboard called WLAN Pi Health
\
Try to reverse-engineer the dashboard, edit values, add, move panels around, etc. To edit each panel, simply click the three-dot symbol
and select Edit
.
If you push the CPU to its limits, which actually takes some effort, you might even notice that CPU throttling is now active. You can tell by the Soft Temperature Limit Active
message.\
Try to open the Web UI and Grafana on your tablet. It is mobile-friendly and, it looks great on a smaller screen.
Absolutely, we can. So far, we have relied on existing Data Streams. They are BASH and/or Python scripts executed by a Linux service. When you start or stop a Data Stream in the WebUI, you are starting or stopping the respective service.
Scripts of the WLAN Pi Health Data Stream are located in /opt/wlanpi-grafana/health directory and they send fresh data to Grafana every 60 seconds. Let's explore them and change this setting to every 30 seconds.
Open Terminal in Cockpit and execute these commands.
Enter the directory by: cd /opt/wlanpi-grafana/health
List all files in this directory: ls -l
Execute the data collection script manually: ./pihealth.sh
\
After few seconds we get the output. This is the data in so called 'Line Protocol' format. The pihealth.sh script itself only collects and outputs data, but it doesn't send them to the dashboard. That's job of the stream-pihealth.sh
script.
Let's see how it works: cat stream-pihealth.sh
It takes the output of the pihealth.sh data collection script and sends it using to-grafana.sh script and sends it via Grafana API every 60 seconds.\
All we need to do is edit this script and change 60 to 30. Open the file by sudo nano stream-pihealth.sh
Enter your password and in the nano editor navigate using arrow keys to the right place. Delete 60 and replace it with 30.\
Save the file by pressing ctrl + o
(that's lowercase o for orange), press enter
, and press ctrl + x
to exit the editor.
We are nearly there, restart the Data Stream by executing sudo service wlanpi-grafana-health restart
. This is equivalent of stopping and restarting the Data Stream from the web interface using the 'X'
and Play buttons
. \
Perfect! Now, go to the WLAN Pi Health
dashboard and verify that we receive a fresh set of data every 30 seconds. \
Each dashboard has a Auto Refresh Interval
setting. When you change it to 30 seconds
, it will update the axis representing time twice a minute.