Files
qbitcheck/main.py
2025-11-21 13:38:02 -08:00

64 lines
2.0 KiB
Python

#!/usr/bin/env python3
"""
Main entry point for qBittorrent connection monitoring
"""
import platform
import socket
import logging
import requests
from config.logging_config import setup_logging, configure_third_party_logging
from monitoring.connection_monitor import ConnectionMonitor
def debug_system_info(logger):
"""
Log system and environment information for troubleshooting
Args:
logger: Configured logger instance
"""
logger.info("System Diagnostic Information:")
logger.info(f"Python Version: {platform.python_version()}")
logger.info(f"Operating System: {platform.platform()}")
logger.info(f"Hostname: {socket.gethostname()}")
# Network connectivity check
try:
response = requests.get('https://www.google.com', timeout=5)
logger.info(f"Internet Connectivity: OK (Status Code: {response.status_code})")
except Exception as e:
logger.warning(f"Internet Connectivity Check Failed: {e}")
def main():
"""
Main entry point for the connection monitoring script
"""
# Configure logging
logger = setup_logging(__name__)
# Run system diagnostics
debug_system_info(logger)
# Configure third-party logging
configure_third_party_logging()
# Create monitor instance with custom parameters
monitor = ConnectionMonitor(
qbittorrent_url='http://sp.service.dc1.consul:8080', # Customize as needed
nomad_url='http://192.168.4.36:4646', # Customize as needed
tracker_name='https://t.myanonamouse.net/tracker.php/VPRYYAL-WpTwnr9G9aIN6044YVZ7x8Ao/announce', # Customize tracker name
consul_url='http://consul.service.dc1.consul:8500', # Consul server URL
logger=logger # Pass the configured logger
)
try:
# Start connection monitoring
monitor.monitor_connection()
except Exception as e:
logger.critical(f"Critical error in main execution: {e}")
raise
if __name__ == '__main__':
main()