Last active
January 16, 2019 13:48
-
-
Save mrsiano/cc01500b9bc0ff7465ac9445ace52699 to your computer and use it in GitHub Desktop.
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
while true; do | |
# capture pidstat | |
pidstat_in_mem=$(pidstat -l -w -u -h -d -r -p ALL) |grep -v 'Time UID\|Linux' | |
# the template | |
#Time,UID,PID,%usr,%system,%guest,%CPU,CPU,minflt/s,majflt/s,VSZ,RSS,%MEM,kB_rd/s,kB_wr/s,kB_ccwr/s,iodelay,cswch/s,nvcswch/s,Command | |
# index's | |
time_idx=1 | |
pid=3 | |
cpu_pres=7 | |
mem_pres=13 | |
rss=12 | |
cmd=20 | |
# dump output to text file per metric. | |
echo "$pidstat_in_mem" |awk -v t="$time_idx" -v m="$cpu_pres" -v c="$cmd" -v p="$pid" '{print $t "," $m "," $p"-"$c}') >> pidstat_raw_cpu_pres.csv | |
echo "$pidstat_in_mem" |awk -v t="$time_idx" -v m="$mem_pres" -v c="$cmd" -v p="$pid" '{print $t "," $m "," $p"-"$c}' >> pidstat_raw_mem_pres.csv | |
echo "$pidstat_in_mem" |awk -v t="$time_idx" -v m="$rss" -v c="$cmd" -v p="$pid" '{print $t "," $m "," $p"-"$c}' >> pidstat_raw_rss.csv | |
sleep 10 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment