Media Services Backup Monitoring #4

Open
opened 2025-10-29 19:44:54 -07:00 by peterwood · 0 comments
Owner

Originally created by @acedanger on GitHub (May 27, 2025).

Media Services Backup Monitoring Integration

Issue Summary

Integrate the Telegram bot with the enhanced media services backup system to monitor and report on backup status for 7 different Docker-based media applications (Sonarr, Radarr, Prowlarr, Audiobookshelf, Tautulli, SABnzbd, Jellyseerr).

Description

Develop Telegram bot commands that interface with the enhanced media backup script to provide monitoring and status reporting for all media services. The system supports parallel execution, verification, performance monitoring, and comprehensive logging.

Requirements

Command Implementation

  • /media_status - Show overall media backup status
  • /media_last - Display last backup summary for all services
  • /media_service <name> - Show status for specific service
  • /media_performance - Display performance metrics and trends
  • /media_logs - Show recent backup activity
  • /media_health - Run health check on all services
  • /media_list - List all monitored services

Advanced Commands (Admin only)

  • /media_backup_now - Trigger immediate backup (all services)
  • /media_backup_service <name> - Backup specific service
  • /media_verify - Run backup verification
  • /media_cleanup - Execute cleanup operations

Integration Points

Existing Scripts to Interface With

# Enhanced media backup script with comprehensive features
/home/acedanger/shell/backup-media.sh

Log Files to Monitor

# JSON performance logs
/home/acedanger/shell/logs/media-backup.json

# Plain text logs
/mnt/share/media/backups/logs/backup_log_*.md

# Backup log monitoring
/home/acedanger/shell/backup-log-monitor.sh

Monitored Services

# 7 media services with their backup locations:
1. Sonarr       -> /config/Backups/scheduled
2. Radarr       -> /config/Backups/scheduled
3. Prowlarr     -> /config/Backups/scheduled
4. Audiobookshelf -> /metadata/backups
5. Tautulli     -> /config/backups
6. SABnzbd      -> /config/sabnzbd.ini
7. Jellyseerr   -> /app/config/db/db.sqlite3

Technical Implementation

Overall Status Monitoring

def get_media_status():
    """Parse JSON logs to determine media backup status"""
    # Read latest performance JSON
    # Check completion status for all services
    # Return comprehensive status overview

def get_last_media_backup():
    """Get summary of most recent backup run"""
    # Parse latest JSON log entry
    # Extract metrics for each service
    # Calculate totals and averages
    # Format for Telegram display

Service-Specific Monitoring

def get_service_status(service_name):
    """Get detailed status for specific service"""
    # Validate service name
    # Extract service-specific data from logs
    # Check backup freshness and integrity
    # Return detailed service information

def list_media_services():
    """Return list of all monitored services"""
    # Return configured service list
    # Include status indicators
    # Show last backup times

Performance Analysis

def get_media_performance():
    """Extract performance metrics from JSON logs"""
    # Parse performance data over time
    # Calculate trends and averages
    # Identify performance issues
    # Return formatted metrics

Health Monitoring

def run_media_health_check():
    """Execute health check across all services"""
    # Check backup freshness for each service
    # Verify backup file integrity
    # Check disk space and capacity
    # Return health assessment

Command Examples

/media_status

🎬 Media Services Backup Status

Overall Status: ✅ 7/7 Services Healthy

Last Backup Run: 2025-05-27 03:00:15
Duration: 4m 32s (Parallel Mode)
Total Size: 2.4 GB

Services Status:
├── ✅ Sonarr (47 files, 124 MB)
├── ✅ Radarr (52 files, 156 MB)
├── ✅ Prowlarr (12 files, 34 MB)
├── ✅ Audiobookshelf (234 files, 1.2 GB)
├── ✅ Tautulli (89 files, 245 MB)
├── ✅ SABnzbd (1 file, 12 KB)
└── ✅ Jellyseerr (1 file, 8.4 MB)

Next Scheduled: 2025-05-28 03:00:00

/media_service sonarr

📺 Sonarr Backup Details

Status: ✅ Healthy
Last Backup: 2025-05-27 03:01:22
Duration: 45 seconds

Backup Details:
├── Files: 47 backup files
├── Size: 124 MB
├── Location: /mnt/share/media/backups/sonarr/
└── Verification: ✅ Passed

Container Status:
├── Running: ✅ Yes
├── Health: ✅ Healthy
└── Last Activity: 15 minutes ago

Backup History (7 days):
├── Success Rate: 100%
├── Avg Duration: 43s (±5s)
├── Avg Size: 122 MB (±8 MB)
└── Trend: ✅ Stable

/media_performance

📊 Media Backup Performance

Recent Performance (7 days):
├── Avg Duration: 4m 28s (±45s)
├── Avg Total Size: 2.3 GB (±0.2 GB)
├── Success Rate: 100%
└── Mode: Parallel (4x faster)

Service Performance:
├── Fastest: SABnzbd (2s avg)
├── Slowest: Audiobookshelf (2m 15s avg)
├── Largest: Audiobookshelf (1.2 GB avg)
└── Most Files: Tautulli (89 files avg)

Trends:
📈 Total backup size growing slowly
⚡ Performance stable
🔄 Parallel mode optimal
✅ No bottlenecks detected

/media_health

🔍 Media Services Health Check

Overall Health: ✅ EXCELLENT

Service Health:
├── ✅ Sonarr (Fresh: 4h ago)
├── ✅ Radarr (Fresh: 4h ago)
├── ✅ Prowlarr (Fresh: 4h ago)
├── ✅ Audiobookshelf (Fresh: 4h ago)
├── ✅ Tautulli (Fresh: 4h ago)
├── ✅ SABnzbd (Fresh: 4h ago)
└── ✅ Jellyseerr (Fresh: 4h ago)

System Health:
├── Storage Space: ✅ 67% available
├── Container Status: ✅ All running
├── Backup Integrity: ✅ All verified
└── Schedule Status: ✅ On track

Issues: None detected
Recommendations: All systems optimal

/media_list

📋 Monitored Media Services

🎬 Media Management:
├── 📺 Sonarr (TV Shows)
├── 🎥 Radarr (Movies)
└── 🔍 Prowlarr (Indexers)

📚 Content & Stats:
├── 📖 Audiobookshelf (Audiobooks)
├── 📊 Tautulli (Plex Statistics)
└── 🎭 Jellyseerr (Requests)

⬇️ Downloads:
└── 📦 SABnzbd (Usenet Client)

Total: 7 services monitored
Status: ✅ All operational
Last Check: 15 minutes ago

File Structure

telegram/bot/commands/
├── media/
│   ├── __init__.py
│   ├── status.py           # Overall status commands
│   ├── services.py         # Individual service commands
│   ├── performance.py      # Performance monitoring
│   ├── health.py           # Health check commands
│   └── control.py          # Backup control commands (admin)
└── utils/
    ├── media_parser.py     # JSON log parsing utilities
    ├── docker_utils.py     # Docker container utilities
    └── service_config.py   # Service configuration mapping

Service Configuration

MEDIA_SERVICES = {
    'sonarr': {
        'name': 'Sonarr',
        'emoji': '📺',
        'description': 'TV Shows',
        'container': 'sonarr',
        'backup_path': '/config/Backups/scheduled'
    },
    'radarr': {
        'name': 'Radarr',
        'emoji': '🎥',
        'description': 'Movies',
        'container': 'radarr',
        'backup_path': '/config/Backups/scheduled'
    },
    # ... additional services
}

Performance Features

  • Support for both parallel and sequential backup modes
  • Performance trend analysis over time
  • Backup size and duration tracking
  • Success rate monitoring
  • Bottleneck identification

Security Considerations

  • Container access validation
  • Safe script execution
  • Admin-only backup triggers
  • Input validation for service names

Success Criteria

  • Overall status monitoring functional
  • Individual service monitoring working
  • Performance metrics accurate
  • Health checks comprehensive
  • JSON log parsing complete
  • Service-specific details available

Dependencies

  • Depends on: Issue #01 (Core Infrastructure)
  • Docker API access for container status
  • JSON parsing capabilities
  • File system monitoring utilities

Estimated Effort

Time: 2-3 days
Complexity: Medium

Testing Requirements

  • Test with all 7 services running
  • Test with some services down
  • Verify performance calculation accuracy
  • Test parallel vs sequential mode detection
  • Validate service-specific command parsing
  • Test error handling for missing containers

Notes

The media backup system handles the most services (7) and has robust parallel processing capabilities. The integration should highlight the efficiency of parallel backups and provide detailed per-service monitoring while maintaining an overview of the entire media stack.

Originally created by @acedanger on GitHub (May 27, 2025). # Media Services Backup Monitoring Integration ## Issue Summary Integrate the Telegram bot with the enhanced media services backup system to monitor and report on backup status for 7 different Docker-based media applications (Sonarr, Radarr, Prowlarr, Audiobookshelf, Tautulli, SABnzbd, Jellyseerr). ## Description Develop Telegram bot commands that interface with the enhanced media backup script to provide monitoring and status reporting for all media services. The system supports parallel execution, verification, performance monitoring, and comprehensive logging. ## Requirements ### Command Implementation - [ ] `/media_status` - Show overall media backup status - [ ] `/media_last` - Display last backup summary for all services - [ ] `/media_service <name>` - Show status for specific service - [ ] `/media_performance` - Display performance metrics and trends - [ ] `/media_logs` - Show recent backup activity - [ ] `/media_health` - Run health check on all services - [ ] `/media_list` - List all monitored services ### Advanced Commands (Admin only) - [ ] `/media_backup_now` - Trigger immediate backup (all services) - [ ] `/media_backup_service <name>` - Backup specific service - [ ] `/media_verify` - Run backup verification - [ ] `/media_cleanup` - Execute cleanup operations ### Integration Points #### Existing Scripts to Interface With ```bash # Enhanced media backup script with comprehensive features /home/acedanger/shell/backup-media.sh ``` #### Log Files to Monitor ```bash # JSON performance logs /home/acedanger/shell/logs/media-backup.json # Plain text logs /mnt/share/media/backups/logs/backup_log_*.md # Backup log monitoring /home/acedanger/shell/backup-log-monitor.sh ``` #### Monitored Services ```bash # 7 media services with their backup locations: 1. Sonarr -> /config/Backups/scheduled 2. Radarr -> /config/Backups/scheduled 3. Prowlarr -> /config/Backups/scheduled 4. Audiobookshelf -> /metadata/backups 5. Tautulli -> /config/backups 6. SABnzbd -> /config/sabnzbd.ini 7. Jellyseerr -> /app/config/db/db.sqlite3 ``` ### Technical Implementation #### Overall Status Monitoring ```python def get_media_status(): """Parse JSON logs to determine media backup status""" # Read latest performance JSON # Check completion status for all services # Return comprehensive status overview def get_last_media_backup(): """Get summary of most recent backup run""" # Parse latest JSON log entry # Extract metrics for each service # Calculate totals and averages # Format for Telegram display ``` #### Service-Specific Monitoring ```python def get_service_status(service_name): """Get detailed status for specific service""" # Validate service name # Extract service-specific data from logs # Check backup freshness and integrity # Return detailed service information def list_media_services(): """Return list of all monitored services""" # Return configured service list # Include status indicators # Show last backup times ``` #### Performance Analysis ```python def get_media_performance(): """Extract performance metrics from JSON logs""" # Parse performance data over time # Calculate trends and averages # Identify performance issues # Return formatted metrics ``` #### Health Monitoring ```python def run_media_health_check(): """Execute health check across all services""" # Check backup freshness for each service # Verify backup file integrity # Check disk space and capacity # Return health assessment ``` ### Command Examples #### `/media_status` ``` 🎬 Media Services Backup Status Overall Status: ✅ 7/7 Services Healthy Last Backup Run: 2025-05-27 03:00:15 Duration: 4m 32s (Parallel Mode) Total Size: 2.4 GB Services Status: ├── ✅ Sonarr (47 files, 124 MB) ├── ✅ Radarr (52 files, 156 MB) ├── ✅ Prowlarr (12 files, 34 MB) ├── ✅ Audiobookshelf (234 files, 1.2 GB) ├── ✅ Tautulli (89 files, 245 MB) ├── ✅ SABnzbd (1 file, 12 KB) └── ✅ Jellyseerr (1 file, 8.4 MB) Next Scheduled: 2025-05-28 03:00:00 ``` #### `/media_service sonarr` ``` 📺 Sonarr Backup Details Status: ✅ Healthy Last Backup: 2025-05-27 03:01:22 Duration: 45 seconds Backup Details: ├── Files: 47 backup files ├── Size: 124 MB ├── Location: /mnt/share/media/backups/sonarr/ └── Verification: ✅ Passed Container Status: ├── Running: ✅ Yes ├── Health: ✅ Healthy └── Last Activity: 15 minutes ago Backup History (7 days): ├── Success Rate: 100% ├── Avg Duration: 43s (±5s) ├── Avg Size: 122 MB (±8 MB) └── Trend: ✅ Stable ``` #### `/media_performance` ``` 📊 Media Backup Performance Recent Performance (7 days): ├── Avg Duration: 4m 28s (±45s) ├── Avg Total Size: 2.3 GB (±0.2 GB) ├── Success Rate: 100% └── Mode: Parallel (4x faster) Service Performance: ├── Fastest: SABnzbd (2s avg) ├── Slowest: Audiobookshelf (2m 15s avg) ├── Largest: Audiobookshelf (1.2 GB avg) └── Most Files: Tautulli (89 files avg) Trends: 📈 Total backup size growing slowly ⚡ Performance stable 🔄 Parallel mode optimal ✅ No bottlenecks detected ``` #### `/media_health` ``` 🔍 Media Services Health Check Overall Health: ✅ EXCELLENT Service Health: ├── ✅ Sonarr (Fresh: 4h ago) ├── ✅ Radarr (Fresh: 4h ago) ├── ✅ Prowlarr (Fresh: 4h ago) ├── ✅ Audiobookshelf (Fresh: 4h ago) ├── ✅ Tautulli (Fresh: 4h ago) ├── ✅ SABnzbd (Fresh: 4h ago) └── ✅ Jellyseerr (Fresh: 4h ago) System Health: ├── Storage Space: ✅ 67% available ├── Container Status: ✅ All running ├── Backup Integrity: ✅ All verified └── Schedule Status: ✅ On track Issues: None detected Recommendations: All systems optimal ``` #### `/media_list` ``` 📋 Monitored Media Services 🎬 Media Management: ├── 📺 Sonarr (TV Shows) ├── 🎥 Radarr (Movies) └── 🔍 Prowlarr (Indexers) 📚 Content & Stats: ├── 📖 Audiobookshelf (Audiobooks) ├── 📊 Tautulli (Plex Statistics) └── 🎭 Jellyseerr (Requests) ⬇️ Downloads: └── 📦 SABnzbd (Usenet Client) Total: 7 services monitored Status: ✅ All operational Last Check: 15 minutes ago ``` ### File Structure ``` telegram/bot/commands/ ├── media/ │ ├── __init__.py │ ├── status.py # Overall status commands │ ├── services.py # Individual service commands │ ├── performance.py # Performance monitoring │ ├── health.py # Health check commands │ └── control.py # Backup control commands (admin) └── utils/ ├── media_parser.py # JSON log parsing utilities ├── docker_utils.py # Docker container utilities └── service_config.py # Service configuration mapping ``` ### Service Configuration ```python MEDIA_SERVICES = { 'sonarr': { 'name': 'Sonarr', 'emoji': '📺', 'description': 'TV Shows', 'container': 'sonarr', 'backup_path': '/config/Backups/scheduled' }, 'radarr': { 'name': 'Radarr', 'emoji': '🎥', 'description': 'Movies', 'container': 'radarr', 'backup_path': '/config/Backups/scheduled' }, # ... additional services } ``` ### Performance Features - Support for both parallel and sequential backup modes - Performance trend analysis over time - Backup size and duration tracking - Success rate monitoring - Bottleneck identification ### Security Considerations - Container access validation - Safe script execution - Admin-only backup triggers - Input validation for service names ### Success Criteria - [ ] Overall status monitoring functional - [ ] Individual service monitoring working - [ ] Performance metrics accurate - [ ] Health checks comprehensive - [ ] JSON log parsing complete - [ ] Service-specific details available ## Dependencies - Depends on: Issue #01 (Core Infrastructure) - Docker API access for container status - JSON parsing capabilities - File system monitoring utilities ## Estimated Effort **Time**: 2-3 days **Complexity**: Medium ## Testing Requirements - [ ] Test with all 7 services running - [ ] Test with some services down - [ ] Verify performance calculation accuracy - [ ] Test parallel vs sequential mode detection - [ ] Validate service-specific command parsing - [ ] Test error handling for missing containers ## Notes The media backup system handles the most services (7) and has robust parallel processing capabilities. The integration should highlight the efficiency of parallel backups and provide detailed per-service monitoring while maintaining an overview of the entire media stack.
peterwood added the enhancement label 2025-10-29 19:44:54 -07:00
Sign in to join this conversation.