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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
#!/bin/sh
# PCP QA Test No. 9000
# If systemd is in the mix, check systemctl status for all PCP
# units.
#
# Copyright (c) 2025 Ken McDonell. All Rights Reserved.
#
if [ $# -eq 0 ]
then
seq=`basename $0`
echo "QA output created by $seq"
else
# use $seq from caller, unless not set
[ -n "$seq" ] || seq=`basename $0`
echo "QA output created by `basename $0` $*"
fi
verbose=false
[ $# -gt 0 -a X"$1" = X--verbose ] && verbose=true
# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check
[ "`$PCP_PS_PROG -p 1 -o comm=`" != systemd ] && _notrun "systemd not active"
[ -d "$PCP_SYSTEMDUNIT_DIR" ] || _notrun "systemd dir $PCP_SYSTEMDUNIT_DIR not found"
_cleanup()
{
cd $here
$sudo rm -rf $tmp $tmp.*
}
status=0 # success is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_filter()
{
sed \
-e "s@$tmp@TMP@g" \
# end
}
# real QA test starts here
echo "Silence is golden ..."
fmt="%-28.28s %-9.9s %-13.13s %-11.11s %-12.12s %-12.12s %-12.12s %-12.12s\n"
$verbose && printf "$fmt" "Unit" "LoadState" "UnitFileState" "ActiveState" "TriggeredBy" "SubState" "ConditionResult"
( cd $PCP_SYSTEMDUNIT_DIR; ls -d pcp-*.service pcp-*.timer pm*.service pm*.timer 2>/dev/null ) \
| while read unit
do
[ -f "$PCP_SYSTEMDUNIT_DIR/$unit" ] || continue
systemctl status -l --no-pager "$unit" >>$seq_full
systemctl show --no-pager "$unit" >$tmp.tmp
LoadState='missing'
eval `grep ^LoadState= $tmp.tmp`
UnitFileState='missing'
eval `grep ^UnitFileState= $tmp.tmp`
ActiveState='missing'
eval `grep ^ActiveState= $tmp.tmp`
TriggeredBy='missing'
eval `grep ^TriggeredBy= $tmp.tmp`
SubState='missing'
eval `grep ^SubState= $tmp.tmp`
ConditionResult='missing'
eval `grep ^ConditionResult= $tmp.tmp`
$verbose && printf "$fmt" "$unit" "$LoadState" "$UnitFileState" "$ActiveState" "$TriggeredBy" "$SubState" "$ConditionResult"
echo "unit=$unit LoadState=$LoadState UnitFileState=$UnitFileState ActiveState=$ActiveState TriggeredBy=$TriggeredBy SubState=$SubState ConditionResult=$ConditionResult" >>$seq_full
if [ "$LoadState" = loaded -a "$UnitFileState" = disabled ]
then
echo "$unit: loaded but disabled" >>$seq_full
continue
fi
if [ "$LoadState" = loaded -a "$ActiveState" = active ]
then
echo "$unit: loaded and active" >>$seq_full
continue
fi
if [ "$LoadState" = loaded -a "$ActiveState" = inactive -a "$SubState" = dead -a "$TriggeredBy" != missing ]
then
echo "$unit: loaded and waiting for $TriggeredBy" >>$seq_full
continue
fi
# pcp-reboot-init.service is a special "one" shot and
# the resulting ActiveState (SubState) can be "inactive (dead)" or
# "active (exited)"
#
if [ "$unit" = pcp-reboot-init.service ]
then
if [ "$ActiveState+$SubState" = "active+exited" -o \
"$ActiveState+$SubState" = "inactive+dead" ]
then
continue
fi
fi
if [ "$SubState" = dead ]
then
echo "$unit: BAD LoadState=$LoadState UnitFileState=$UnitFileState ActiveState=$ActiveState Substate=dead TriggeredBy=$TriggeredBy"
systemctl status -l --no-pager "$unit"
continue
fi
echo "$unit: BAD Unclassified LoadState=$LoadState UnitFileState=$UnitFileState ActiveState=$ActiveState TriggeredBy=$TriggeredBy SubState=$SubState"
systemctl status -l --no-pager "$unit"
done
# success, all done
exit
|