Adding README.md File
هذا الالتزام موجود في:
37
README .md
37
README .md
@@ -10,8 +10,8 @@ The project also includes **logging**, a **log monitoring script**, and **automa
|
|||||||
- Search fruits by name
|
- Search fruits by name
|
||||||
- Filter fruits by category
|
- Filter fruits by category
|
||||||
- Health check endpoint
|
- Health check endpoint
|
||||||
- Logging of all requests & responses to `api.log`
|
- Logging of all requests & responses to `fruit_api.log`
|
||||||
- Bash script for monitoring logs (`monitor.sh`)
|
- Bash script for monitoring logs (`log_monitor.sh`)
|
||||||
- Bash script for automated API testing (`test_api.sh`)
|
- Bash script for automated API testing (`test_api.sh`)
|
||||||
- Swagger/OpenAPI documentation
|
- Swagger/OpenAPI documentation
|
||||||
|
|
||||||
@@ -38,6 +38,10 @@ pip install -r requirements.txt
|
|||||||
```bash
|
```bash
|
||||||
python fruit_api.py
|
python fruit_api.py
|
||||||
```
|
```
|
||||||
|
or
|
||||||
|
```bash
|
||||||
|
python3 fruit_api.py
|
||||||
|
```
|
||||||
|
|
||||||
API will start at:
|
API will start at:
|
||||||
👉 `http://localhost:5000`
|
👉 `http://localhost:5000`
|
||||||
@@ -89,7 +93,7 @@ curl -X PUT http://localhost:5000/fruits/1 -H "Content-Type: application/js
|
|||||||
|
|
||||||
- All API requests and responses are saved in:
|
- All API requests and responses are saved in:
|
||||||
```
|
```
|
||||||
api.log
|
fruit_api.log
|
||||||
```
|
```
|
||||||
|
|
||||||
Example log:
|
Example log:
|
||||||
@@ -99,17 +103,17 @@ Example log:
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🔎 Monitoring (monitor.sh)
|
## 🔎 Monitoring (log_monitor.sh)
|
||||||
|
|
||||||
The `monitor.sh` script:
|
The `log_monitor.sh` script:
|
||||||
- Monitors `api.log` every 2 hours
|
- Monitors `fruit_api.log` every 2 hours
|
||||||
- Detects **errors (4XX, 5XX)** and unusual keywords (`failed`, `timeout`)
|
- Detects **errors (4XX, 5XX)** and unusual keywords (`failed`, `timeout`)
|
||||||
- Captures server metrics (IP, CPU, RAM, Disk)
|
- Captures server metrics (IP, CPU, RAM, Disk)
|
||||||
- Sends an **alert JSON** to Ghaymah endpoint
|
- Sends an **alert JSON** to Ghaymah endpoint
|
||||||
|
|
||||||
Run it in background:
|
Run it in background:
|
||||||
```bash
|
```bash
|
||||||
bash monitor.sh &
|
bash log_monitor.sh &
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -153,24 +157,9 @@ fruit-api/
|
|||||||
│── fruit_api.py # Main Flask API
|
│── fruit_api.py # Main Flask API
|
||||||
│── requirements.txt # Dependencies
|
│── requirements.txt # Dependencies
|
||||||
│── Dockerfile # Docker support
|
│── Dockerfile # Docker support
|
||||||
│── monitor.sh # Log monitoring script
|
│── log_monitor.sh # Log monitoring script
|
||||||
│── test_api.sh # Automated testing script
|
│── test_api.sh # Automated testing script
|
||||||
│── api.log # API logs
|
│── fruit_api.log # API logs
|
||||||
│── test_results.log # Test logs
|
|
||||||
│── README.md # Documentation
|
│── README.md # Documentation
|
||||||
│── .gitignore # Ignore venv/logs
|
│── .gitignore # Ignore venv/logs
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 📌 Submission Guidelines
|
|
||||||
- Push project to **GitPasha**: [https://app.gitpasha.com/](https://app.gitpasha.com/)
|
|
||||||
- Repository must include:
|
|
||||||
- API source code
|
|
||||||
- Bash scripts (`monitor.sh`, `test_api.sh`)
|
|
||||||
- Sample logs
|
|
||||||
- Documentation (`README.md`)
|
|
||||||
- Demo should include:
|
|
||||||
- Running the API
|
|
||||||
- Triggering errors
|
|
||||||
- Showing alerts in action
|
|
||||||
|
المرجع في مشكلة جديدة
حظر مستخدم