-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontainers.sh
More file actions
executable file
·49 lines (42 loc) · 1.09 KB
/
containers.sh
File metadata and controls
executable file
·49 lines (42 loc) · 1.09 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
#!/bin/bash
CONTAINERS=$(/snap/bin/lxc list -c n --format csv)
containerInfo () {
local STAT=$(/snap/bin/lxc list $CONTAINER -c s --format csv | awk '{print toupper(substr($0,0,1))tolower(substr($0,2))}')
local IP4=$(/snap/bin/lxc list $CONTAINER -c 4 --format csv)
#local MUSE=$(/snap/bin/lxc info $CONTAINER | awk '/Memory \(current\)/ {print $3}')
local DUSE=$(/snap/bin/lxc exec $CONTAINER -- du -shx / | awk '{print $1}')
echo "<tr>"
echo "<td>$CONTAINER</td>"
echo "<td>$STAT</td>"
echo "<td>$IP4</td>"
#echo "<td>$MUSE</td>"
echo "<td>$DUSE</td>"
echo "</tr>"
}
for CONTAINER in $CONTAINERS
do
san=$(echo $CONTAINER | sed 's/[^a-zA-Z0-9]//g')
containerInfo > /tmp/$san &
done
wait
echo "<section id='containers'>"
echo "<table>"
echo "<thead>"
echo "<tr>"
echo "<th>Name</th>"
echo "<th>Status</th>"
echo "<th>IP</th>"
#echo "<th>Memory</th>"
echo "<th>Disk</th>"
echo "</tr>"
echo "</thead>"
echo "<tbody>"
for CONTAINER in $CONTAINERS
do
san=$(echo $CONTAINER | sed 's/[^a-zA-Z0-9]//g')
cat /tmp/$san
rm /tmp/$san
done
echo "</tbody>"
echo "</table>"
echo "</section>"