Analog-Labs / testnet_issue_tracker

This repository is dedicated to tracking issues reported by Analog testnet users
34 stars 12 forks source link

Enhanced Blockchain Node Monitoring and Notifications #619

Open catsmile100 opened 2 weeks ago

catsmile100 commented 2 weeks ago

Script Monitor Node Analog link Script : https://github.com/catsmile100/Validator-Testnet/blob/main/Analog/Monitor-Analog.md

This script is designed to monitor the status of a blockchain node and integrate it with a Telegram bot. It utilizes the local IP with port 9944 (default) as a means to fetch information from the node. Here's a more detailed explanation of how this script works:

  1. Fetching Node Information The getNodeInfo function is used to retrieve various information from the blockchain node through several HTTP requests using axios. The information retrieved includes:

    • Number of Connected Peers: Indicates how many peers are currently connected to the node.
    • Node Version: Displays the version of the running node.
    • Synchronization Status: Indicates whether the node is currently synchronizing or not.
    • Current Block: The block currently being processed by the node.
    • Highest Block: The highest block known by the node.
  2. Checking Synchronization Status The checkSyncStatus function is used to check if the blockchain node is out of sync. This function calls getNodeInfo and compares currentBlock and highestBlock to determine if there's a significant difference (>= 10 blocks). If there's a significant difference, it indicates that the node is not synchronized.

  3. Sending Telegram Messages The sendTelegramMessage function is used to send messages to Telegram users via the bot. These messages can be information about the node status or notifications if the node is not synchronized.

  4. Initializing Telegram Bot This part initializes the Telegram bot with the provided token and sets up polling to receive messages. The bot will respond to the /start command from users and display the "INFO" button.

  5. Handler for /start Command This section handles the /start command from users and displays the "INFO" button. When the "INFO" button is pressed, the bot will fetch node information and send it to the user.

  6. Handler for Callback Query This section handles the callback query when the user presses the "INFO" button. It calls getNodeInfo and sends the node information to the user.

  7. Interval for Checking Synchronization Status This part sets the interval to check the synchronization status of the node every 60 seconds. If the node is not synchronized, the bot will send a message to a specific chat ID to notify that the node is not synchronized.

Conclusion This script allows you to monitor the real-time status of a blockchain node and receive notifications via a Telegram bot. By utilizing the local IP and port 9944, this script can fetch crucial information from the node and deliver it to Telegram users, ensuring that you always have the latest information about your node status.


Motivation

The need to ensure the continuous and optimal operation of blockchain nodes is crucial, especially for systems that rely on real-time data and transactions. In situations where nodes go out of sync, it can lead to significant issues such as data inconsistency, transaction delays, and potential financial losses. Therefore, there is a necessity for a robust monitoring system that can provide timely alerts and detailed information about node status.

Problem Statement

Monitoring blockchain nodes manually is inefficient and prone to human error. Without automated monitoring, detecting issues such as node desynchronization or network connectivity problems can be delayed, leading to extended downtimes and operational inefficiencies. There's a clear need for an automated, reliable, and user-friendly solution to keep track of node health and status.

Suggested Solution

The suggested solution is to implement a script that automates the monitoring process of blockchain nodes and integrates it with a Telegram bot. This script should:

Additional Information

To evaluate this suggestion, consider the following:

This script aims to provide a seamless and efficient solution for monitoring blockchain nodes, ensuring minimal downtime and optimal performance.

source : https://github.com/catsmile100/Validator-Testnet/blob/main/Analog/Monitor-Analog.md https://catsmile.tech/

tiaro commented 2 weeks ago

this script is very good and useful! I don't know JS (I mean I understand, but can't write), so I translated it to Python (without Telegram sending part) and use for daily monitoring. Thank you

catsmile100 commented 2 weeks ago

yes please, the most important thing is the two main functions are still running, node information and node notification