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
|
#!/bin/sh
# PCP QA Test No. 1810
# Exercise the BPF PMDA CO-RE oomkill module - install, remove and values.
#
# Copyright (c) 2022 Sohaib Mohamed.
#
seq=`basename $0`
echo "QA output created by $seq"
. ./common.bpf
physmem=`pmprobe -v hinv.physmem | $PCP_AWK_PROG '{print $3}'`
if [ -z "$physmem" ]
then
pminfo -f hinv.physmem
_notrun "No values for hinv.physmem?"
elif [ "$physmem" -gt 4000 ]
then
_notrun "Physical memory too large ($physmem)"
fi
_pmdabpf_check
_pmdabpf_require_kernel_version 5 0
_pmdabpf_require_libbpf_version 1 0
status=1 # failure is the default!
signal=$PCP_BINADM_DIR/pmsignal
cat <<EOF >$tmp.conf
# Installed by PCP QA test $seq on `date`
[oomkill.so]
enabled=true
EOF
_pmdabpf_tryload $tmp.conf
_cleanup()
{
cd $here
_pmdabpf_cleanup
$sudo rm -rf $tmp $tmp.*
}
_prepare_pmda bpf
trap "_cleanup; exit \$status" 0 1 2 3 15
_stop_auto_restart pmcd
# real QA test starts here
_pmdabpf_install $tmp.conf
_pmdabpf_wait_for_metric
# Generate system activity for the CO-RE oomkill module
# ... this simple recipe comes from
# https://askubuntu.com/questions/301057/testing-my-system-i-need-a-script-that-will-use-as-much-ram-and-swap-as-possibl/823798#comment1507361_823798
# and is much more reliable than the former perl+ulimit solution
# we were using here
#
tail /dev/zero >$tmp.oom.log 2>&1 &
wait 2>>$seq_full
echo "=== report metric values for fcomm ==="
pminfo -dfmtT bpf.oomkill.fcomm 2>&1 | tee -a $seq_full \
| _value_filter_any
echo "=== report metric values for fpid ==="
pminfo -dfmtT bpf.oomkill.fpid 2>&1 | tee -a $seq_full \
| _value_filter_nonzero
echo "=== report metric values for tcomm ==="
pminfo -dfmtT bpf.oomkill.tcomm 2>&1 | tee -a $seq_full \
| _value_filter_exact '"tail"'
echo "=== report metric values for tpid ==="
pminfo -dfmtT bpf.oomkill.tpid 2>&1 | tee -a $seq_full \
| _value_filter_nonzero
echo "=== report metric values for pages ==="
pminfo -dfmtT bpf.oomkill.pages 2>&1 | tee -a $seq_full \
| _value_filter_nonzero
_pmdabpf_remove
echo >>$seq_full
echo "=== oom log ===" >>$seq_full
cat $tmp.oom.log >>$seq_full
status=0
exit
|