EOS account resource monitor tool
Purpose
It has become necessary to obtain in advance information about the ending resources on an EOS account, in particular, about the amount of remaining RAM. A quick search did not give any ready-made solutions, so it was decided to write a simple script that would solve this problem.
Here it is: https://github.com/4ban/EOSAccountMonitor
Description
A simple tool that monitors resources for a set of accounts and sends emails (tested with using Gmail) if accounts run out of resources (RAM, CPU, NET). Also, tool will send daily reports about states for all accounts.
Resource alert, check every 5 hours
How the email looks like:
Daily report, every 24 hours
How the email looks like:
Details
The percentage of RAM is not a very reliable metric, an account can have free 800 bytes out of 1000 bytes which means 80% that is a good number, buе a single transaction can be 500 bytes, so even if the account has 20% of ram, this may not be enough even for a single transaction.
In this case, the estimated number of remaining transactions based on the average RAM per transaction size is used. Using an online monitor, I looked at the fact that the RAM size of transactions that are performed most often on accounts that interest me is 160 bytes
. Based on this, the estimated number of remaining transactions is calculated.
In my case, there was an account which took 747 bytes
of RAM for each transfer action. This account marked as heavy and the estimated number of remaining transactions is calculated based on this number.
As a limit for alerts I took:
RAM >= 90%
- Transactions left
<= 30
CPU >= 90%
NET >= 90%
Installation
The script is written by using Python 3
.
pip3 install tabulate
Usage
Fill the config file:
[DEFAULT]
# The timeout for checking accounts in hours
TIMEOUT=5
# The timeout for sending daily reports in hours
STATS_TIMEOUT=24
# Producer
PRODUCER=https://eos.greymass.com
ACCOUNTS=eosio.token,whaleextoken,community123,prospectorsg
# Credentials (Gmail server)
# to use anything other than gmail you need to manually change line 91.
MAIL_LOGIN={[email protected]}
MAIL_PASS={password}
# Recipients
[email protected],[email protected]
# Common transaction (bytes)
TR_USE=160
# Heavy transaction (bytes)
HEAVY_TR_USE=747
HEAVY_ACCOUNTS=accountname
Run: python3 app.py
Summary
I do not know whether anyone will benefit from this article and this tool. But since I decided to blog, I need to start somewhere, right?
EOF
Enjoy. Git cool!