One of the most common reasons a witness node stops producing blocks is the ever-increasing size of the STEEM blockchain exceeded the amount of RAM allocated to it in the /dev/shm file. Similar to the witness monitoring script I wrote which sends me a text if the logs ever look funky, the point of this script is to send me a daily email showing the size of the shared memory file on my various servers like this:
It's a simple python script which you run via cron like so:
# Import smtplib for the actual sending function
import smtplib
import subprocess
# Import the email modules we'll need
from email.mime.text import MIMEText
df = subprocess.Popen(["df", "-h", "/dev/shm"], stdout=subprocess.PIPE)
output = df.communicate()[0]
device, size, used, available, percent, mountpoint = \
output.split("\n")[1].split()
msg = MIMEText("US Witness server shm file size:\n" + output)
msg['Subject'] = "US Witness shm Available: "+available
msg['From'] = "***********@gmail.com"
msg['To'] = "***********@gmail.com"
s = smtplib.SMTP_SSL('smtp.gmail.com')
s.login('***********@gmail.com','*** APP PASSWORD ***')
s.sendmail(msg['From'], [msg['To']], msg.as_string())
s.quit()
Name the file something like check_shm.py
and change these values:
- Replace
**********@gmail.com
with your Gmail address. - Replace
*** APP PASSWORD ***
with your SMTP password. - Replace
US Witness
with something descriptive.
If you're not sure how to set up an app password for your GMail account, see my previous post. If you have another method of sending mail from your server (sendmail, etc), you can use that as well.
Next, set up a cron job via crontab -e to run this script as often as you like
0 1 * * * cd /root/steem-docker; python check_shm.py
With that setting on each of your servers and nodes, you'll get a nice daily email like this:
Though Witness rankings can change at any moment, I'm currently just barely in the top 20. Thank you so much for your support and for powering up which keeps your vote strong.
(Note: this post is mostly for my fellow witnesses and backup witnesses. If you're a regular reader of my blog, don't worry if you don't understand a word of this! :)
Luke Stokes is a father, husband, business owner, programmer, STEEM witness, and voluntaryist who wants to help create a world we all want to live in. Visit UnderstandingBlockchainFreedom.com