https://github.com/octonawish-akcodes/application-health-checkup
Python script to monitor web application uptime and health based on HTTP status codes.
https://github.com/octonawish-akcodes/application-health-checkup
Last synced: 2 months ago
JSON representation
Python script to monitor web application uptime and health based on HTTP status codes.
- Host: GitHub
- URL: https://github.com/octonawish-akcodes/application-health-checkup
- Owner: octonawish-akcodes
- Created: 2024-08-06T04:58:31.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-08-06T05:05:37.000Z (10 months ago)
- Last Synced: 2025-03-28T01:59:54.724Z (2 months ago)
- Language: Python
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Application-Health-Checkup
**Purpose:**
This Python script is designed to monitor the uptime and health of a web application. It periodically checks the application's HTTP status code and reports whether it's 'up' (functioning correctly) or 'down' (unavailable or not responding).**How it works:**
1. Imports necessary libraries: `requests` for making HTTP requests and `time` for introducing delays between checks.
2. Defines a function `check_application_health`:
- Takes the application URL as input.
- Attempts to make a GET request to the URL with a timeout.
- Returns 'up' if the request is successful and the status code is 200.
- Returns 'down' if the request fails or the status code is not 200.
3. Defines the `main` function:
- Sets the application URL.
- Continuously checks the application health using `check_application_health`.
- Prints the status to the console.
- Sleeps for a specified interval before the next check.**Usage:**
1. Replace `"http://google.com"` with the actual URL of your application.
2. Adjust the `time.sleep(60)` value to change the check interval as needed.
3. Run the script `python3 app.py`.**Example Output:**
```
Application status: up
Application status: down
Application status: up
```