Overview
When enabled, Chainbench sends notifications to your chosen ntfy.sh topic at key moments:- Test Started: When the benchmark begins in headless mode
- Test Finished: When the benchmark completes or is stopped
- Mobile devices (iOS/Android apps)
- Desktop (web browser)
- Command line
- Email (via ntfy.sh email integration)
Quick Start
Enable notifications by adding the--notify flag with a topic name:
How It Works
ntfy.sh Architecture
Chainbench uses ntfy.sh’s public instance by default:- When
--notifyis specified, Chainbench publishes messages tohttps://ntfy.sh/{your-topic} - You subscribe to the same topic using the ntfy.sh app or web interface
- Messages are delivered in real-time to all subscribers
The default ntfy.sh server is public and requires no authentication. Anyone who knows your topic name can receive your notifications. Use a random, hard-to-guess topic name for privacy.
Notification Flow
Notifier instance that sends messages to your topic:
Subscribing to Notifications
Mobile Apps
iOS
iOS
- Install the ntfy app from the App Store
- Open the app and tap “Subscribe to topic”
- Enter your topic name (e.g.,
my-chainbench-tests) - Notifications will appear as push notifications
Android
Android
- Install the ntfy app from Google Play or F-Droid
- Open the app and tap the ”+” button
- Enter your topic name
- Grant notification permissions when prompted
Web Browser
Visithttps://ntfy.sh/{your-topic} in any browser:
- Real-time notifications as they arrive
- History of recent messages
- Options to customize notification sound and behavior
Command Line
Subscribe using curl:Notification Features
Priority Levels
The Notifier class supports 5 priority levels:DEFAULT priority for all notifications.
Tags (Emojis)
Notifications include visual indicators:- loudspeaker (📢): Test started
- tada (🎉): Test finished
Message Content
Notifications include:- Title: “Test started” or “Test finished”
- Message: Profile name and test context
- Timestamp: Automatically added by ntfy.sh
Advanced Configuration
Custom ntfy.sh Server
While not exposed via CLI, you can host your own ntfy.sh server for privacy:Email Notifications
Configure ntfy.sh to forward notifications to email:File Attachments
The Notifier class supports attaching files to notifications:Use Cases
Long-Running Benchmarks
Long-Running Benchmarks
For tests running several hours or overnight:Receive a notification on your phone when the test completes.
Automated Testing Pipelines
Automated Testing Pipelines
In CI/CD or scheduled testing:Monitor automated tests without polling.
Multi-Node Testing
Multi-Node Testing
When benchmarking multiple nodes simultaneously:Get notified as each node’s test completes.
Team Collaboration
Team Collaboration
Share a topic with your team:Everyone subscribed to the topic receives notifications.
Privacy and Security
Topic Name Best Practices
Follow these practices:-
Use random topic names:
-
Avoid sensitive information in notifications:
- Don’t include passwords, API keys, or internal hostnames
- Use generic messages or run IDs
-
Use access tokens on self-hosted ntfy.sh:
- Configure authentication on your own server
- Restrict topic access to authorized users
Data Retention
ntfy.sh public instance:- Messages are stored for 12 hours by default
- After that, they’re permanently deleted
- No logs of message content are kept
Troubleshooting
Not Receiving Notifications
-
Verify topic name matches:
- Check the topic in your subscription
- Ensure no typos or extra spaces
-
Test manually:
-
Check app permissions:
- Ensure notification permissions are granted
- Check Do Not Disturb settings
-
Verify headless mode:
- Test started notifications only appear in
--headlessmode - Test finished notifications always appear
- Test started notifications only appear in
Delayed Notifications
ntfy.sh uses HTTP streaming for real-time delivery:- Mobile apps may experience delays if in battery saver mode
- Web interface requires an active connection
- Consider using email forwarding for critical alerts
Connection Issues
If Chainbench can’t send notifications:- Check your internet connection
- Verify
https://ntfy.shis accessible - Look for proxy or firewall restrictions
Alternative: NoopNotifier
When--notify is not specified, Chainbench uses a no-op notifier:
Implementation Reference
The notification system consists of:Core Classes
Notifier (chainbench/util/notify.py:82):
- Handles HTTP requests to ntfy.sh
- Supports custom servers, priorities, tags, emails, and file attachments
Notification (chainbench/util/notify.py:29):
- Dataclass representing a notification message
- Builds HTTP headers and content
NoopNotifier (chainbench/util/notify.py:123):
- Null object pattern for disabled notifications
Integration Points
CLI Argument (chainbench/main.py:168):- Test started: Line 426
- Test finished: Line 455