Skip to content

Commit

Permalink
mod monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
DanRunfola committed Feb 14, 2025
1 parent b064668 commit 3e268e3
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 22 deletions.
31 changes: 25 additions & 6 deletions geoBoundaryBuilder/monitor/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,27 @@ def get_stats():

# Get status information
cur.execute("""
SELECT "STATUS_TYPE", "STATUS", "TIME"
FROM status
ORDER BY "STATUS_TYPE"
WITH latest_status AS (
SELECT "STATUS_TYPE", "STATUS", "TIME"
FROM status
WHERE "STATUS" NOT LIKE '%heartbeat%'
AND "STATUS_TYPE" IN ('GIT', 'QUEUE', 'WORKER')
),
latest_heartbeat AS (
SELECT "STATUS_TYPE", "STATUS", "TIME"
FROM status
WHERE "STATUS" LIKE '%heartbeat%'
AND "STATUS_TYPE" IN ('GIT', 'QUEUE', 'WORKER')
)
SELECT
ls."STATUS_TYPE",
ls."STATUS" as status_message,
ls."TIME" as status_time,
lh."STATUS" as heartbeat_message,
lh."TIME" as heartbeat_time
FROM latest_status ls
LEFT JOIN latest_heartbeat lh ON ls."STATUS_TYPE" = lh."STATUS_TYPE"
ORDER BY ls."STATUS_TYPE"
""")
rows = cur.fetchall()
logging.info(f"Status rows: {rows}")
Expand All @@ -71,9 +89,10 @@ def get_stats():
for row in rows:
status_info.append({
'type': row[0],
'status': row[1],
'last_updated': row[2].isoformat() if row[2] else None,
'heartbeat': row[2].isoformat() if row[2] else None # Using TIME for both since there's no separate heartbeat
'status_message': row[1],
'status_time': row[2].isoformat() if row[2] else None,
'heartbeat_message': row[3],
'heartbeat_time': row[4].isoformat() if row[4] else None
})
logging.info(f"Processed status info: {status_info}")

Expand Down
66 changes: 50 additions & 16 deletions geoBoundaryBuilder/monitor/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,45 @@
}
.status-card {
background-color: #fff;
padding: 15px;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
border: 1px solid #e1e1e1;
}
.status-type {
font-size: 1.2em;
font-size: 1.4em;
font-weight: bold;
color: #2c3e50;
margin-bottom: 10px;
margin-bottom: 15px;
text-align: center;
border-bottom: 2px solid #eee;
padding-bottom: 10px;
}
.status-section {
margin-bottom: 15px;
padding: 10px;
background: #f8f9fa;
border-radius: 6px;
}
.status-label {
font-size: 0.9em;
color: #666;
text-transform: uppercase;
letter-spacing: 0.5px;
margin-bottom: 5px;
}
.status-value {
font-size: 1.1em;
color: #34495e;
margin-bottom: 5px;
margin: 5px 0;
padding: 5px;
background: white;
border-radius: 4px;
}
.status-time {
font-size: 0.9em;
color: #7f8c8d;
}
.heartbeat {
font-size: 0.8em;
color: #95a5a6;
margin-top: 5px;
color: #7f8c8d;
margin-top: 3px;
font-style: italic;
}
.error {
color: #e74c3c;
Expand Down Expand Up @@ -119,10 +134,19 @@ <h2>System Status</h2>
</div>

<script>
function formatDate(isoString) {
function formatDateEST(isoString) {
if (!isoString) return 'None';
const date = new Date(isoString);
return date.toLocaleString();
return date.toLocaleString('en-US', {
timeZone: 'America/New_York',
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: true
});
}

function getTimeDifferenceInMinutes(isoString) {
Expand Down Expand Up @@ -213,11 +237,21 @@ <h2>System Status</h2>

const statusColor = getStatusColor(status.status);

const statusColor = getStatusColor(status.status_message);
const heartbeatColor = getHeartbeatColor(status.heartbeat_time);

statusCard.innerHTML = `
<div class="status-type">${status.type}</div>
<div class="status-value" style="color: ${statusColor}">${status.status}</div>
<div class="status-time">Updated: ${formatDate(status.last_updated)}</div>
<div class="heartbeat" style="color: ${getHeartbeatColor(status.heartbeat)}">Heartbeat: ${formatDate(status.heartbeat)}</div>
<div class="status-section">
<div class="status-label">Status:</div>
<div class="status-value" style="color: ${statusColor}">${status.status_message}</div>
<div class="status-time">Last Updated: ${formatDateEST(status.status_time)}</div>
</div>
<div class="status-section">
<div class="status-label">Heartbeat:</div>
<div class="status-value" style="color: ${heartbeatColor}">${status.heartbeat_message}</div>
<div class="status-time">Last Beat: ${formatDateEST(status.heartbeat_time)}</div>
</div>
`;

statusGrid.appendChild(statusCard);
Expand Down

0 comments on commit 3e268e3

Please sign in to comment.