Skip to content

elsonico/UrlMonitoring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL Monitoring System

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.

Features

  • 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

Prerequisites

  • Python 3.7+
  • PostgreSQL 12+

Installation

  1. Clone this repository:
git clone <repository-url>
cd url-monitoring
  1. Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Create a PostgreSQL database:
CREATE DATABASE url_monitor;
  1. Create a .env file 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
  1. Initialize the database schema:
psql -U your_username -d url_monitor -f schema.sql

Usage

Adding URLs to Monitor

Use the add_url.py script to add new URLs to monitor:

python add_url.py

Follow the prompts to enter:

  • URL to monitor
  • Name for the URL
  • Check interval in seconds

Running the Monitor

Start the URL monitoring service:

python url_monitor.py

The service will continuously monitor all configured URLs according to their specified intervals.

Database Schema

urls table

  • id: Serial primary key
  • url: The URL to monitor
  • name: A friendly name for the URL
  • check_interval: Interval between checks in seconds
  • created_at: Timestamp of creation
  • updated_at: Timestamp of last update

url_checks table

  • id: Serial primary key
  • url_id: Foreign key to urls table
  • status_code: HTTP status code
  • response_time: Response time in seconds
  • is_up: Boolean indicating if the URL is up
  • error_message: Error message if the check failed
  • checked_at: Timestamp of the check

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages