هذا الالتزام موجود في:
2026-07-28 13:34:58 +03:00
التزام 1150963ef4
20 ملفات معدلة مع 674 إضافات و0 حذوفات

عرض الملف

@@ -0,0 +1,17 @@
{
"id": "159ccedb-4f26-447c-99e7-bcad1de22120",
"name": "q5-mithal-monitor",
"projectId": "27aacb50-4d56-474c-baae-b52a853b4d57",
"ports": [
{
"expose": true,
"number": 80
}
],
"publicAccess": {
"enabled": true,
"domain": "auto"
},
"resourceTier": "t1",
"dockerFileName": "Dockerfile"
}

عرض الملف

@@ -0,0 +1,34 @@
name: Ghaymah CI/CD Pipeline
on:
push:
branches: [ "master" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
deploy-production:
name: Deploy to Production
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Install Ghaymah CLI
run: curl -sSL https://cli.ghaymah.systems/install.sh | bash
- name: Login to Ghaymah
run: $HOME/ghaymah/bin/gy auth login --email "${{ secrets.GHAYMAH_EMAIL }}" --password "${{ secrets.GHAYMAH_PW }}" --debug
- name: Deploy to Ghaymah (Production)
run: $HOME/ghaymah/bin/gy resource app launch --debug

عرض الملف

@@ -0,0 +1,28 @@
FROM nginx:alpine
# Install bash, curl, openssl, coreutils (for date parsing), and cron
RUN apk update && apk add bash curl openssl coreutils dcron
# Clear the default Nginx welcome page first
RUN rm -rf /usr/share/nginx/html/*
# Setup workspace
COPY dashboard.html /usr/share/nginx/html/index.html
COPY monitor.sh /usr/local/bin/monitor.sh
RUN chmod +x /usr/local/bin/monitor.sh
RUN touch /usr/share/nginx/html/data.csv && \
chown -R nginx:nginx /usr/share/nginx/html && \
chmod -R 755 /usr/share/nginx/html
# Add cron job (runs every minute)
RUN echo "* * * * * /usr/local/bin/monitor.sh" | crontab -
# Custom entrypoint to start cron in background, then nginx in foreground
RUN echo '#!/bin/sh' > /entrypoint.sh && \
echo 'crond -b -l 8' >> /entrypoint.sh && \
echo 'nginx -g "daemon off;"' >> /entrypoint.sh && \
chmod +x /entrypoint.sh
EXPOSE 80
CMD ["/entrypoint.sh"]

عرض الملف

@@ -0,0 +1,115 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mithal Engine Status</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
body { font-family: system-ui, sans-serif; background: #f4f4f5; margin: 0; padding: 20px; color: #18181b; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-bottom: 20px; }
.card { background: white; padding: 20px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.metric { font-size: 2rem; font-weight: bold; color: #2563eb; }
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid #e4e4e7; }
.status-up { color: #16a34a; font-weight: bold; }
.status-down { color: #dc2626; font-weight: bold; }
</style>
</head>
<body>
<h1>Mithal Engine Monitoring Dashboard</h1>
<div class="grid">
<div class="card">
<h3>Uptime (Last 24h)</h3>
<div class="metric" id="uptime-indicator">--%</div>
</div>
<div class="card">
<h3>SSL Certificate</h3>
<div class="metric" id="ssl-status">-- Days</div>
</div>
</div>
<div class="card" style="margin-bottom: 20px;">
<h3>Response Time (Last Hour)</h3>
<canvas id="latencyChart" height="80"></canvas>
</div>
<div class="card">
<h3>Recent Logs (Last 10 Checks)</h3>
<table>
<thead>
<tr>
<th>Timestamp</th>
<th>Status</th>
<th>Latency (s)</th>
<th>DNS (s)</th>
<th>Search (s)</th>
</tr>
</thead>
<tbody id="log-table"></tbody>
</table>
</div>
<script>
async function loadData() {
const response = await fetch('data.csv');
const text = await response.text();
// Parse CSV
const rows = text.trim().split('\n').slice(1).map(row => {
const [timestamp, status, latency, ssl_days, dns, search] = row.split(',');
return { timestamp, status: parseInt(status), latency: parseFloat(latency), ssl_days, dns, search };
});
if (rows.length === 0) return;
// Uptime Calculation
const upChecks = rows.filter(r => r.status >= 200 && r.status < 400).length;
const uptimePct = ((upChecks / rows.length) * 100).toFixed(2);
document.getElementById('uptime-indicator').textContent = `${uptimePct}%`;
// SSL Status
const latest = rows[rows.length - 1];
document.getElementById('ssl-status').textContent = `${latest.ssl_days} Days`;
// Chart Data (Last 60 entries = 1 hour)
const recentHour = rows.slice(-60);
const labels = recentHour.map(r => new Date(r.timestamp).toLocaleTimeString());
const data = recentHour.map(r => r.latency);
new Chart(document.getElementById('latencyChart'), {
type: 'line',
data: {
labels: labels,
datasets: [{
label: 'Latency (s)',
data: data,
borderColor: '#2563eb',
tension: 0.1,
fill: false
}]
},
options: { animation: false }
});
// Logs Table (Last 10)
const last10 = rows.slice(-10).reverse();
const tbody = document.getElementById('log-table');
tbody.innerHTML = last10.map(r => `
<tr>
<td>${new Date(r.timestamp).toLocaleString()}</td>
<td class="${r.status === 200 ? 'status-up' : 'status-down'}">${r.status}</td>
<td>${r.latency.toFixed(3)}</td>
<td>${parseFloat(r.dns).toFixed(3)}</td>
<td>${parseFloat(r.search).toFixed(3)}</td>
</tr>
`).join('');
}
loadData();
setInterval(loadData, 60000); // Refresh every minute
</script>
</body>
</html>

عرض الملف

@@ -0,0 +1,41 @@
#!/bin/bash
# monitor.sh
TARGET="mithal.space"
URL="https://$TARGET"
SEARCH_URL="$URL/?q=test" # Adjust query parameter based on the actual search endpoint
if [ -d "/usr/share/nginx/html" ]; then
DATA_FILE="/usr/share/nginx/html/data.csv"
else
DATA_FILE="./data.csv"
fi
# Initialize CSV with headers if it doesn't exist
if [ ! -f "$DATA_FILE" ]; then
echo "timestamp,status,latency,ssl_days,dns_time,search_time" > "$DATA_FILE"
fi
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
# 1. Uptime, Latency, and DNS Resolution
HTTP_RESPONSE=$(curl -o /dev/null -s -w "%{http_code},%{time_total},%{time_namelookup}" "$URL")
STATUS=$(echo "$HTTP_RESPONSE" | cut -d',' -f1)
LATENCY=$(echo "$HTTP_RESPONSE" | cut -d',' -f2)
DNS_TIME=$(echo "$HTTP_RESPONSE" | cut -d',' -f3)
# 2. Search Response Time
SEARCH_TIME=$(curl -o /dev/null -s -w "%{time_total}" "$SEARCH_URL")
# 3. SSL Expiration
EXP_DATE=$(echo | openssl s_client -servername "$TARGET" -connect "$TARGET:443" 2>/dev/null | openssl x509 -noout -enddate | cut -d= -f2)
if [ -n "$EXP_DATE" ]; then
EXP_EPOCH=$(date -d "$EXP_DATE" +%s)
CURRENT_EPOCH=$(date +%s)
SSL_DAYS=$(( (EXP_EPOCH - CURRENT_EPOCH) / 86400 ))
else
SSL_DAYS=0
fi
# Append to CSV
echo "$TIMESTAMP,$STATUS,$LATENCY,$SSL_DAYS,$DNS_TIME,$SEARCH_TIME" >> "$DATA_FILE"