Website Monitoring Tool
A Python-based website monitoring tool that periodically checks the availability and content of specified websites, logging detailed structured JSON logs and console output.
Features
- Periodic checks of multiple URLs with user-defined intervals.
- Validates HTTP response status codes.
- Verifies presence of expected content in the response.
- Handles and logs connection errors, timeouts, and HTTP errors.
- Structured logging to console and JSON file with rich metadata.
- Configurable via YAML file.
Project Structure
Project Structure
├── ashar_website_monitor/
│ ├── config/
│ │ └── config.yaml # User input config for URLs and checking period
│ ├── logs/
│ │ └── monitoring_logs.json # JSON log output
│ ├── src/
│ │ ├── logger_config.py # Custom logger setup with JSON formatter
│ │ ├── monitor.py # Monitor class to run periodic checks
│ │ └── website.py # Website class to handle individual site checks
│ ├── __init__.py
│ ├── main.py # Main script to load config and start monitoring
├── tests/
│ ├── test_website.py # Unit tests for Website class
│ └── test_monitor.py # Unit tests for Monitor class
├── .gitignore # Git ignore file
├── pyproject.toml # Pip package setup file
├── requirements.txt # Package requrements
└── README.md # This documentation
---
## Configuration
Create a YAML config file specifying the checking period and URLs to monitor.
Example `config/config.yaml`:
```yaml
checking_period: 7
urls:
- url: "https://www.google.com/"
expected_content: "Google"
- url: "https://www.facebook.com/"
expected_content: "ok pk hello bye"
- url: "https://httpbin.org/status/404"
expected_content: "hello world"
- url: "http://thisdomaindoesnotexist1234567890.com"
expected_content: "anything"
- url: "https://httpbin.org/delay/10"
expected_content: "Delayed"
- url: "htp://invalid-url.com"
expected_content: "test"
- url: "https://httpbin.org/status/500"
expected_content: "internal"
Usage
Pre requisites
- Python 3.7+
- Install dependencies:
pip install -r requirements.txt
Run the monitor
python main.py --config config/config.yaml
Testing
Run all tests with:
PYTHONPATH=./ashar_website_monitor pytest -v tests/
Logging
Logs structured JSON entries containing:
- asctime (timestamp)
- url
- status_code
- response_time
- levelname
- error_type
- message
Logs are written both to console (plain text) and JSON file.
Metadata
Release files for ashar-website-monitor 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ashar_website_monitor-0.1.0.tar.gz | 3.8 kB | Without provenance | Details for ashar_website_monitor-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ashar_website_monitor-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for ashar_website_monitor-0.1.0-py3-none-any.whl |
Total release size: 7.4 kB
Release files / ashar_website_monitor-0.1.0.tar.gz
| Download URL | ashar_website_monitor-0.1.0.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
14e0eff9ddb9ede676613f047f782f33c0ec7b25ea710f0e1efcf58beb8b6f28
|
|
BLAKE2b-256 checksum How to use checksums |
57a722e65e6861c7f48263c6bbf4c757ef330f05c3b77c0bf6e4e55b10280d5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Release files / ashar_website_monitor-0.1.0-py3-none-any.whl
| Download URL | ashar_website_monitor-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3c1c1c7d0061d3be7952f9b46a4180b57ba90963684e7146942c7d0710994d2d
|
|
BLAKE2b-256 checksum How to use checksums |
018d958e1c2951d1d2e471940a06c338626c344236d41d4a2a18125e9bad8915
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Security for ashar-website-monitor 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.