#!/usr/bin/env python import string, sys, commands, getopt, os, re def help(): print "USAGE: " print " check_concat_logs.py -d -f [ ...]" print " options: -d directory where log files are" print " default: /cdf/opr/cdfprod0/ConcatenationLogs" print " -v version of processing" print " -f name of the log file in defined directory" print " -h this help" sys.exit(0) kDirectory = "/cdf/opr/cdfprod0/ConcatenationLogs" kFilenames =[] kVersion = "5.1.1" if len(sys.argv) > 1: program_variab = sys.argv[1:] else: help() try: list, arglist = getopt.getopt(program_variab,'d:f:v:h') except getopt.error,reason: print reason help() for item in list: if item[0] =='-d': kDirectory = item[1] if item[0] =='-f': kFilenames.append(item[1]) if item[0] =='-v': kVersion = item[1] if item[0] =='-h': help() if arglist !=[]: for item in arglist: kFilenames.append(item) print "looking in directory: "+kDirectory print "checking file(s): "+str(kFilenames) for file in kFilenames: kNumErrS = 0 kNumErrA = 0 kNumErrE = 0 kNumErrW = 0 print "FILE: "+file print "----------------------------------" longFilename = os.path.join(kDirectory,file) if os.path.exists(longFilename): fileLines = open(longFilename,'r').readlines() else: print "file "+longFilename+" does NOT exists" continue i=0 concatFilenames=[] for line in fileLines: i=i+1 #check attempt write multiple times into database the same file #if string.find(line,'ORA-') > -1: # kNumErrS = kNumErrS + 1 # os.system("echo Error ORA in "+file+" LINE: \""+line+"\" >> /tmp/mail_errors.txt ") #look for standart errolog ERROR-[ASE] line_lowercase=string.lower(line) if (string.find(line_lowercase,'erlog-s') > -1 and string.find(line_lowercase,'framework abortjob') == -1 and string.find(line_lowercase,'plugstripmaker') == -1 and string.find(line_lowercase,'plugstripclustermaker') == -1 and string.find(line_lowercase,'fluffed') == -1): kNumErrS = kNumErrS + 1 os.system("echo erlog-s in "+file+" LINE: \""+line+"\" >> /tmp/mail_errors.txt ") if string.find(line_lowercase,'erlog-w') > -1: kNumErrW = kNumErrW + 1 if string.find(line_lowercase,'erlog-a') > -1: kNumErrA = kNumErrA + 1 if string.find(line_lowercase,'erlog-e') > -1: kNumErrE = kNumErrE + 1 result = re.match('.*found.*for[ \t]*(.*)',string.strip(line)) if result: concatFilenames.append(result.groups()[0]) if ( kNumErrS or kNumErrA or kNumErrE ): print "ERLOGS: -S: "+str(kNumErrS)+" -A: "+str(kNumErrA) \ +" -E: "+str(kNumErrE)+" -W: "+str(kNumErrW) sys.exit(0)