############################################################################ # DashCentral.org Updater Version 7 (10/22/2020) ############################################################################ Use this script to further precise the monitoring of your masternodes and automatically restart crashed or hung nodes. The script does a "getnetworkinfo" request to your coin daemon, to obtain following JSON data values: blockheight, version, protocolversion, errors. The script is well tested, but you have to use it on your own risk. Let's get it up and running! It's a good idea to move the dashcentral-updater files to: /home/username/dashcentral-updater "username" is your linux login username. ************************************ * 1. A) Use "compiled" dashcentral-updater (linux, beginner) ************************************ If you want to use the "compiled" dashcentral-updater, you don't have to install any dependencies and you can directly move on to step 2. Disadvantage 1: you have to trust us that we did not compile anything bad. We can assure you, the binary is fine. Disadvantage 2: it may not run on any architecture (in case of problems, proceed with "source setup" below) Make sure the binary is executeable: chmod 755 /home/username/dashcentral-updater/dcupdater Test if the script works: cd /home/username/dashcentral-updater ./dcupdater If the script returns a message stating "malformed JSON string ..." everything is working correctly. We now have to proceed with step 2. Hint: In case running "dcupdater" leads to an error saying that GLIBC_2.28 is not found, please use the file "dcupdater_old_ubuntu". It is compiled to work with older ubuntu versions. ************************************ * 1. B) Use "source" dashcentral-updater (linux, recommended) ************************************ Install the following dependencies: --- perl: should be already installed on most linux operating systems Install on Debian/Ubuntu: sudo apt-get install libjson-rpc-perl libcrypt-ssleay-perl libio-socket-ssl-perl sudo perl -MCPAN -e 'install JSON::RPC::Legacy::Client' Install on other Linux: sudo perl -MCPAN -e 'install JSON::RPC::Legacy::Client' sudo perl -MCPAN -e 'install Bundle::LWP' sudo perl -MCPAN -e 'install Net::SSL' sudo perl -MCPAN -e 'install IO::Socket::SSL' (Running this script on windows has not been tested. You might start by installing perl from http://www.activestate.com/activeperl and then proceed with installation of the perl modules mentioned above) ************************************ * 2. Edit /home/username/dashcentral-updater/dashcentral.conf ************************************ Enter your Dashcentral API key. Get it from DashCentral.org "My Account" => "Account Settings"). ************************************ * 3. Configure your masternode RPC data in /home/username/dashcentral-updater/dashcentral.conf ************************************ Example for one masternode: our %masternodes = ( 'Xuia3V5v51AFTjYNtz6tpu9YrKYoWc9Ruz' => { 'rpc_host' => 'localhost', 'rpc_port' => 9998, 'rpc_user' => 'masternode1', 'rpc_password' => '123password', 'daemon_autorestart' => 'disabled', 'daemon_binary' => '/home/username/dash/dashd', 'daemon_datadir' => '/home/username/.dashcore' } ); Make sure your DASH daemon is configured correctly for RPC connections. /home/username/.dashcore/dash.conf RPC configuration example: rpcuser=masternode1 rpcpassword=123password rpcallowip=127.0.0.1 rpcport=9998 In case you have problems with the authentication, make sure your password contains only numbers and letters (no special chars). We'll configure the daemon autorestart at the end of this tutorial. So it's fine to leave the respective configuration values (daemon_autorestart ...) untouched for now. ************************************ * 4. You can also configure multiple (two or more) masternodes ************************************ Example of /home/username/dashcentral-updater/dashcentral.conf with two masternodes: our %masternodes = ( 'Xuia3V5v51AFTjYNtz6tpu9YrKYoWc9Ruz' => { 'rpc_host' => 'localhost', 'rpc_port' => 9998, 'rpc_user' => 'masternode1', 'rpc_password' => '123password', 'daemon_autorestart' => 'disabled', 'daemon_binary' => '/home/username/dash/dashd', 'daemon_datadir' => '/home/username/.dashcore' }, 'Xo1cwpFNHff5Nj12qWWXhCDyv5fPCdGZNR' => { 'rpc_host' => 'localhost', 'rpc_port' => 9998, 'rpc_user' => 'masternode2', 'rpc_password' => '123password', 'daemon_autorestart' => 'disabled', 'daemon_binary' => '/home/username/dash/dashd', 'daemon_datadir' => '/home/username/.dashcore' } ); ************************************ * 5. Run the dashcentral updater script ************************************ A) /home/username/dashcentral-updater/dcupdater ("compiled setup", beginner) B) perl /home/username/dashcentral-updater/dcupdater.pl ("source setup", recommended) Check if everything is running smoothly and proceed to next step. Hint: By default, dashcentral.conf located in the same directory as the script is used. In case you want to use a custom config location run: A) "compiled setup" /home/username/dashcentral-updater/dcupdater --config=/home/username/dashcentral-updater/dashcentral.conf B) "source setup" perl /home/username/dashcentral-updater/dcupdater.pl --config=/home/username/dashcentral-updater/dashcentral.conf ************************************ * 6. Configure a cronjob to run the script every 2 minutes ************************************ A) "compiled setup" */2 * * * * username /home/username/dashcentral-updater/dcupdater B) "source setup" */2 * * * * username perl /opt/dashcentral-updater/dcupdater.pl (Usemranme is your local user account.) ************************************ * 7. Go to DashCentral.org "My Account" => "Account Settings" ************************************ Enable "Masternode remote data monitoring". If everything went well, you should see a recent timestamp of the last data push in this configuration area. ************************************ * 8. Enable automatic masternode restart on crash or hang ************************************ Edit dashcentral.conf and set the value "daemon_autorestart" to "enabled". Also make sure that the path to the DASH daemon binary "daemon_binary" and the path to your DASH datadir "daemon_datadir" match your system configuration. Run a manual test, to make sure the automatic restart is working correctly. Ensure, your masternode is running, before running the following test command: A) "compiled setup" /home/username/dashcentral-updater/dcupdater -testrestart=ENTER_MASTERNODE_ADDRESS_TO_RESTART B) "source setup" perl /home/username/dashcentral-updater/dcupdater.pl -testrestart=ENTER_MASTERNODE_ADDRESS_TO_RESTART The output of the test command shows you, if the old DASH daemon process has been successfully killed and the new process has been started. If the test has been successful, you can lean back and enjoy. Next time your masternode crashes or hangs, the dcupdater script will send this information the the Dashcentral sever. If your masternode is unresponsive for at least 10 minutes, it will be restarted. You'll receive a notification of the restart and you'll see a log entry in your masternode incident log on the Dashcentral website. Timely automatic restarts of unresponsive masternodes avoids efficiently, that a masternode drops of the payment list and you miss a payment.