forked from stove/risotto
add diagnose command
This commit is contained in:
parent
30a605a81c
commit
b9be6491cc
1 changed files with 52 additions and 0 deletions
52
sbin/diagnose
Normal file
52
sbin/diagnose
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
MACHINES=""
|
||||||
|
for nspawn in $(ls /etc/systemd/nspawn/*.nspawn); do
|
||||||
|
nspawn_file=$(basename $nspawn)
|
||||||
|
machine=${nspawn_file%.*}
|
||||||
|
MACHINES="$MACHINES$machine "
|
||||||
|
done
|
||||||
|
STARTED=""
|
||||||
|
DEGRADED=""
|
||||||
|
found=true
|
||||||
|
idx=0
|
||||||
|
while [ $found = true ]; do
|
||||||
|
found=false
|
||||||
|
echo "tentative $idx"
|
||||||
|
for machine in $MACHINES; do
|
||||||
|
if ! echo $STARTED | grep -q " $machine "; then
|
||||||
|
status=$(machinectl -q shell $machine /usr/bin/systemctl is-system-running 2>/dev/null || echo "not started")
|
||||||
|
if echo "$status" | grep -q degraded; then
|
||||||
|
STARTED="$STARTED $machine "
|
||||||
|
DEGRADED="$DEGRADED $machine"
|
||||||
|
elif echo "$status" | grep -q running; then
|
||||||
|
STARTED="$STARTED $machine "
|
||||||
|
else
|
||||||
|
found=true
|
||||||
|
echo "status actuel de $machine : $status"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
sleep 2
|
||||||
|
idx=$((idx+1))
|
||||||
|
if [ $idx = 60 ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
retcode=0
|
||||||
|
for machine in $MACHINES; do
|
||||||
|
if ! echo "$STARTED" | grep -q " $machine "; then
|
||||||
|
echo
|
||||||
|
echo "========= $machine"
|
||||||
|
machinectl -q shell $machine /usr/bin/systemctl is-system-running 2>/dev/null || echo "not started"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo $DEGRADED
|
||||||
|
for machine in $DEGRADED; do
|
||||||
|
echo
|
||||||
|
echo "========= $machine"
|
||||||
|
machinectl -q shell $machine /usr/bin/systemctl --state=failed --no-legend --no-pager
|
||||||
|
retcode=1
|
||||||
|
done
|
||||||
|
|
||||||
|
exit $retcode
|
Loading…
Reference in a new issue