@@ -825,25 +825,40 @@ done`,
825825 },
826826 PMUBusyScriptName : {
827827 Name : PMUBusyScriptName ,
828- ScriptTemplate : `# loop through the PMU counters and check if they are active or inactive
829- for i in 0x30a 0x309 0x30b 0x30c 0xc1 0xc2 0xc3 0xc4 0xc5 0xc6 0xc7 0xc8; do
830- arr=()
831- # read the value of the msr represented by the hex value 6 times, save results in an array
832- for j in {1..6}; do
833- val=$(rdmsr $i | tr -d '\n')
834- # if the value isn't a hex value, go on to next hex value
835- if [[ ! $val =~ ^[0-9a-fA-F]+$ ]]; then
836- echo "$i Unknown"
837- continue 2
838- fi
839- arr+=($val)
840- done
841- # if the first and last value in the array are the same, the counter is inactive
842- if [ ${arr[0]} == ${arr[5]} ]; then
843- echo "$i Inactive"
844- else
845- echo "$i Active"
846- fi
828+ ScriptTemplate : `# define the list of PMU counters
829+ pmu_counters=(0x30a 0x309 0x30b 0x30c 0xc1 0xc2 0xc3 0xc4 0xc5 0xc6 0xc7 0xc8)
830+
831+ # define the number of times to loop, i.e., read the MSR value
832+ num_loops=6
833+
834+ # initialize an associative array to store the values for each PMU counter
835+ declare -A pmu_values
836+
837+ # read the value of the msr represented by the hex value num_loops times for each PMU counter
838+ for ((j=1; j<=num_loops; j++)); do
839+ for i in "${pmu_counters[@]}"; do
840+ val=$(rdmsr $i | tr -d '\n')
841+ # if the value isn't a hex value, go on to next hex value
842+ if [[ ! $val =~ ^[0-9a-fA-F]+$ ]]; then
843+ echo "$i Unknown"
844+ continue 2
845+ fi
846+ # append the value to the array for the current PMU counter
847+ pmu_values[$i]+="$val "
848+ done
849+ done
850+
851+ # check if the first and last value in the array are the same for each PMU counter
852+ for i in "${pmu_counters[@]}"; do
853+ # convert the space-separated string to an array
854+ arr=(${pmu_values[$i]})
855+ if [ ${arr[0]} == ${arr[5]} ]; then
856+ echo "$i Inactive"
857+ else
858+ echo "$i Active"
859+ fi
860+ # print the full list of PMU values
861+ echo "Values: ${pmu_values[$i]}"
847862done` ,
848863 Superuser : true ,
849864 Architectures : []string {x86_64 },
0 commit comments