A Python-based URL monitoring system that checks the availability and performance of URLs at specified intervals and stores the results in a PostgreSQL database.
- Monitor multiple URLs with different check intervals
- Track response times, status codes, and availability
- Store historical monitoring data in PostgreSQL
- Easy-to-use command-line interface for adding new URLs
- Python 3.7+
- PostgreSQL 12+
- Clone this repository:
git clone <repository-url>
cd url-monitoring- Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Create a PostgreSQL database:
CREATE DATABASE url_monitor;- Create a
.envfile in the project root with your database credentials:
DB_NAME=url_monitor
DB_USER=your_username
DB_PASSWORD=your_password
DB_HOST=localhost
DB_PORT=5432
- Initialize the database schema:
psql -U your_username -d url_monitor -f schema.sqlUse the add_url.py script to add new URLs to monitor:
python add_url.pyFollow the prompts to enter:
- URL to monitor
- Name for the URL
- Check interval in seconds
Start the URL monitoring service:
python url_monitor.pyThe service will continuously monitor all configured URLs according to their specified intervals.
id: Serial primary keyurl: The URL to monitorname: A friendly name for the URLcheck_interval: Interval between checks in secondscreated_at: Timestamp of creationupdated_at: Timestamp of last update
id: Serial primary keyurl_id: Foreign key to urls tablestatus_code: HTTP status coderesponse_time: Response time in secondsis_up: Boolean indicating if the URL is uperror_message: Error message if the check failedchecked_at: Timestamp of the check
MIT License