Megatest

triage.rb at [f012b3cc77]
Login

File utils/triage.rb artifact 54791236c4 part of check-in f012b3cc77


#!/usr/bin/env ruby

#  Copyright 2006-2017, Matthew Welland.
# 
# This file is part of Megatest.
# 
#     Megatest is free software: you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation, either version 3 of the License, or
#     (at your option) any later version.
# 
#     Megatest is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
# 
#     You should have received a copy of the GNU General Public License
#     along with Megatest.  If not, see <http://www.gnu.org/licenses/>.

#dir = "."
#if ARGV.length == 1
#  dir = ARGV[0]
#end
#puts dir
#exit 1

allfiles = []
server_logs = `find logs/ -type f -name 'server*.log' 2>/dev/null`.split /\n/
allfiles += server_logs
ARGV.each{|dir|
  nbfiles = `find #{dir} -type f -name '##*' 2>/dev/null`.split /\n/
  fakefiles = `find #{dir} -type f -name 'NBFAKE-*' 2>/dev/null`.split /\n/
  allfiles = allfiles + nbfiles + fakefiles
}

buckets = Hash.new{|h,k| h[k]=[]}
#;buckets['OK'] = []
#;buckets['stackdump'] = []


sig_patterns = [
                'cannot create directory - File exists',
                'in thread: \(finalize!\) bad argument type - not a database or statement: #<unspecified>',
                'cannot delete file - No such file or directory: .*\/.runconfig.',
                'Error: \(hash-table-ref/default\) bad argument type - not a structure of the required type',
                '\(#<thread: Watchdog thread>\): in thread: \(open-output-file\) cannot open file - File exists:',
                'http-transport.scm:442: posix-extras#change-file-times',
                'thread: \(file-exists\?\) system error while trying to access file:',
                'error: database is locked',
                'Finalizing failed, unable to close due to unfinalized statements or unfinished backups',
                'rmt.scm:276: current-milliseconds',
                'http-transport.scm:366: exit',
                'should never happen',
                'FATAL: \*configdat\* was inaccessible! This should never happen.',
                'FATAL ERROR: http-transport:client-api-send-receive called with no server info',
                '!!ISOENV PRESENT!!'

           ]

allfiles.each{|logfile|
  bucket = 'OK'
  open(logfile){|fh|
    fh.each{|line|

      if line.match(/Call history/)
        if bucket == 'OK'
          bucket='??'
        end
      end
      sig_patterns.each_with_index{|pat,bucket_name|
        #bucket_name,pat = i
        if line.match(/#{pat}/)
          bucket=bucket_name
        end
      }
        
    }
  }
  buckets[bucket] << logfile
}

puts "count\tsignature\texample file"
buckets.keys.each{|bucket|
  count = buckets[bucket].length

  example = buckets[bucket][0]
  if example
    puts "#{count}\tsignature-#{bucket}\t#{example}"
    if bucket.to_s.match(/^[0-9]+$/)
      puts "                   `- pattern = /#{sig_patterns[bucket]}/"
    end
  else
    puts "#{count}\tsignature-#{bucket}"
  end
}
#puts buckets['stackdump'][0]