I have a log file in which there are plenty of threads. i want to count the number of unique threads.Here thread is tid value.
My Logfile looks like this--
Code:
Wed May 20 05:22:53.993 2009 Morocco Standard Time INFO: pid 2172 tid 688: 17: 10106931: ArAuthFrameworkImpl::doPreAuth::1:10106931:: Authentication mechanism returned [0] for AuthIdentity []
Wed May 20 05:22:53.993 2009 Morocco Standard Time INFO: pid 2172 tid 688: 170: 10106931: Arcot Native Server: recvd AA_BIN_MSG_VER_CHG
Wed May 20 05:22:57.634 2009 Morocco Standard Time INFO: pid 2172 tid 3352: 170: 10106932: Arcot Native Server: recvd AA_BIN_MSG_GET_WLT
Wed May 20 05:22:57.634 2009 Morocco Standard Time INFO: pid 2172 tid 3352: 170: 10106932: Session tracker Id associated with generate challenge[1:10106932]
Like this there are thousands of threads in a log file.
i want to capture the unique threads and count the numbers.
Any kind of help or suggestion will be very useful to me.
perl -ne'
/ tid (\d+)/ && $tid{$1}++;
print map "$_: $tid{$_}\n", keys %tid
if eof
' infile
Hi ,
i am using this code and it's giving me whole count including the repated ones. I just want to get the count of unique threads. please suggest me what i need to do to achieve this.
Code:
#!/usr/bin/perl -w
print "Hello, World...\n";
my $logFile = $ARGV[0];
die "usage: $0 <logFile>" unless $logFile;
die "Logfile $logFile doesn't exist" unless -f "$logFile";
open(my $log, "<", $logFile) or die "Can't open $logFile for reading.";
print "Processing file $logFile...\n";
#my $authenticates = {};
my $n = 0;
my $TIDCount = 0;
while(my $line = <$log>) {
# Outer loop. Look for an interesting part of the log file.
$n++;
$line =~ tr/\r\n//d;
if($line =~ /tid (\d+)/){
$TIDCount++;
next;
}
}
print "Thread count for the logfile is $TIDCount\n";
Dear Moderator
I am not able to post any new thread or post reply to mine old thread.
Kindly help as i am stuck on one problem and needed suggestion.
Regards
Jaydeep (1 Reply)
I am running a multithreaded program which creates 10 threads and works away.
However, when I use top to monitor my program whilst it is running, it only shows 4 under the thread count!
Can anyone explain if this is in fact the number of threads running in my process... (0 Replies)