Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
cmisip's script improved
#!/bin/bash
interval=5
numreports=12 #1 minute
tail_n=$((${numreports} +1))
zmc_array=(`ps ax | grep -w z[m]c | awk '{print $1}'`)
zma_array=(`ps ax | grep -w z[m]a | awk '{print $1}'`)
(for i in "${zmc_array[@]}"
do
zmc=(`pidstat -p $i -u $interval $numreports | tail -${tail_n} | cut -c56-62`)
bc_arg_zmc=();
zmc_counter=${#zmc[@]}
for j in "${zmc[@]}"
do
((zmc_counter--))
if [ $zmc_counter -gt 0 ]; then
bc_arg_zmc=(${bc_arg_zmc[@]} "$j + ")
fi
done
echo;
echo "PIDSTAT zmc : Reporting average of $numreports readings at $interval seconds intervals"
bc_arg_zmc=(`echo ${bc_arg_zmc[@]} | sed 's/..$//g'`)
echo ""
echo "ZMC Process ID : $i ==> ( ${bc_arg_zmc[@]} ) / ${numreports} "
echo "AVERAGE : ${zmc[$((${#zmc[@]}-1))]}"
done) & zmcjob=$!
sleep 1;
(for i in "${zma_array[@]}"
do
zma=(`pidstat -p $i -u $interval $numreports | tail -${tail_n} | cut -c56-62`)
bc_arg_zma=();
zma_counter=${#zma[@]}
for j in "${zma[@]}"
do
((zma_counter--))
if [ $zma_counter -gt 0 ]; then
bc_arg_zma=(${bc_arg_zma[@]} "$j + ")
fi
done
echo;
echo "PIDSTAT zma : Reporting average of $numreports readings at $interval seconds intervals"
bc_arg_zma=(`echo ${bc_arg_zma[@]} | sed 's/..$//g'`)
echo ""
echo "ZMA Process ID : $i ==> ( ${bc_arg_zma[@]} ) / ${numreports} "
echo "AVERAGE : ${zma[$((${#zma[@]}-1))]}"
done) & zmajob=$!
wait $zmcjob;
wait $zmajob;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.