-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmonitor.sh
More file actions
57 lines (45 loc) · 1.66 KB
/
monitor.sh
File metadata and controls
57 lines (45 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# Monitoring script for Pegascape Docker container
# Usage: ./monitor.sh [interval_seconds]
INTERVAL=${1:-30}
CONTAINER_NAME="pegascape"
echo "Pegascape Container Monitor"
echo "==========================="
echo "Monitoring interval: ${INTERVAL}s"
echo "Press Ctrl+C to stop"
echo
while true; do
clear
echo "$(date): Pegascape Status Report"
echo "=================================="
# Container status
if docker ps --filter "name=$CONTAINER_NAME" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" | grep -q "$CONTAINER_NAME"; then
echo "✓ Container is running"
docker ps --filter "name=$CONTAINER_NAME" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
else
echo "✗ Container is not running"
fi
echo
# Health status
HEALTH=$(docker inspect --format='{{.State.Health.Status}}' $CONTAINER_NAME 2>/dev/null)
if [ "$HEALTH" = "healthy" ]; then
echo "✓ Health: $HEALTH"
elif [ "$HEALTH" = "unhealthy" ]; then
echo "✗ Health: $HEALTH"
elif [ "$HEALTH" = "starting" ]; then
echo "⏳ Health: $HEALTH"
else
echo "? Health: Unknown or no health check"
fi
echo
# Resource usage
echo "Resource Usage:"
docker stats $CONTAINER_NAME --no-stream --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.NetIO}}" 2>/dev/null || echo "Unable to get stats"
echo
# Recent logs (last 5 lines)
echo "Recent Logs:"
docker logs --tail 5 $CONTAINER_NAME 2>/dev/null | sed 's/^/ /' || echo " Unable to get logs"
echo
echo "Next update in ${INTERVAL}s..."
sleep $INTERVAL
done