| | |
- SASummary
class SASummary |
| |
A class to summarize some interesting information found in
the MTA log file.
The values of variables that contain CAPS should be modified by the user
before this script is run. For example:
self.LOG_FILE_DIR = "/var/log/exim4"
should be modified to point to the directory in which you keep your log
files.
DAYS_COUNT The number of days previous to the current day
that should be included in the search. For
example, DAYS_COUNT=1 means yesterday,
DAYS_COUNT=2 means yesterday and the day before
yesterday.
MAILTO A Python tuple of email addresses to which the
script output is mailed. This is only used when
this file is run from the command line. (see the
if __name__ == '__main__':
code at the bottom of the mta_summary.py file for
details)
DATE_FORMAT A format string that makes dates look pretty
(http://www.egenix.com/files/python/mxDateTime.html)
LOG_FILE_DIR A path to the directory in which you keep your
log files
MAIN_LOG_FILE The name of the main log file to be searched.
This file name will be appended to LOG_FILE_DIR
REJECT_LOG_FILE The name of the reject log file to be searched.
This file name will be appended to LOG_FILE_DIR
LINE_COUNT The system command used to count lines
SEARCH_EXE A format string containing the system command used
to find log file lines referring to executable
attachments that were blocked
COUNT_EXE A format string containing the system command used
to count log file lines referring to executable
attachments that were blocked. This is typically
the SEARCH command piped into the LINE_COUNT command
SEARCH_VIRII A format string containing the system command used
to find log file lines referring to virus
attachments that were blocked
COUNT_VIRII A format string containing the system command used
to count log file lines referring to virus
attachments that were blocked. This is typically
the SEARCH command piped into the LINE_COUNT command |
| |
Methods defined here:
- __init__(self, days_count=1)
- Initialize some flags and constants.
- formatExeLines(self, lines)
- A helper method to format lines relating to blocked executable files.
- formatLines(self, lines, split_one, split_two)
- A generic log file line formatting method.
lines A list of log file lines
split_one A string on which to split each log file line
split_two A string on which to split the second item of the
results of the first split
For example, if lines contains:
["2004-03-02 02:19:50 1Ay708-00022w-RN H=localhost [127.0.0.1] U=fetchmail F=<cipytyhjsxglhw@newsletters.microsoft.net> rejected after DATA: This message contains an attachment of a type which we do not accept (.exe)"]
and split_one is
"F="
and split_two is
"rejected after DATA: This message contains an attachment of a type which we do not accept"
then the first split results in a list containing:
["2004-03-02 02:19:50 1Ay708-00022w-RN H=localhost [127.0.0.1] U=fetchmail,
"<cipytyhjsxglhw@newsletters.microsoft.net> rejected after DATA: This message contains an attachment of a type which we do not accept (.exe)"]
The second split will work on the second element in that list
(<cipy...), and results in a list containing:
["<cipytyhjsxglhw@newsletters.microsoft.net>",
" (.exe)"]
The return value contains those two list elements joined together
followed by a newline character:
"<cipytyhjsxglhw@newsletters.microsoft.net> (.exe)\n"
- formatVirusLines(self, lines)
- A helper method to format lines relating to blocked virii.
- getBlockedExecutables(self)
- Returns a string containing a sub-summary of blocked executable
files. The sub-summary includes the email address from which the email
was sent and the type of file blocked.
- getBlockedVirii(self)
- Returns a string containing a sub-summary of blocked virii. The
sub-summary includes the email address from which the email was sent
and the type of virus that was blocked.
- setFilterDates(self)
- Sets the filter_dates flag by creating a list of days previous to
today. That list is then used in the self.SEARCH* commands.
- showAll(self)
- Returns a string containing all the configured sub-summaries (the
entire summary)
| |