Monitor your Geth node with Google Sheet
In this article, I will explain how to monitor a Geth node and keep track of the syncing process very easily with a CronJob and Google Sheet
Capture and store geth and system metrics every 15 min
In the first step, we are configuring a cronjob (15 min scheduled task) on our Linux system where Geth is installed to capture some interesting metrics about the syncing state of Geth (blocks, states, peers) and the operating system (e.g CPU, memory, disk, load average).
Use the command $ crontab -e
to edit the crontab file and add the following line at the end to capture all the metrics and print them into a semi-column seperated CSV file.
1 | crontab -e |
Please find below a detailed explanation of each metrics:
date --iso-8601=seconds
prints the current date and time/usr/local/bin/geth --verbosity 0 --datadir /mnt/ssd/ethereum/ --exec 'var a = admin.peers; var s = eth.syncing; s.currentBlock + ";" + s.highestBlock + ";" + (s.highestBlock-s.currentBlock) + ";" + s.pulledStates + ";" + s.knownStates + ";" + a.length' attach | tr -d "\""
connects to geth (--datadir
might differ) and retrieve the following information: number of peers connected, current block, highest block, pulled states count, known states countsdf /dev/sda --output=used | sed -n 2p
prints the used disk spaceiostat /dev/sda -d -x | awk {'print $4";"$5";"$16'} | sed -n 4p
returns the current disk speed (read/write) as well as the percentage utilization of the diskfree | awk {'print $3";"$2'} | sed -n 2p
prints the used and total memory of the systemfree | awk {'print $3";"$2'} | sed -n 3p
prints the used and total swap of the systemcat /proc/loadavg | awk {'print $1";"$2";"$3'}
returns the current load average (1min, 5min, 15min)iostat -c | sed -n 4p | awk {'print $1'}
prints the current CPU percentage utilizationcat /sys/devices/virtual/thermal/thermal_zone?/temp | sed -n 1p | awk '{ print $1/1000 }'
gives the CPU temperature`
You can replace /home/pi/geth_metrics.csv
by any files on the system.
As a result, every 15 min, the CSV file will be appended with new metrics.
1 | $ cat /home/pi/geth_metrics.csv |
Render the data into a spreadsheet
Now we have a consistent way to capture periodically our Geth and system metrics into a CSV, we can download this file and upload it to a Google Spreadsheet template.
- Download the CSV file
Connect via SSH using SCP to download the CSV file.
1 | scp [email protected]:/home/pi/geth_metrics.csv ~/Downloads/geth_metrics.csv |
- Create a copy of the spreadsheet template
Open the template and create a copy
- Import the CSV data into the
raw
sheet
- Select the tab sheet called
raw
- Click on File > Import
- Go to the Upload tab
- Select the file
geth_metrics.csv
downloaded - In the popup
- Import location: Replace current sheet
- Separator type: custom
;
- Click on “Import Data”
- Once imported, you should be able to navigate to the “Table” sheet and visualise every single metrics over time
In the “Charts” sheet, you can visualise diagrams for each metrics
Replay those steps every time you want to update the Geth metrics dashboard
Congrats
You can now:
- Track precisely the performance of your Geth node
- Observe the system health, investigate unusual behaviour and find the root cause of a problem
- Shill on Twitter your nice diagrams rather than dirty system logs