| 
 | 1 | +#!/bin/sh  | 
 | 2 | +# PCP QA Test No. 1747  | 
 | 3 | +# Exercise pmlogger labels handling for dynamic instance domains.  | 
 | 4 | +#  | 
 | 5 | +# Copyright (c) 2025 Red Hat.  All Rights Reserved.  | 
 | 6 | +#  | 
 | 7 | + | 
 | 8 | +seq=`basename $0`  | 
 | 9 | +echo "QA output created by $seq"  | 
 | 10 | + | 
 | 11 | +# get standard environment, filters and checks  | 
 | 12 | +. ./common.product  | 
 | 13 | +. ./common.filter  | 
 | 14 | +. ./common.check  | 
 | 15 | + | 
 | 16 | +[ -d $PCP_PMDAS_DIR/simple ] || _notrun "simple PMDA directory is not installed"  | 
 | 17 | + | 
 | 18 | +_cleanup()  | 
 | 19 | +{  | 
 | 20 | +    cd $here  | 
 | 21 | +    if $need_restore  | 
 | 22 | +    then  | 
 | 23 | +        need_restore=false  | 
 | 24 | +        $sudo rm -rf $PCP_ETC_DIR/pcp/labels/*  | 
 | 25 | +        _restore_config $PCP_ETC_DIR/pcp/labels  | 
 | 26 | +        _restore_config $PCP_PMDAS_DIR/simple/simple.conf  | 
 | 27 | +        _sighup_pmcd  | 
 | 28 | +    fi  | 
 | 29 | +    $sudo rm -rf $tmp $tmp.*  | 
 | 30 | +}  | 
 | 31 | + | 
 | 32 | +userid=`id -u`  | 
 | 33 | +groupid=`id -g`  | 
 | 34 | +hostname=`hostname`  | 
 | 35 | +machineid=`_machine_id`  | 
 | 36 | +domainname=`_domain_name`  | 
 | 37 | +rm -f $seq_full  | 
 | 38 | + | 
 | 39 | +status=0	# success is the default!  | 
 | 40 | +need_restore=true  | 
 | 41 | +trap "_cleanup; exit \$status" 0 1 2 3 15  | 
 | 42 | + | 
 | 43 | +_filter_labels()  | 
 | 44 | +{  | 
 | 45 | +    sed \  | 
 | 46 | +        -e "s/.domainname.:.${domainname}./\"domainname\":\"DOMAIN\"/g" \  | 
 | 47 | +        -e "s/.machineid.:.${machineid}./\"machineid\":\"MACHINE\"/g" \  | 
 | 48 | +        -e "s/.hostname.:.${hostname}./\"hostname\":\"HOSTNAME\"/g" \  | 
 | 49 | +        -e "s/.groupid.:$groupid/\"groupid\":GID/g" \  | 
 | 50 | +        -e "s/.userid.:$userid/\"userid\":UID/g" \  | 
 | 51 | +    #end  | 
 | 52 | +}  | 
 | 53 | + | 
 | 54 | +# real QA test starts here  | 
 | 55 | +_save_config $PCP_ETC_DIR/pcp/labels  | 
 | 56 | +$sudo rm -rf $PCP_ETC_DIR/pcp/labels/*  | 
 | 57 | +_sighup_pmcd || _exit 1  | 
 | 58 | + | 
 | 59 | +_save_config "$PCP_PMDAS_DIR/simple/simple.conf"  | 
 | 60 | +conf="sec"  | 
 | 61 | +echo $conf > "$tmp.simple.conf"  | 
 | 62 | +$sudo cp "$tmp.simple.conf" "$PCP_PMDAS_DIR/simple/simple.conf"  | 
 | 63 | + | 
 | 64 | +cat > $tmp.config <<EOF  | 
 | 65 | +log mandatory on default { simple }  | 
 | 66 | +EOF  | 
 | 67 | + | 
 | 68 | +pmlogger -c $tmp.config -l $tmp.log -t 1sec -T 8sec $tmp.archive &  | 
 | 69 | +pid=$!  | 
 | 70 | + | 
 | 71 | +# delay for pmlogger startup  | 
 | 72 | +pmsleep 0.5  | 
 | 73 | + | 
 | 74 | +# inject changes to instances and labels  | 
 | 75 | +for insts in "sec,min" "sec,min,hour"  | 
 | 76 | +do  | 
 | 77 | +    pmsleep 1.5  | 
 | 78 | +    echo $insts > "$tmp.simple.conf"  | 
 | 79 | +    $sudo cp "$tmp.simple.conf" "$PCP_PMDAS_DIR/simple/simple.conf"  | 
 | 80 | +done  | 
 | 81 | + | 
 | 82 | +# ensure pmlogger has completed (from use of the -T option)  | 
 | 83 | +wait $pid  | 
 | 84 | +cat $tmp.log | tee $seq_full | _filter_pmlogger_log  | 
 | 85 | + | 
 | 86 | +# reading from the archive end, expect labels for three instances  | 
 | 87 | +pmdumplog -ae $tmp.archive >> $seq_full  | 
 | 88 | +#pminfo -fl simple.now >> $seq_full  | 
 | 89 | +pminfo -l -O 6sec -a $tmp.archive simple.now | _filter_labels  | 
 | 90 | + | 
 | 91 | +# success, all done  | 
 | 92 | +exit  | 
0 commit comments