From bc5489289efd99e8d8010e256e24937e79619591 Mon Sep 17 00:00:00 2001 From: Noran-Salm Date: Mon, 27 Jul 2026 03:18:04 +0300 Subject: [PATCH] Initial commit --- .gitignore | 4 + README.md | 0 common-mortakaz/integration-1.md | 0 common-mortakaz/integration-2.md | 0 common-qabilah/qabilah-profile.txt | 0 q1-deploy-monitor/Dockerfile | 16 ++ q1-deploy-monitor/app.py | 38 ++++ q1-deploy-monitor/dashboard.html | 293 ++++++++++++++++++++++++++++ q1-deploy-monitor/health-check.sh | 38 ++++ q1-deploy-monitor/requirements.txt | 1 + q1-deploy-monitor/update_monitor.py | 31 +++ q2-postmortem/postmortem-report.md | 0 q3-cicd/workflow.yml | 0 q4-scalability/architecture.png | 0 q4-scalability/calculations.md | 0 q5-mithal-monitor/dashboard.html | 0 q5-mithal-monitor/monitor.py | 0 17 files changed, 421 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 common-mortakaz/integration-1.md create mode 100644 common-mortakaz/integration-2.md create mode 100644 common-qabilah/qabilah-profile.txt create mode 100644 q1-deploy-monitor/Dockerfile create mode 100644 q1-deploy-monitor/app.py create mode 100644 q1-deploy-monitor/dashboard.html create mode 100644 q1-deploy-monitor/health-check.sh create mode 100644 q1-deploy-monitor/requirements.txt create mode 100644 q1-deploy-monitor/update_monitor.py create mode 100644 q2-postmortem/postmortem-report.md create mode 100644 q3-cicd/workflow.yml create mode 100644 q4-scalability/architecture.png create mode 100644 q4-scalability/calculations.md create mode 100644 q5-mithal-monitor/dashboard.html create mode 100644 q5-mithal-monitor/monitor.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c787019 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.venv/ +__pycache__/ +*.pyc +monitoring-data.json \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/common-mortakaz/integration-1.md b/common-mortakaz/integration-1.md new file mode 100644 index 0000000..e69de29 diff --git a/common-mortakaz/integration-2.md b/common-mortakaz/integration-2.md new file mode 100644 index 0000000..e69de29 diff --git a/common-qabilah/qabilah-profile.txt b/common-qabilah/qabilah-profile.txt new file mode 100644 index 0000000..e69de29 diff --git a/q1-deploy-monitor/Dockerfile b/q1-deploy-monitor/Dockerfile new file mode 100644 index 0000000..a67ee7a --- /dev/null +++ b/q1-deploy-monitor/Dockerfile @@ -0,0 +1,16 @@ +FROM python:3.11-slim + +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONUNBUFFERED=1 + +WORKDIR /app + +COPY requirements.txt . + +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +EXPOSE 5000 + +CMD ["python", "app.py"] \ No newline at end of file diff --git a/q1-deploy-monitor/app.py b/q1-deploy-monitor/app.py new file mode 100644 index 0000000..265475f --- /dev/null +++ b/q1-deploy-monitor/app.py @@ -0,0 +1,38 @@ +from flask import Flask, jsonify +import time + +app = Flask(__name__) + +request_count = 0 +start_time = time.time() + + +@app.route("/") +def home(): + global request_count + request_count += 1 + return jsonify({ + "message": "Hello from Ghaymah!", + "timestamp": time.time() + }) + + +@app.route("/health") +def health(): + global request_count + request_count += 1 + return jsonify({ + "status": "healthy" + }) + + +@app.route("/metrics") +def metrics(): + return jsonify({ + "request_count": request_count, + "uptime": round(time.time() - start_time, 2) + }) + + +if __name__ == "__main__": + app.run(host="0.0.0.0", port=5000) \ No newline at end of file diff --git a/q1-deploy-monitor/dashboard.html b/q1-deploy-monitor/dashboard.html new file mode 100644 index 0000000..9ab6cb0 --- /dev/null +++ b/q1-deploy-monitor/dashboard.html @@ -0,0 +1,293 @@ + + + + + + API Monitoring Dashboard + + + + + +
+

πŸ“Š API Monitoring Dashboard

+ + +
+
+
Uptime (24h)
+
--
+
+
+
Current Status
+
--
+
+
+
Last Latency
+
--
+
milliseconds
+
+
+
Total Requests
+
--
+
+
+ + +
+ +
+ + +
+

Recent Checks (last 10)

+ + + + + + + + + + + + +
TimestampStatusLatency (ms)Request Count
Loading data…
+
+
+ + + + \ No newline at end of file diff --git a/q1-deploy-monitor/health-check.sh b/q1-deploy-monitor/health-check.sh new file mode 100644 index 0000000..b2331a3 --- /dev/null +++ b/q1-deploy-monitor/health-check.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +URL="http://localhost:5000" + +REQUESTS=0 + +while true +do + REQUESTS=$((REQUESTS+1)) + + RESPONSE=$(curl -o /dev/null -s -w "%{http_code} %{time_total}" "$URL/health") + + STATUS_CODE=$(echo "$RESPONSE" | cut -d' ' -f1) + RESPONSE_TIME=$(echo "$RESPONSE" | cut -d' ' -f2) + + if [ "$STATUS_CODE" = "200" ] + then + STATUS="UP" + else + STATUS="DOWN" + fi + + TIMESTAMP=$(date -Iseconds) + LATENCY_MS=$(awk "BEGIN {print $RESPONSE_TIME * 1000}") + + python update_monitor.py \ + "$TIMESTAMP" \ + "$(echo $STATUS | tr '[:upper:]' '[:lower:]')" \ + "$LATENCY_MS" \ + "$REQUESTS" + + echo "Status : $STATUS" + echo "Latency : ${LATENCY_MS} ms" + echo "Requests : $REQUESTS" + echo "-------------------------" + + sleep 30 +done \ No newline at end of file diff --git a/q1-deploy-monitor/requirements.txt b/q1-deploy-monitor/requirements.txt new file mode 100644 index 0000000..cc35792 --- /dev/null +++ b/q1-deploy-monitor/requirements.txt @@ -0,0 +1 @@ +Flask==2.3.3 \ No newline at end of file diff --git a/q1-deploy-monitor/update_monitor.py b/q1-deploy-monitor/update_monitor.py new file mode 100644 index 0000000..80db841 --- /dev/null +++ b/q1-deploy-monitor/update_monitor.py @@ -0,0 +1,31 @@ +import json +import os +import sys + +FILE = "monitoring-data.json" +MAX_ENTRIES = 100 + +entry = { + "timestamp": sys.argv[1], + "status": sys.argv[2], + "latency": float(sys.argv[3]), + "request_count": int(sys.argv[4]) +} + +if os.path.exists(FILE): + try: + with open(FILE, "r") as f: + data = json.load(f) + if not isinstance(data, list): + data = [] + except Exception: + data = [] +else: + data = [] + +data.append(entry) + +data = data[-MAX_ENTRIES:] + +with open(FILE, "w") as f: + json.dump(data, f, indent=2) \ No newline at end of file diff --git a/q2-postmortem/postmortem-report.md b/q2-postmortem/postmortem-report.md new file mode 100644 index 0000000..e69de29 diff --git a/q3-cicd/workflow.yml b/q3-cicd/workflow.yml new file mode 100644 index 0000000..e69de29 diff --git a/q4-scalability/architecture.png b/q4-scalability/architecture.png new file mode 100644 index 0000000..e69de29 diff --git a/q4-scalability/calculations.md b/q4-scalability/calculations.md new file mode 100644 index 0000000..e69de29 diff --git a/q5-mithal-monitor/dashboard.html b/q5-mithal-monitor/dashboard.html new file mode 100644 index 0000000..e69de29 diff --git a/q5-mithal-monitor/monitor.py b/q5-mithal-monitor/monitor.py new file mode 100644 index 0000000..e69de29