A comprehensive system monitoring and event processing framework that generates STEP (Space, Time, Event, Psychology) messages for real-time system observability and analysis.
The STEP System consists of two main components:
- STEP Generator (
step_generator.py) - Monitors Linux system activities and generates structured STEP messages - STEP-BUS (
step-bus.py,step-bus1.py) - Universal event bus architecture for receiving, routing, and distributing STEP messages
STEP messages are structured event notifications that capture four key dimensions:
- Space: Where the event occurred (hostname, IP, location context)
- Time: When the event happened (timestamps, duration)
- Event: What happened (event type, description, metadata)
- Psychology: Emotional context of the event (valence, intensity)
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"time": {
"start": 1693872000000
},
"event": {
"type": "system.cpu.high",
"description": "CPU usage at 85%"
},
"space": {
"hostname": "server01",
"ip": "192.168.1.100",
"cpu_percent": 85
},
"psychology": {
"valence": -0.3,
"intensity": 0.7
}
}The STEP Generator monitors various system activities and generates STEP messages in real-time:
- CPU Usage: Alerts when CPU usage exceeds 80%
- Memory Usage: Tracks memory consumption above 85%
- Disk I/O: Monitors heavy disk read/write operations (>50MB)
- Network Traffic: Detects high network activity (>10MB)
- Process Management: Tracks process creation and termination
- File System Events: Monitors file creation, deletion, and modification (requires pyinotify)
- User Activity: Tracks active user sessions
- Multi-threaded monitoring for concurrent system observation
- Psychology scoring for system stress indicators
- Optional integration with STEP-BUS for centralized collection
- Console output and remote publishing support
The STEP-BUS provides a universal event bus architecture for STEP message processing:
- Message Publishing: REST API for publishing STEP messages
- Pattern-based Subscriptions: Subscribe to specific event types or patterns
- WebSocket Support: Real-time message streaming
- Message History: In-memory and Redis-backed message persistence
- Query Interface: Historical message retrieval with pattern matching
- Statistics: Real-time bus performance metrics
POST /step- Publish a STEP messagePOST /subscribe- Create subscription patternDELETE /subscribe/{id}- Remove subscriptionGET /query- Query historical messagesGET /stats- Bus statisticsWS /ws- WebSocket subscription endpoint
pip install psutil fastapi uvicorn websockets redis pydanticpip install pyinotify # For file system monitoring on Linux# Console output only
python step_generator.py
# With STEP-BUS integration
python step_generator.py --bus-url http://localhost:8080/step# Start the event bus server
python step-bus.pyThe STEP-BUS will be available at:
- REST API: http://localhost:8080/docs
- WebSocket: ws://localhost:8080/ws
curl -X POST http://localhost:8080/step \
-H "Content-Type: application/json" \
-d '{
"event": {"type": "custom.test", "description": "Test message"},
"space": {"source": "api"},
"psychology": {"valence": 0.5, "intensity": 0.3}
}'curl "http://localhost:8080/query?limit=10"const ws = new WebSocket('ws://localhost:8080/ws?pattern={"event":{"type":"system.cpu.high"}}');
ws.onmessage = function(event) {
console.log('Received STEP:', JSON.parse(event.data));
};┌─────────────────┐ ┌──────────────┐ ┌─────────────────┐
│ STEP Generator │───▶│ STEP-BUS │───▶│ Subscribers │
│ (System Monitor)│ │ (Event Bus) │ │ (Applications) │
└─────────────────┘ └──────────────┘ └─────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌──────────────┐ ┌─────────────────┐
│ System Events │ │ Message │ │ Real-time │
│ • CPU/Memory │ │ History │ │ Notifications │
│ • Disk/Network │ │ (Redis) │ │ • WebSocket │
│ • Processes │ │ │ │ • Callbacks │
│ • Files │ │ │ │ • Dashboards │
└─────────────────┘ └──────────────┘ └─────────────────┘
- Monitoring thresholds can be adjusted in the source code
- Custom event types can be added by extending the monitor methods
- Psychology scoring can be customized for different event types
- Redis URL: Configure Redis connection for message persistence
- Message history limits: Adjust in-memory and Redis storage limits
- WebSocket and REST API ports: Configurable in the main execution block
- System Monitoring: Real-time system health monitoring and alerting
- Performance Analysis: Historical system performance data analysis
- Anomaly Detection: Pattern-based detection of unusual system behavior
- Integration Testing: Event-driven testing and validation frameworks
- Observability: Comprehensive system observability and debugging
- Automation: Event-triggered automation and workflow systems
The system includes emotional context through psychology scoring:
- Valence: Emotional positivity (-1.0 negative to +1.0 positive)
- Intensity: Emotional strength (0.0 low to 1.0 high)
This enables:
- System "mood" tracking
- Stress level monitoring
- Intelligent alerting based on emotional context
- Human-like interpretation of system states
Extend the LinuxStepGenerator class with new monitor methods:
def monitor_custom_metric(self):
"""Monitor custom system metric"""
while self.running:
# Your monitoring logic here
if condition:
step = self.create_step(
"custom.metric.event",
"Custom event description",
{"custom_data": value},
{"valence": 0.0, "intensity": 0.5}
)
self.publish_step(step)
time.sleep(interval)Create custom STEP message processors:
def custom_handler(step_message):
"""Process incoming STEP messages"""
if step_message.event.get("type") == "system.cpu.high":
# Handle high CPU events
send_alert(step_message)
# Subscribe to specific patterns
bus.subscribe({"event": {"type": "system.cpu.high"}}, custom_handler)This project is open source and available under standard open source licensing terms.
Contributions are welcome! Areas for improvement:
- Additional system monitors
- Enhanced pattern matching
- Dashboard interfaces
- Mobile notifications
- Cloud integrations
- Machine learning analysis
STEP System - Bringing consciousness to system monitoring