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
or
$ curl -L https://bit.ly/glances | /bin/bash
or
$ wget -O- https://bit.ly/glances | /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 chia-plugin.sh
Below is the code for the plugin.
#!/bin/bash # # 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
[amp_Chia] enable=true regex=.*python* command=sh ~/chia-plugin/chia-plugin.sh refresh=10 oneline=true
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:
[fs] disable=False hide=/boot.*,/snap.*
--Steve
Want to help support? | |
Chia (XCH): | xch1xz9g7cyy79vnrh6nuyh86jq4ps6ah2ny0ck2050wfqqfjwkyk0mqd89etp |
HDDcoin (HDD): | hdd19vatjqxka49c5lht6nrf2cqc94va6rf9vv2mzu2793vq4dwq8wes842qff |
Bitcoin (BTC) no fee on Coinbase: | 3ADGMs1i6MU8Bxnr8qC6CPmgTUAS6DevyT |
Etherium (ETH) no fee on Coinbase: | 0x1F604e5a010f42F36e0C24868454f08056bc5B0A |
Venmo: | @steppsr |
Cash App: | $StevenStepp |
![]() |
One addition I made to the "chia-plugin.sh" file was to add in a section to determine the number of plots being created currently and report that into the data for glances.
ReplyDelete# 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"