Saturday, August 18, 2018

python program to check ocssd.log in oracle 11g for node eviction / issues

# python program to check ocssd.log in oracle 11g for node eviction / issues

# customize name/location of ocssd file: it has changed in 12g
infile = r'/ora01/grid/11.2.0.4/grid/log/`hostname`/cssd/ocssd.log'

important = []
keep_phrases = ["Diskpingout",
              "CRS-1013",
              "Polling"]

with open(infile) as f:
    f = f.readlines()

for line in f:
    for phrase in keep_phrases:
        if phrase in line:
            # important.append(line.rstrip('\n'))
            important.append([line.rstrip('\n')])
# OutputList.append([EventDate,line.rstrip('\n')])
            break

# print(important)
print infile
for o in important:
    # use o[0].strftime('%a %b %d %H:%M:%S %Y') to get original Oracle style Format
    # print('[%s] %s' % (o[0],o[1]))
    print('[%s]' % (o[0]))