I have written this blog post as a guide on how I got the monit daemon working to monitor the zend daemon. Thanks to Rolf at Blockoperations for all the hard work to get this up and running.
Please ensure that your node is working properly by running zend manually before trying to configure monit
This is how I converted my nodes that originally used crontab to start zend.
First start up crontab and delete the line that starts zend on boot.
delete @reboot zend
Then I installed the monit software by running:
sudo apt install monit
Next we need to create the script that will start/stop zend and generate the Process ID (.pid file). I like to use nano for editing files so my command is:
Now this next part is the script that you will need to copy and paste into the zen_node.sh file. Please change the
<your_user_name> to the username that you log into node with. I have not included the text of the code, but instead an image of the code, so you will not be able to copy and paste. The script is available on the Blockoperations website here under the monit section.
Next is to make the new file an executable script:
chmod u+x ~/zencash/zen_node.sh
Now we need to edit the monitrc configuration file. This is done by editing /etc/monit/monitrc using your favourite editor:
sudo nano /etc/monit/monitrc
I like to have monit service poll my processes once every 10 seconds. To do this find the line that says:
set daemon 120
And change it to:
set daemon 10
Then add the following section to the bottom of the monitrc file:
Note: Please replace the
<your_user_name> with the username you log into your node with.
If you want to have email notifications, install postfix and add this section below the section above:
Note: Please change the your_node and [email protected] to your details
Now reload monit with our new configuration using:
sudo monit reload
And then start zend using the monit service:
sudo monit start zend
To stop the zend daemon run:
sudo monit stop zend
If you find this blog useful, and if you would like to keep it up and running, donations are always appreciated to any of the following addresses: