Uptime Monitor is a Rust-based application that periodically checks the status of a list of websites and logs the status to a SQLite database. It helps in monitoring the uptime of specified websites and records their status codes.
- Periodically checks the status of specified websites.
- Logs the status (up or down) and status code to a SQLite database.
- Handles errors and logs DNS errors specifically.
- Initializes the SQLite database with the necessary schema.
- Rust (latest stable version recommended)
- SQLite
git clone https://github.com/your-username/uptime_monitor.git
cd uptime_monitor
Ensure you have Rust and Cargo installed. If not, you can install them from here.
Run the init_db
script to set up the SQLite database.
cargo run --bin init_db
This will create a uptime_monitor.db
file with the necessary schema.
Execute the uptime_monitor
script to start monitoring the websites.
cargo run --bin uptime_monitor
Modify the urls
vector in src/main.rs
to include the websites you want to monitor.
let urls: Vec<&str> = vec![
"https://google.com",
"https://www.subinstha.com.np/",
"https://www.outcodesoftware.com/",
"https://asdasdasdasdasdasdasw2123.com",
];
The interval for checking the website status is set to 60 seconds by default. You can change this by modifying the Duration::from_secs(60)
value in src/main.rs
.
time::sleep(Duration::from_secs(60)).await;
src/main.rs
: The main script that performs the uptime monitoring and logging.src/init_db.rs
: The script to initialize the SQLite database.Cargo.toml
: The Cargo configuration file specifying dependencies and binary targets.
reqwest
: For making HTTP requests.tokio
: For asynchronous runtime.rusqlite
: For interacting with the SQLite database.
Happy Monitoring!