Monitoring Raspberry Pi With Dashboard
One of the interesting things one can do with their RaspberryPi is setting up a monitoring dashboard. For this we use Grafana (a dashboard service), InfluxDB (the database) and collectd (a metric collection service).
Updating and Upgrading
Down to your basics, update and upgrade your system first
Bash | |
---|---|
1 |
|
InfluxDB
Installing InfluxDB
Bash | |
---|---|
1 |
|
Fiddling with Configuration
Bash | |
---|---|
1 |
|
The values of the directories are going to be changed to tmp
so that values are stored in RAM.
End result should look like this
Text Only | |
---|---|
1 2 3 4 5 6 7 8 |
|
Now we will bind our data to localhost only.
Text Only | |
---|---|
1 2 3 |
|
Changing collectd configuration
Text Only | |
---|---|
1 2 3 4 5 |
|
Done! Now we will run the following code to enable and start InfluxDB
Bash | |
---|---|
1 2 |
|
If you now run influx
in your terminal you should see it work!
Run these commands
SQL | |
---|---|
1 2 |
|
"twentyfour_hours is the name of the policy, should you want to delete it later. the REPLICATION directive is only relevant for clustered systems but must be set nonetheless. Here, we only want one copy of our data.
Press CTRL + D to exit the influx prompt, and start with the next step."
collectd
Installing collectd -
Bash | |
---|---|
1 |
|
Once again, open the configuration file /etc/collectd/collectd.conf
and ensure the following settings are not commented out:
(Usually they aren't commented out but just check)
Text Only | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
What does all this mean?? The individual plugin report:
- cpufreq: the CPU frequency
- df: available disk space
- entropy: available entropy for (pseudo) random number generation
- interface: transmitted and received bytes on the network interfaces
- irq: number of times the interrupt handler of the OS has been called
- load: CPU load averages
- memory: available and used main memory
- network: write data to network servers
- processes: number of processes and their state
- swap: size and usage of the swap partition
- thermal: CPU temperature
- users: number of logged in users (via SSH, …)
Now that the plugins are loaded, we must configure some of them individually:
Text Only | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
Finally, we must tell collectd where to write all the data. We will set it to the host and port of InfluxDB’s collectd listener:
Text Only | |
---|---|
1 2 3 |
|
Finally making it work!
Bash | |
---|---|
1 2 |
|
Testing The Data
Bash | |
---|---|
1 |
|
SQL | |
---|---|
1 2 |
|
Grafana
Finally we install the dashboard To add the Grafana APT key to your Raspberry Pi’s keychain, run the following command
Bash | |
---|---|
1 |
|
Use the following command on your Raspberry Pi to add the repository to the list.
Bash | |
---|---|
1 |
|
Finally updating our Pi
Bash | |
---|---|
1 |
|
And installing it
Bash | |
---|---|
1 |
|
Enabling and starting the Grafana service
Bash | |
---|---|
1 2 |
|
Now open Grafana using your host IP address and on port 3000. The password and username for the dashboard is admin.
Note - Do not like port 3000 or another service is utilizing it? Change the port in /etc/grafana/grafana.ini
you have to change in /usr/share/grafana/conf/defaults.ini
.
Remove the semicolon in /usr/share/grafana/conf/defaults.ini
and chance the port! You're good to go!
Finally
- Open Grafana and if not prompted, head to settings (the gear icon) and click on Data Sources
- Add the data source as InfluxDB as given below
Done! Now just save and test! If it works you are 95% done!
Getting the beautiful output
Head over to the + sign and Import this and you shall now be seeing an output!