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
Great job Luke and great script to share with the other Witnesses as well!
Thank you, Brian. I hope it's helpful.
Thank-u @lukestokes for such a useful info
It's a lot of great posts to read. Your hosts are awesome Which benefits you. Can I do something good like steemit like you with your cooperation?
Sorry, I'm losing some of your meaning in the translation.
👍I follow and upvote you .you follow and upvote me👌please !!!!
The only way I follow and upvote people is if they provide value. Have you provided any value with your comment? Most likely you've only provided a reason to be flagged. Don't do that. Maybe this post can help.
This is precisely what happened to me. It's what prompted me to upgrade to a larger server with more RAM.
That's why I made this script. It's the most common reason a witness dies, I think.
Thanks Luke, going to be helpful for a lot of people who underestimate the blockchain and are surprised by how fast it expands.
Great post with full solution. good job bro. have fun
Thanks a lot for sharing this useful things...
That screenshot contains your email, maybe you should edit it.
I thought about that, but also thought, "Why?" My email is probably pretty easy to obtain via a google search. What would be the point of hiding it? I have 2FA for things that matter, so what's the real harm? Reminds me of this post.
I value privacy, I figured you might as well.
Thank you. What do you think of my post? Do you value privacy over the well-being it might diminish?
With the dangers of identity theft and harassment, I'll pick privacy anytime. Besides, putting personal info permanently on a blockchain is something to think about.
To assume your personally identifiable information isn't readily available online is naive to me, IMO. I prefer controlling the narrative by controlling who I am, online and offline and putting more out there than any adversary could. When I'm googled online today, it's all stuff I've put out there. If people value privacy too much, they give up their ability to control the narrative online about themselves, IMO.
I don't give away my private life on fb like the sheeplings do, therefore I'm a shadow.
Good stuff man
Thanks man.
Anytime
Great idea!
If you'd like to send the 'used' figure via a call such as:
https://www.steemreports.com/api/witness-info?shm=16106127360&key=*****
I can include, and probably graph it over time. If so, maybe you could send a private message with some key for identification?
Perhaps somebody could do the same with a full RPC node too?
Thank you so much! This should make our lives a bit more easy :)
Awesome! My node was crashing an I had no idea where it came from. I got a hint looking at the logs. Now I need to increase the size of /dev/shm from 16G. I might need to change the setting to a more expensive vps if my 32G of ram is not enough anymore.
32GB should be fine. Just don't make your /dev/shm bigger than the free ram you have.