adjusted parser to enable dry mode
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
import os, sys, json, requests, psutil, socket, subprocess, logging
|
||||
import os, sys, json, requests, psutil, socket, subprocess, logging, argparse, urllib.request
|
||||
from typing import Dict, Any, List
|
||||
|
||||
# Create a logger
|
||||
@ -126,7 +126,7 @@ class SystemHealthMonitor:
|
||||
"""
|
||||
issues = self._detect_issues(health_report)
|
||||
if not issues:
|
||||
print("No issues detected.")
|
||||
logger.info("No issues detected.")
|
||||
return
|
||||
|
||||
hostname = socket.gethostname() # Get the current hostname
|
||||
@ -384,19 +384,25 @@ def main():
|
||||
# Run the health checks
|
||||
monitor.run()
|
||||
|
||||
# Check network health asynchronously
|
||||
network_health = asyncio.run(monitor._check_network_status())
|
||||
print(f"Network health: {network_health}")
|
||||
|
||||
except KeyboardInterrupt:
|
||||
# Handle KeyboardInterrupt gracefully
|
||||
print("Interrupted by user. Exiting...")
|
||||
sys.exit(0)
|
||||
# Check network health synchronously
|
||||
network_health = monitor._check_network_status()
|
||||
logger.info(f"Network health: {network_health}")
|
||||
|
||||
except Exception as e:
|
||||
# Handle other exceptions
|
||||
print(f"An unexpected error occurred: {e}")
|
||||
logger.error(f"An unexpected error occurred: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Argument parser for CLI options
|
||||
parser = argparse.ArgumentParser(description="System Health Monitor")
|
||||
parser.add_argument(
|
||||
"--dry-run",
|
||||
action="store_true",
|
||||
help="Enable dry-run mode (simulate ticket creation without actual API calls)."
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
# Set dry-run mode if specified
|
||||
dry_run_mode = args.dry_run
|
||||
|
||||
main()
|
||||
Reference in New Issue
Block a user