Thanks to @lukestokes, who was kind enough to create a script, which notifies if witness server stops working I have added this functionality to our server as well. Tested it, works perfectly! I think that this is a must have for every witness.
Steemit software is not perfect and for some reason, it might stop working.
We have seen some cases when an accounts sent out spam messages which caused some witness servers to stop functioning or when a false power-down was allowed to happen because of a bug in software and the whole network stopped to protect accounts.
Having notifications being sent out to witness owners if a witness server stops working is crucial to protect our Steemit blockchain. Thanks again @lukestokes for creating such a script for everyone to use. Here is a link to the original article: https://steemit.com/witness-category/@lukestokes/bash-script-to-monitor-your-witness-node
Please find below detailed installation instructions on how to install the sctipt below for those of you who are not so advanced in using the console. These instructions apply to the @someguy123 STEEM-in-a-box, although I believe it should work on any set-up. If you have a chance to test it on regular setup, please let us know in the comments section.
This script monitors the witness server using ./run.sh logs command, and writes the latest block to the last_block.txt file. If the block number is lower then the one in the file it will send a notification using python using your credentials in the sendnotice.py file. It also logs errors in notification_sent.txt file.
Step 1 - Intal python
You will need python to send out an SMS or an email. Install it if you don't have python installed already
Install prerequisites
sudo apt-get update
sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
Download and extract Python
cd /usr/src
sudo wget https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tgz
sudo tar xzf Python-2.7.14.tgz
Compile Python Source
cd Python-2.7.14
sudo ./configure --enable-optimizations
sudo make altinstall
Check python version
python2.7 -V
Step 2 - Create your scripts
Navigate to your Steem-in-the-box docker
cd steem-docker
Create check_status.sh file (which monitors the logs)
nano check_status.sh
Paste in the code (ctrl + v) and to save and close type "Y" and hit Enter
#!/usr/bin/env bash
if [ -f notification_sent.txt ]; then
exit 1
fi
if [ ! -f last_block.txt ]; then
echo "1" > last_block.txt
exit 1
fi
last_saved_block=$(< last_block.txt)
latest_log_entry=$(./run.sh logs | tail -n 1)
if [[ $latest_log_entry == *"Generated block"* ]]; then
echo "We just mined a block. Exiting."
exit 1
fi
latest_block=$(echo $latest_log_entry | awk '{print $11;}')
# to test, uncomment this next line:
#latest_block=""
if [[ "$latest_block" -gt "$last_saved_block" ]]; then
echo "We're good. Latest block is... $latest_block"
echo $latest_block > last_block.txt
exit 1
fi
# Houston, we have a problem!
echo "There seems to be a problem."
echo "Last saved block: $last_saved_block"
echo "Latest block: $latest_block"
python sendnotice.py
echo -e "Something went wrong. Here's what we got for the latest block: $latest_block \r\n" > notification_sent.txt
./run.sh logs >> notification_sent.txt
Create a file which sends out notification
nano sendnotice.py
Paste in the following code (ctrl + v) and to save and close type "Y" and hit Enter
# Import smtplib for the actual sending function
import smtplib
# Import the email modules we'll need
from email.mime.text import MIMEText
msg = MIMEText("Check your Steemit Witness Node!")
msg['Subject'] = "Witness Node ERROR!"
msg['From'] = "YOURFROMEMAILHERE"
msg['To'] = "**********@txt.att.net"
s = smtplib.SMTP_SSL('smtp.gmail.com')
s.login('************@gmail.com','*********APP PASSWORD**********')
s.sendmail(msg['From'], [msg['To']], msg.as_string())
s.quit()
Edit the following fields
- Replace YOURFROMEMAILHERE with your email address.
- Replace ***********@txt.att.net with your 10 digit phone number and domain for your phone carrier service. You can also just insert your gmail email address for email notifications
- Replace *************@gmail.com with your gmail login.
- Replace *********APP PASSWORD********** with your gmail password
Step 3 - Test email script
python sendnotice.py
If you receive an email from google saying that the app was blocked you can try to change these settings to ON.
Or if google blocks your server attempt to send an email "Review blocked sign-in attempt", visit this link: https://myaccount.google.com/security and press "Review devices" and mark that this device is yours.
Step 4 - Test main script
bash check_status.sh
If everything is ok you should see something like this
Step 5 - Setup Cron job to every minute
check your current path
pwd
Open up crontab (I prefer using nano to edit contab)
export VISUAL=nano; crontab -e
Paste in this code at the bottom of the file but instead of "/yuriks2000/steem-docker" use your path, which you got earlier using pwd command
* * * * * cd /yuriks2000/steem-docker; ./check_status.sh
Then to close press (ctrl + c ) and to save and close type Y and hit Enter
Thats all folks!
Thank you for your attention, hope that this initiative by @lukestokes, will help us all to secure Steemit blockchain even better. I remember that because of this script @lukestokes was the first to react during the network halt on July 3ed 2018.
@yuriks2000 your loyal Steemit Witness and a CEO of BoomApps developing SteemApp, a completely free app for Steemians
Please support @yuriks2000 and @lukestokes by voting for us as Witness
Go to https://steemit.com/~witnesses
Or vote for us through steemconnect
Have a lovely day!
This is why we love Steemit!

Hi @yuriks2000, I'm @checky ! While checking the mentions made in this post I found out that @txt.att.net doesn't exist on Steem. Maybe you made a typo ?
If you found this comment useful, consider upvoting it to help keep this bot running. You can see a list of all available commands by replying with
!help
.Great post! I just followed you and upvoted you! Follow me back @relsserd.
you are my witness.@yuriks2000
@yuriks2000 you were flagged by a worthless gang of trolls, so, I gave you an upvote to counteract it! Enjoy!!