-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlxddt.sh
22 lines (18 loc) · 941 Bytes
/
lxddt.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash
# ./lxddt.sh
MAX_RUNNING_LXC=$(grep LXD_META_NUMBER_OF_RUNNING_CONTAINERS /var/log/syslog{.1,} | tail -1 | rev | cut -d' ' -f1 | rev)
CURRENT_RUNNING_LXC=$(ps aux | grep '[l]xc monitor' | wc -l)
LAST_LIVE_CONTAINER_NAME=$(cat /var/snap/lxd/common/lxd/logs/lxd.log | grep 'Started container' | grep -v '\-staging\-' | tail -n1 | egrep -o "(instance|name)=.*" | cut -d'=' -f2 | cut -d' ' -f1)
LAST_LIVE_CONTAINER_TIME=$(cat /var/snap/lxd/common/lxd/logs/lxd.log | grep 'Started container' | grep "$LAST_LIVE_CONTAINER_NAME" | tail -n1 | cut -d' ' -f1 | egrep -o '[0-9]+:[0-9]+')
echo ""
echo "Time now: $(date '+%H:%M') UTC"
echo ""
echo "Running / Max"
echo " $CURRENT_RUNNING_LXC / $MAX_RUNNING_LXC"
echo ""
echo "Last live container started:
$LAST_LIVE_CONTAINER_NAME @ $LAST_LIVE_CONTAINER_TIME UTC"
echo ""
echo "Last uptime:"
grep LXD_META_UP_SINCE /var/log/syslog{.1,} | tail -1 | rev | cut -d' ' -f1-2 | rev
echo ""