4 min read - Posted 03 May 20

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.

$ crontab -e

*/15 * * * * echo $(date --iso-8601=seconds)\;$(/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 "\"")\;$(df /dev/sda --output=used | sed -n 2p)\;$(iostat /dev/sda -d -x | awk {'print $4";"$5";"$16'} | sed -n 4p)\;$(free | awk {'print $3";"$2'} | sed -n 2p)\;$(free | awk {'print $3";"$2'} | sed -n 3p)\;$(cat /proc/loadavg | awk {'print $1";"$2";"$3'})\;$(iostat -c | sed -n 4p | awk {'print $1'})\;$(cat /sys/devices/virtual/thermal/thermal_zone?/temp | sed -n 1p | awk '{ print $1/1000 }') >> /home/pi/geth_metrics.csv

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 counts
  • df /dev/sda --output=used | sed -n 2p prints the used disk space
  • iostat /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 disk
  • free | awk {'print $3";"$2'} | sed -n 2p prints the used and total memory of the system
  • free | awk {'print $3";"$2'} | sed -n 3p prints the used and total swap of the system
  • cat /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 utilization
  • cat /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.

$ 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.

  1. Download the CSV file

Connect via SSH using SCP to download the CSV file.

$ scp user@xx.xx.xx.xx:/home/pi/geth_metrics.csv ~/Downloads/geth_metrics.csv
  1. Create a copy of the spreadsheet template

Open the template and create a copy

article image

  1. Import the CSV data into the raw sheet

  2. Select the tab sheet called raw
  3. Click on File > Import
  4. Go to the Upload tab
  5. Select the file geth_metrics.csv downloaded
  6. In the popup
    • Import location: Replace current sheet
    • Separator type: custom ;

article image

  • Click on "Import Data"

  • Once imported, you should be able to navigate to the "Table" sheet and visualise every single metrics over time

article image

In the "Charts" sheet, you can visualise diagrams for each metrics

article image

Replay those steps every time you want to update the Geth metrics dashboard


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
Created with Sketch.Content is"CC-BY-SA 4.0" licensed
Article Author

Grégoire Jeanmart

Kauri Software Engineer




Related Articles
(3/5) Collect metrics with Elastic Metricbeat for monitoring Kubernetes

Metricbeat is a lightweight shipper installed on a server to periodically collect metrics from the host and services running. This represents the first pillar of observability to monitor our stack. Metricbeat captures by default system metrics but also includes a large list of modules to capture specific metrics about services such as proxy (NGINX), message bus (RabbitMQ, Kafka), Databases (MongoDB, MySQL, Redis) and many others (find the full list here) Prerequisite - kube-state-metrics First,

(8/8) Deploy Prometheus and Grafana to monitor a Kubernetes cluster

This article is part of the series Build your very own self-hosting platform with Raspberry Pi and Kubernetes Introduction Install Raspbian Operating-System and