Event Log Errors Email Script

Posted on
Sun Mar 25, 2018 4:12 pm
GRWilde offline
User avatar
Posts: 156
Joined: Nov 15, 2005
Location: Los Angeles

Event Log Errors Email Script

Event Log errors occur frequently throughout the day (most are not very consequential), but it is difficult to browse through the daily Event Log to find all of those errors to determine if any are really important. I modified a very simple python script I found to do this for me. I schedule the script to execute just before midnight every day to get a daily summary of all of my Event Log errors. Actually you could schedule execution of the script at any time you desire, or manually execute it in an Action Group. The script can be embedded because it should execute in well under 10 seconds. I have also frequently modified the script to look for events other than 'Error' when I am investigating other issues. The following is the script (just put in your appropriate email address):

Code: Select all
import os
from datetime import date

baseDir = '/Library/Application Support/Perceptive Automation/Indigo 7/Logs'
tmpFileName = os.path.join(baseDir, 'tmp.txt')

fileDate = str(date.today())
eventFileName = os.path.join(baseDir, fileDate + ' Events.txt')

theBody = ''

with open(tmpFileName, 'a') as tmpFile:
    with open( eventFileName, 'r' ) as log:
        for line in log:
            if 'Error' in line:
               tmpFile.write(line)
               theBody += line

# theBody is the body of  an email which is sent next
print theBody

theSubject = "Indigo Event Log Errors"
indigo.server.sendEmailTo("emailAddress", subject=theSubject, body=theBody)
Last edited by GRWilde on Sun Mar 25, 2018 4:47 pm, edited 1 time in total.

George Wilde

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 0 guests