I'm wishing to identify which process on a server causes huge loadavg spikes on it .. by logging the loadavg and process cpu, ram and disk usage ..
Recently found pidstat usage really usefull, I'm running a command in background setting the output to a file which I collect every minute in order to trace cpu and ram consuming processes ... Only problem is, this file only keeps bigger over the time .. even if i try to truncate it each time it is bigger than 1Mo, it just keeps growing over and over again .. Is there any option to run once that command, output to file, so it can put it in a loop ?
I know I'm doing it wrong .. yet I'm bruteforcing this this way ... funny thing is each output is exactly 4096 bytes and some processes seems to repeat 3 times within the output...
interval=60;checks=9;kill -9 $subpro;pkill -9 -f pidstat; ( while [ true ]; do s=`wc -c /cpu.log|awk '{print $1}'`; if [ $s -gt 10000 ];then echo $s;cp /cpu.log /cpu.log.2; kill -9 $process; echo '' > /cpu.log; pidstat -urd -h $interval | awk '{print $8" "$14" "$15" "$16" "$17" "$19}' > /cpu.log & process=$!; echo $process; fi; sleep $checks; done; ) & subpro=$!;echo $subpro;#
pidstat -urd -h 60 | awk '{print $8" "$14" "$15" "$16" "$17" "$19}' > /cpu.log &
Thanks in advance for any clue, notice, enlightment, solution ;)