Hi guys,
I need a script that will generate a core of a process when the process uses high cpu for a sustained period?
So for example if a process is using greater than 80% cpu for more than 30 minutes do "gcore /var/tmp/process.core pid"
Hi guys,
I need a script that will generate a core of a process when the process uses high cpu for a sustained period?
So for example if a process is using greater than 80% cpu for more than 30 minutes do "gcore /var/tmp/process.core pid"
I gave a simple script , Actually I did not complete your requirement fully , but
I am quite sure that it will help you to understand the way and let you to complete this
requirement.
The following is a perl script.
use strict;
use warnings;
open FH , ">> Filename ";
while (1)
{
my $cpu = `ps -U abubacker -eo "%C %c\n"|sort -n|tail -n 1`;
$cpu =~ s/^\s*(.*)$/$1/;
my($pid, $process)= split / /, $cpu ;
if ( $pid > 80 )
{
print FH "$pid == $process\n" ;
}
sleep 5;
}
close FH ;