Build your own Chia Plugin for Glances on Ubuntu Linux

First you need to ensure glances is installed. 

Glances Auto Install script

To install the latest Glances production ready version, just enter the following command line:

$ sudo apt install glances
$ curl -L | /bin/bash
$ wget -O- | /bin/bash

To run Glances normally:

$ glances
We will want to make sure Chia's python virtual environment is running BEFORE we launch glances. To make this simplier, I added an alias to my .bashrc file. You don't have to use an alias, but will you will need to manually start the virtual environment first.

$ nano .bashrc
# at the bottom of your .bashrc file add an alais for glances
alias gl="cd ~/chia-plugin && glances --fs-free-space --fahrenheit --process-short-name --enable-plugin sensors,chia"

With that alias, now you can just run the command below to launch Glances with your Plugin (that we will build next)

$ gl

Now lets create the actual plugin file for Chia. We will create a bash script that will build up the data to display in Glances.

Create a folder for the plugin in your user directory and change the directory to that folder.
$ mkdir chia-plugin
$ cd chia-plugin
Now we'll create a new text file with Nano.
$ nano
Below is the code for the plugin.
# The Chia python virtual environment must be active for this plugin to work properly
# since we are pulling data from Chia.
# To start the python virtual environment
#  $  cd ~/chia-blockchain
#  $  . ./activate
bal=`chia wallet show | grep '   .Total Balance:' | cut --fields 6 --delimiter=\ `
count=`chia farm summary | grep 'Plot count' | cut --fields 3 --delimiter=\ `
size=`chia farm summary | grep 'Total size of plots' | cut --fields 5,6 --delimiter=\ `
net=`chia farm summary | grep 'Estimated network space' | cut --fields 4,5 --delimiter=\ `
win=`chia farm summary | grep 'Expected time to win' | cut --fields 5,6,7,8,9 --delimiter=\ `

plugin="Wallet: $bal ~~~ $count plots - $size of $net ~~~ ETTW: $win"
echo $plugin

Ctrl + X to close nano. Be sure to say Yes to save the file.

Note: You must use back-ticks (the key to the left of the 1 key) for this to work. Commands inside of back-ticks are executed in Bash and the output returned to the script.

The last step is to add our new plugin into the glances configuration file so our plugin is actually ran inside of Glances. You may not have a glances configuration file, especially if you just installed it. I had to create a new text file and add the below code to it.

$ cd ~/.config/glances/

 If you get "No such file or directory" then you need to create the "glances" folder under ".config"

$ cd ~/.config
$ mkdir glances
Now lets update the configuration file.

$ nano glances.conf

command=sh ~/chia-plugin/
Note: the value of refresh is the number of seconds between each plugin run to update the data.

One final tip for the glances configuration file, I prefer to hide the boot and snap drives. Add the following into your glances.conf file:



  1. One addition I made to the "" file was to add in a section to determine the number of plots being created currently and report that into the data for glances.

    # update the number of plots being created on this server
    creating=`ps e -C "chia plots create" | grep -c "chia plots create"`

    plugin="Wallet: $bal xch ~~~ $count plots - $size of $net ~~~ ETTW: $win ~~~ Plotting: $creating"


Post a Comment

Popular posts from this blog