adjusted parser to enable dry mode
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/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
|
from typing import Dict, Any, List
|
||||||
|
|
||||||
# Create a logger
|
# Create a logger
|
||||||
@ -126,7 +126,7 @@ class SystemHealthMonitor:
|
|||||||
"""
|
"""
|
||||||
issues = self._detect_issues(health_report)
|
issues = self._detect_issues(health_report)
|
||||||
if not issues:
|
if not issues:
|
||||||
print("No issues detected.")
|
logger.info("No issues detected.")
|
||||||
return
|
return
|
||||||
|
|
||||||
hostname = socket.gethostname() # Get the current hostname
|
hostname = socket.gethostname() # Get the current hostname
|
||||||
@ -384,19 +384,25 @@ def main():
|
|||||||
# Run the health checks
|
# Run the health checks
|
||||||
monitor.run()
|
monitor.run()
|
||||||
|
|
||||||
# Check network health asynchronously
|
# Check network health synchronously
|
||||||
network_health = asyncio.run(monitor._check_network_status())
|
network_health = monitor._check_network_status()
|
||||||
print(f"Network health: {network_health}")
|
logger.info(f"Network health: {network_health}")
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
# Handle KeyboardInterrupt gracefully
|
|
||||||
print("Interrupted by user. Exiting...")
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Handle other exceptions
|
logger.error(f"An unexpected error occurred: {e}")
|
||||||
print(f"An unexpected error occurred: {e}")
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
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()
|
main()
|
||||||
Reference in New Issue
Block a user