A Python script for monitoring multiple website domains in real-time, displaying whether they are accessible (“up”) or unreachable (“down”). It also logs these status checks to a file (website_monitor.log
). This tool runs until the user presses ENTER, allowing continuous website monitoring.
- Multi-Domain Monitoring: Checks multiple domains (entered by the user) in one script run.
- Real-Time Checking: Monitors each domain’s status every 1 second.
- Immediate Stop: Press ENTER at any time to halt the continuous check loop.
- Colorful Output: Uses the Pystyle library for styled console printing (e.g., banners, color-coded text).
- Logging: Records each check result (e.g., “up”, “down”, errors) in
website_monitor.log
.
-
User Input:
- The script prompts you to input one or more domains (separated by commas).
-
Background Thread:
- A separate “stopper” thread waits for the user to press ENTER.
- Once pressed, it sets a
stop_flag
toTrue
, signalling the monitoring loop to stop.
-
Monitoring Loop:
- Repeatedly sends
GET
requests (viarequests.get()
) to each domain every 1 second. - If a domain returns an HTTP status code of 200, it prints
"[+] <domain> is up"
. - If the HTTP code is not 200 or an exception occurs, it prints and logs a message indicating the site is down or inaccessible.
- Continues indefinitely until ENTER is pressed.
- Repeatedly sends
-
Logging:
- Saves each status check (timestamped) to
website_monitor.log
using the Pythonlogging
module.
- Saves each status check (timestamped) to
-
System Requirements:
- Python 3.6+ recommended.
- OS compatibility: The script should work on any OS (Windows, macOS, Linux) as long as
pystyle
supports it.
-
Python Libraries:
-
Install Required Libraries:
pip install requests pystyle
-
Clone or Copy the script (e.g.,
down_detector.py
) to your local machine. -
Run the Script
-
Input Domains:
- When prompted, enter one or more domain names separated by commas (e.g.,
https://example.com, https://anotherdomain.com
).
- When prompted, enter one or more domain names separated by commas (e.g.,
-
Monitoring:
- The script will check each domain in a loop every 1 second.
- It will display whether each domain is up or down in the console.
-
Stop Monitoring:
- At any time, press ENTER in the console window.
- The script will exit the loop and print “Monitoring stopped.”
-
Check Interval:
- Currently hard-coded to 1 second (
time.sleep(1)
in themonitor_websites()
function). - Adjust as needed for heavier or lighter monitoring frequencies.
- Currently hard-coded to 1 second (
-
Logging Setup:
-
Logging is configured in the
main()
function with:logging.basicConfig( filename='website_monitor.log', level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s' )
-
Modify
filename
,level
, orformat
as desired.
-
-
Heavy Logging:
- Checking every second and logging each result can quickly grow
website_monitor.log
. - Consider rotating logs or adjusting the check interval.
- Checking every second and logging each result can quickly grow
-
No HTTPS Verification Settings:
- Currently, SSL verification is not altered. If you require special SSL certificates or want to disable verification, you must adjust the
requests.get()
parameters.
- Currently, SSL verification is not altered. If you require special SSL certificates or want to disable verification, you must adjust the
-
Script Running Indefinitely:
- The script only stops when ENTER is pressed, so it’s not suitable for use in a purely headless environment (unless you modify the code).
-
Connectivity Issues:
- A domain returning a non-200 code is flagged as “down,” but the domain may actually be reachable with a different status code. Modify as needed if your use case differs (e.g., for APIs returning 201, 204, etc.).
-
Pressing ENTER Doesn’t Stop:
- In some shells or IDEs, the input buffering behavior might vary. Ensure you are running the script in a standard terminal or console.
-
Logging Not Working:
- Check that you have write permissions to the directory where the script runs.
- Verify the
logging
level and filepath inlogging.basicConfig
.
-
ImportError for
pystyle
:- Make sure you installed the library with
pip install pystyle
. - If installed globally, confirm your Python interpreter in the environment can see it.
- Make sure you installed the library with
Author:
🛡️ By Joshua M Clatney - Ethical Pentesting Enthusiast 🛡️
Version: 1.00
Disclaimer: This script is provided as-is for basic website monitoring. Please adapt configurations (e.g. interval, logging verbosity) to your own requirements.
Copyright 2025 Joshua M Clatney (Clats97)