From d0e1b7186cf110f14086ad2c98ee542f024b4caa Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Thu, 20 Nov 2025 07:51:33 +0100 Subject: [PATCH] Add perl script for CC logfile analysis --- tools/grepCCLog.pl | 74 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100755 tools/grepCCLog.pl diff --git a/tools/grepCCLog.pl b/tools/grepCCLog.pl new file mode 100755 index 0000000..0425427 --- /dev/null +++ b/tools/grepCCLog.pl @@ -0,0 +1,74 @@ +#!/usr/bin/env perl + +my $filename = $ARGV[0]; +my $Tday = $ARGV[1]; + +open FILE,"<$filename"; + +my %startedJob; +my %stoppedJob; + +foreach ( ) { + if ( /Oct ([0-9]+) .*new job \(id: ([0-9]+)\): cluster=([a-z]+), jobId=([0-9]+), user=([a-z0-9]+),/ ) { + my $day = $1; + my $id = $2; + my $cluster = $3; + my $jobId = $4; + my $user = $5; + + if ( $cluster eq 'woody' && $day eq $Tday ) { + $startedJob{$id} = { + 'day' => $day, + 'cluster' => $cluster, + 'jobId' => $jobId, + 'user' => $user + }; + } + } + if ( /Oct ([0-9]+) .*archiving job... \(dbid: ([0-9]+)\): cluster=([a-z]+), jobId=([0-9]+), user=([a-z0-9]+),/ ) { + my $day = $1; + my $id = $2; + my $cluster = $3; + my $jobId = $4; + my $user = $5; + + if ( $cluster eq 'woody' ) { + $stoppedJob{$id} = { + 'day' => $day, + 'cluster' => $cluster, + 'jobId' => $jobId, + 'user' => $user + }; + } + } +} +close FILE; + +my $started = 0; +my $count = 0; +my %users; + +foreach my $key (keys %startedJob) { + $started++; + if ( not exists $stoppedJob{$key} ) { + $count++; + + if ( not exists $users{$startedJob{$key}->{'user'}} ) { + $users{$startedJob{$key}->{'user'}} = 1; + } else { + $users{$startedJob{$key}->{'user'}}++; + } + + print <{'jobId'} User: $startedJob{$key}->{'user'} +====== +END + } +} + +foreach my $key ( keys %users ) { + print "$key => $users{$key}\n"; +} + +print "Not stopped: $count of $started\n";