EOS account resource monitor tool

in #eos5 years ago

58137831d319b6807c0111e9839ac21945ab59a3.png

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:
Screen Shot 20190522 at 6.46.28 PM.png

Daily report, every 24 hours

How the email looks like:
Screen Shot 20190522 at 6.46.37 PM.png

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!

Coin Marketplace

STEEM 0.28
TRX 0.13
JST 0.032
BTC 65229.52
ETH 2946.17
USDT 1.00
SBD 3.67