Statistics & Monitoring
Performance monitoring and statistic relay system for LegacyStream
Statistics & Monitoring
LegacyStream provides comprehensive monitoring and statistics capabilities to help you track server performance, stream health, and relay statistics to external services.
Real-time Performance
Monitor CPU usage, memory consumption, and I/O performance in real-time
Stream Analytics
Track listener counts, bitrates, and stream quality metrics
Statistic Relay
Automatically relay statistics to external IceCast and SHOUTcast servers
Performance Monitoring
The PerformanceManager component provides comprehensive system monitoring and optimization capabilities.
System Metrics
Monitor the following system metrics in real-time:
- CPU Usage: Current CPU utilization percentage
- Memory Usage: RAM consumption and allocation patterns
- I/O Performance: Network and disk I/O statistics
- Thread Performance: Worker thread efficiency and load distribution
Performance Optimization
Automatic optimization features include:
- Memory Pooling: Efficient memory allocation and deallocation
- IOCP Optimization: Windows I/O Completion Port optimization
- Buffer Management: Intelligent buffer sizing and recycling
- Thread Management: Dynamic thread pool sizing
Performance Statistics Structure
struct PerformanceStats {
double cpuUsage; // CPU usage percentage
double memoryUsage; // Memory usage percentage
qint64 totalMemory; // Total memory in bytes
qint64 availableMemory; // Available memory in bytes
qint64 networkBytesIn; // Network bytes received
qint64 networkBytesOut; // Network bytes sent
int activeConnections; // Active client connections
int workerThreads; // Active worker threads
double avgResponseTime; // Average response time in ms
};
Statistic Relay System
The statistic relay system automatically forwards stream statistics to external IceCast and SHOUTcast servers.
Supported Protocols
IceCast Relay
Relay statistics to IceCast servers with authentication
- Host and port configuration
- Username and password authentication
- Mount point alias support
- Automatic retry on failure
SHOUTcast Relay
Relay statistics to SHOUTcast servers
- Host and port configuration
- Password authentication
- Session ID support (v2)
- Fallback authentication
Configuration
Configure statistic relay in your configuration file:
Example Configuration
[Server]
Location=My Streaming Server
Hostname=stream.example.com
SourcePassword=sourcepass123
RelayPassword=relaypass456
AdminUsername=admin
AdminPassword=adminpass789
[StatisticRelay]
Enabled=true
UpdateInterval=30
[IcecastRelay]
Enabled=true
Host=icecast.example.com
Port=8001
Username=admin
Password=adminpass789
Alias=/live
[ShoutcastRelay]
Enabled=true
Host=shoutcast.example.com
Port=8000
Password=relaypass456
SID=1
Authentication Fallback
The system uses a fallback authentication mechanism:
- If relay-specific credentials are not provided, global server credentials are used
- IceCast relay uses admin username/password from server settings
- SHOUTcast relay uses relay password from server settings
- Server hostname is automatically used for URL construction
Web Interface Statistics
The web interface provides real-time statistics and monitoring capabilities.
Real-time Dashboard
Access comprehensive statistics through the web interface:
- Server Statistics: CPU, memory, network usage
- Stream Statistics: Listeners, bitrates, quality metrics
- Mount Point Details: Server type, description, format, started time
- Relay Status: Connection status and relay statistics
WebSocket Updates
Real-time updates via WebSocket connections:
WebSocket Message Format
{
"type": "stats_update",
"timestamp": 1640995200,
"data": {
"cpu_usage": 45.2,
"memory_usage": 67.8,
"active_connections": 125,
"total_listeners": 342,
"mount_points": [...]
}
}
Analytics Dashboard
Advanced analytics and visualization features:
- Historical performance charts
- Listener trend analysis
- Stream quality metrics
- Relay performance monitoring
API Endpoints
Access statistics programmatically through REST API endpoints.
Server Statistics
GET /api/stats
Get comprehensive server statistics
{
"cpu_usage": 45.2,
"memory_usage": 67.8,
"total_memory": 8589934592,
"available_memory": 2768240640,
"network_bytes_in": 1048576,
"network_bytes_out": 2097152,
"active_connections": 125,
"worker_threads": 8,
"avg_response_time": 12.5
}
GET /api/mountpoints
Get detailed mount point information
[
{
"path": "/live",
"listeners": 45,
"bitrate": 128,
"format": "MP3",
"server_type": "IceCast",
"description": "Live Stream",
"started": "2025-01-01T12:00:00Z",
"quality": "High"
}
]
Relay Statistics
GET /api/relay/status
Get relay connection status
{
"icecast": {
"connected": true,
"last_update": "2025-01-01T12:00:00Z",
"error_count": 0
},
"shoutcast": {
"connected": true,
"last_update": "2025-01-01T12:00:00Z",
"error_count": 0
}
}
GET /api/analytics
Get analytics data
{
"listener_trends": [...],
"performance_metrics": [...],
"relay_statistics": [...]
}
Configuration
Configure monitoring and statistics features through the configuration system.
Performance Settings
Setting | Description | Default |
---|---|---|
EnablePerformanceMonitoring | Enable real-time performance monitoring | true |
PerformanceUpdateInterval | Performance stats update interval (seconds) | 5 |
MemoryPoolSize | Memory pool size in MB | 256 |
WorkerThreads | Number of worker threads | 8 |
Relay Settings
Setting | Description | Default |
---|---|---|
EnableStatisticRelay | Enable statistic relay system | false |
RelayUpdateInterval | Relay update interval (seconds) | 30 |
RelayRetryAttempts | Number of retry attempts on failure | 3 |
RelayTimeout | Relay connection timeout (seconds) | 10 |
Troubleshooting
Common issues and solutions for statistics and monitoring.
Performance Issues
High CPU Usage
Symptoms: Server becomes unresponsive, high CPU utilization
Solutions:
- Reduce worker thread count
- Increase memory pool size
- Check for memory leaks
- Optimize codec settings
Memory Issues
Symptoms: Out of memory errors, slow performance
Solutions:
- Increase memory pool size
- Enable memory compression
- Check for memory leaks
- Reduce buffer sizes
Relay Issues
Connection Failures
Symptoms: Relay statistics not updating
Solutions:
- Verify host and port settings
- Check authentication credentials
- Ensure network connectivity
- Check firewall settings
Authentication Errors
Symptoms: 401/403 errors from relay servers
Solutions:
- Verify username/password
- Check credential fallback settings
- Ensure proper permissions
- Test with manual authentication
Web Interface Issues
Statistics Not Updating
Symptoms: Web interface shows stale data
Solutions:
- Check WebSocket connections
- Verify update intervals
- Check browser console for errors
- Restart web interface
API Endpoint Errors
Symptoms: 404/500 errors from API calls
Solutions:
- Verify endpoint URLs
- Check server status
- Review API documentation
- Check authentication headers