Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions ansible/roles/test/files/tools/loganalyzer/loganalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ def init_sys_logger(self):
return logger
#---------------------------------------------------------------------

def __init__(self, run_id, verbose):
def __init__(self, run_id, verbose, start_marker = None):
self.run_id = run_id
self.verbose = verbose
self.start_marker = start_marker
#---------------------------------------------------------------------

def print_diagnostic_message(self, message):
Expand All @@ -92,7 +93,10 @@ def print_diagnostic_message(self, message):
#---------------------------------------------------------------------

def create_start_marker(self):
return self.start_marker_prefix + "-" + self.run_id
if (self.start_marker is None) or (len(self.start_marker) == 0):
return self.start_marker_prefix + "-" + self.run_id
else:
return self.start_marker

#---------------------------------------------------------------------

Expand Down Expand Up @@ -576,6 +580,7 @@ def main(argv):

action = None
run_id = None
start_marker = None
log_files_in = ""
out_dir = None
match_files_in = None
Expand All @@ -584,7 +589,7 @@ def main(argv):
verbose = False

try:
opts, args = getopt.getopt(argv, "a:r:l:o:m:i:e:vh", ["action=", "run_id=", "logs=", "out_dir=", "match_files_in=", "ignore_files_in=", "expect_files_in=", "verbose", "help"])
opts, args = getopt.getopt(argv, "a:r:s:l:o:m:i:e:vh", ["action=", "run_id=", "start_marker=", "logs=", "out_dir=", "match_files_in=", "ignore_files_in=", "expect_files_in=", "verbose", "help"])

except getopt.GetoptError:
print "Invalid option specified"
Expand All @@ -602,6 +607,9 @@ def main(argv):
elif (opt in ("-r", "--run_id")):
run_id = arg

elif (opt in ("-s", "--start_marker")):
start_marker = arg

elif (opt in ("-l", "--logs")):
log_files_in = arg

Expand All @@ -624,7 +632,7 @@ def main(argv):
usage()
sys.exit(err_invalid_input)

analyzer = AnsibleLogAnalyzer(run_id, verbose)
analyzer = AnsibleLogAnalyzer(run_id, verbose, start_marker)

log_file_list = filter(None, log_files_in.split(tokenizer))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
extract_log:
directory: '/var/log'
file_prefix: 'syslog'
start_string: 'start-LogAnalyzer-{{ testname_unique }}'
start_string: "{% if start_marker is defined %}{{ start_marker }}{% else %}start-LogAnalyzer-{{ testname_unique }}{% endif %}"
target_filename: "/tmp/syslog"
become: yes

Expand All @@ -122,7 +122,7 @@
shell: sed -i 's/^#//g' /etc/cron.d/logrotate
become: yes

- set_fact: cmd="python {{ run_dir }}/loganalyzer.py --action analyze --logs {{ tmp_log_file }} --run_id {{ testname_unique }} --out_dir {{ test_out_dir }} {{ match_file_option }} {{ ignore_file_option }} {{ expect_file_option }} -v"
- set_fact: cmd="python {{ run_dir }}/loganalyzer.py --action analyze --logs {{ tmp_log_file }} --run_id {{ testname_unique }} {% if start_marker is defined %}--start_marker '{{ start_marker }}'{% endif %} --out_dir {{ test_out_dir }} {{ match_file_option }} {{ ignore_file_option }} {{ expect_file_option }} -v"

- debug: msg={{cmd}}

Expand Down