Last active
January 16, 2019 13:36
-
-
Save mrsiano/dc7979413358977852268c1acc630af9 to your computer and use it in GitHub Desktop.
pbench pidstat-toolscript new gen - the actual pistat script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# index's | |
time_idx=1 | |
pid=3 | |
cpu_pres=7 | |
mem_pres=13 | |
rss=12 | |
cmd=20 | |
pidstat_in_mem=$(pidstat -l -w -u -h -d -r -p ALL |grep -v 'Time UID\|Linux') | |
pids=$(echo "${pidstat_in_mem}" | awk '{print $3}' |sort |uniq |grep '[0-9]') | |
process=$(echo "${pidstat_in_mem}" | awk '{print $3"-"$20}' |sort |uniq |grep '[0-9]-') | |
# initialized the new csv's | |
pidstat_cpu_pres_csv=/tmp/pidstat_cpu_pres.csv | |
echo -n "timestamp" > $pidstat_cpu_pres_csv | |
for pid in $process; do | |
echo -n ",$pid" >> $pidstat_cpu_pres_csv | |
done | |
echo "" >> $pidstat_cpu_pres_csv | |
# fill csv with data | |
counter=1 | |
rcomma="" # set initial right comma | |
colomuns=$(echo $pids | awk -F ' ' '{ print NF }') # count colomuns | |
for pid in $pids; do | |
# build a series of commas in order to parse the rotation. | |
lcomma="" | |
for x in $counter; do | |
rcomma+="0," | |
done | |
z=$(expr $colomuns - $counter) | |
for i in $( seq 1 $z ); do | |
lcomma+=",0" | |
done | |
# actually fill the pid column with data. | |
# the time is already sorted. | |
for line in `echo "${pidstat_in_mem}" | grep $pid |awk '{print $1","$7}'`; do | |
timestamp=`echo $line |awk -F "," '{print $1}'` # get time | |
let timestamp=$timestamp*1000 # get time in ms. | |
data=`echo $line |awk -F "," '{print $2}'` # get data | |
# dump line | |
echo "$timestamp$rcomma$data$lcomma" >> $pidstat_cpu_pres_csv | |
done | |
let counter++ | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment