Skip to content

Midnight-Scripts/Midnight-Live-View

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 

Repository files navigation

Midnight Node Monitoring


Credits

  • CNTool's gLiveView - Dashboard inspiration and design
  • @RcadaPool SPO - Key-checker script logic

Version Information

  • LiveView version: 0.2.1
  • Tested on: Midnight Validator Node - Testnet - Version: 0.12.0-cab67f3b

A comprehensive monitoring solution for Midnight blockchain nodes, featuring real-time dashboard monitoring and persistent block tracking.

Screenshot 2025-08-18 at 11 47 56 AM

What's Included

  • LiveView.sh - Real-time monitoring dashboard (inspired by CNTool's gLiveView)
  • simple_block_monitor.sh - Persistent block tracking that survives Docker restarts
  • Integration - Historic block counting that shows total blocks since monitoring started

Tested

Midnight Node Monitor - Version: 0.12.0-29935d2f

Prerequisites

Required Dependencies

  • jq - Command-line JSON processor
  • curl - For API calls
  • docker - If using Docker deployment
  • Standard utilities: awk, date, grep, etc.

Required Files

  1. partner-chains-public-keys.json - Must be in the same directory as LiveView.sh
  2. Midnight node running (Docker container named "midnight" by default)

Node Configuration

To enable full monitoring features, update your .envrc file:

Modify the APPEND_ARGS line:

If you have 2 server setup ( Side chain on one and Midnight node on one )

# From:
export APPEND_ARGS="--allow-private-ip --pool-limit 10 --trie-cache-size 0 --prometheus-external --rpc-external"

# To:
export APPEND_ARGS="--validator --allow-private-ip --pool-limit 10 --trie-cache-size 0 --prometheus-external --unsafe-rpc-external --rpc-methods=Unsafe --rpc-cors all"

If you have 1 server setup ( Side chain and Midnight node on same server )

# From:
export APPEND_ARGS="--allow-private-ip --pool-limit 10 --trie-cache-size 0 --prometheus-external --rpc-external"

# To:
export APPEND_ARGS="--validator --allow-private-ip --pool-limit 10 --trie-cache-size 0 --prometheus-external --unsafe-rpc-external --rpc-methods=Unsafe --rpc-cors all --rpc-port 9944 --keystore-path=/data/chains/partner_chains_template/keystore/"

NOTE = Change the key store path if necessary


Installation & Setup

1. Download the Files

# Download all files to your preferred directory
wget -O ./LiveView.sh  https://raw.githubusercontent.com/Midnight-Scripts/Midnight-Live-View/refs/heads/main/LiveView.sh
wget -O ./simple_block_monitor.sh  https://raw.githubusercontent.com/Midnight-Scripts/Midnight-Live-View/refs/heads/main/simple_block_monitor.sh
chmod +x LiveView.sh simple_block_monitor.sh

2. Basic Setup (LiveView Only)

# Just run the dashboard
./LiveView.sh

3. Full Setup (Dashboard + Persistent Tracking)

# Step 1: Start the block monitor (creates all_blocks.json)
./simple_block_monitor.sh start

# Step 2: Run the dashboard (will show historic blocks)
./LiveView.sh

LiveView.sh - Real-Time Dashboard

Features

  • Node Information: Version, uptime, container start time
  • Security: Node key (masked), port, key status
  • Registration: Registration status
  • Block Data:
    • Historic blocks (total since monitoring started)
    • Blocks produced (since Docker restart)
    • Latest/finalized blocks, sync status
  • Network: Peer count and details
  • System: CPU, memory, disk usage

Usage

./LiveView.sh

Interactive Controls

  • [q] - Quit
  • [p] - View peer details

Configuration

Update these variables if needed:

Environment (USER VARIABLES)

Make sure to check and update the user variables below according to your setup:

# ─── USER VARIABLES ────────────────────────────────
CONTAINER_NAME="${CONTAINER_NAME:-midnight}"
PORT="${PORT:-9944}"
USE_DOCKER="${USE_DOCKER:-true}"

Simple Block Monitor - Persistent Tracking

Overview

Monitors Docker logs for new blocks and maintains a persistent all_blocks.json file. This data survives Docker restarts and provides long term block tracking.

Commands

Start Background Monitoring

./simple_block_monitor.sh start
  • Runs in background
  • Creates block_monitor.log and .block_monitor.pid
  • Continuously appends new blocks to all_blocks.json

Stop Background Monitoring

./simple_block_monitor.sh stop

Check Status

./simple_block_monitor.sh status
  • Shows if monitor is running
  • Displays current block count

Run Interactively

./simple_block_monitor.sh run
  • Shows real-time output
  • Press Ctrl+C to stop

Files Created

  • all_blocks.json - Persistent block database
  • block_monitor.log - Monitor activity log
  • .block_monitor.pid - Process tracking file

Usage Workflows

Option 1: Basic Monitoring

# Just run the dashboard
./LiveView.sh
  • Shows current session blocks only
  • Blocks reset on Docker restart

Option 2: Full Persistent Monitoring (Recommended)

# Start persistent block tracking
./simple_block_monitor.sh start

# Run dashboard with historic data
./LiveView.sh
  • Dashboard shows both historic and current blocks
  • Historic count survives Docker restarts
  • Continuous background monitoring

Option 3: One-Time Check

# Check monitor status
./simple_block_monitor.sh status

# Run dashboard
./LiveView.sh

Integration Features

When both tools are used together:

  1. Historic Blocks Line: LiveView shows total blocks since monitoring started
  2. Persistent Data: Block count survives Docker container restarts
  3. Duplicate Prevention: Only truly new blocks are added to the database
  4. Automatic Integration: LiveView automatically detects and uses all_blocks.json

File Structure

full pack/
├── LiveView.sh                    # Real-time dashboard
├── simple_block_monitor.sh        # Block tracking script
├── partner-chains-public-keys.json # Required keys file
├── all_blocks.json                # Block database (created automatically)
├── block_monitor.log              # Monitor logs (created automatically)
├── .block_monitor.pid             # Process tracking (created automatically)
└── README.md                      # This file

Troubleshooting

LiveView Issues

Dashboard not showing data:

# Test RPC connection
curl -s http://127.0.0.1:9615/metrics
  • Should return metrics data
  • Update CONTAINER_NAME and PORT variables if needed

Block Monitor Issues

"Blocks file not found":

  • Run ./simple_block_monitor.sh start to create all_blocks.json

"Monitor already running":

./simple_block_monitor.sh stop
./simple_block_monitor.sh start

No new blocks appearing:

  • Check if node is producing blocks
  • Verify container name: docker ps
  • Check logs: tail -f block_monitor.log

General Issues

Permission denied:

chmod +x LiveView.sh simple_block_monitor.sh

Missing dependencies:

# Ubuntu/Debian
sudo apt update && sudo apt install jq curl

# macOS
brew install jq curl

Environment Variables

  • CONTAINER_NAME - Docker container name (default: "midnight")
  • PORT - RPC port (default: 9944)
  • USE_DOCKER - Use Docker commands (default: true)

Notes

  • Docker logs are not persistent by default use Simple Block Monitor for long term tracking
  • The dashboard refreshes every second
  • Block monitor prevents duplicate entries automatically
  • Both tools can run independently or together

Contribute to World Development

Please stake some ADA to Enigma ticker one. This helps us to continue building and maintaining the midnight tools.

About

Ment to display help full info about midnight validator node

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages