Skip to content
Snippets Groups Projects
Commit ed39e18d authored by abeche's avatar abeche
Browse files

Fix check_gridftp_transfer to follow the thread

parent 707b3ad4
No related branches found
No related tags found
No related merge requests found
......@@ -99,9 +99,12 @@ class check_gridftp_transfer:
transfer_failed_before_starting = 0
# Pattern to parse the logfile
endtrans_pattern = re.compile("^\[\d*\] (.*) :: Closed connection")
begtrans_pattern = re.compile("Server started")
return_pattern = re.compile("^\[\d*\] (.*) :: .* \[SERVER\]\: (\d*) ")
endtrans_pattern = re.compile("^\[(\d*)\] (.*) :: Closed connection")
begtrans_pattern = re.compile("^\[(\d*)\] (.*) :: Server started")
return_pattern = re.compile("^\[(\d*)\] (.*) :: .* \[SERVER\]\: (\d*) ")
# Flags for each thread (transfer_start and error)
thread_infos = {}
# Open the file and parse it in reverse order
gridftp = open(self.log, "r")
......@@ -112,12 +115,15 @@ class check_gridftp_transfer:
# End transfer detected
if found_end:
thread_id = int(found_end.group(1))
thread_infos[thread_id] = {"transfer_start":0, "error":0}
# Set the error and transfer flags to 0
transfer_start, error = 0, 0
# Stop the probes if the wanted interval is finished
try:
dt = strptime(found_end.group(1).strip(), "%a %b %d %X %Y")
dt = strptime(found_end.group(2).strip(), "%a %b %d %X %Y")
if int(mktime(gmtime()) - mktime(dt)) > (self.interval * 60):
break
except:
......@@ -125,23 +131,34 @@ class check_gridftp_transfer:
# Standard return detected
elif found_pattern:
thread_id = int(found_pattern.group(1))
if thread_id not in thread_infos:
continue
# Error code detected
code = found_pattern.group(2)
code = found_pattern.group(3)
if (int(code) > 399) and (int(code) < 555):
error = 1
thread_infos[thread_id]["error"] = 1
# Transfer starting detected
elif int(code) == 150:
transfer_start = 1
thread_infos[thread_id]["transfer_start"] = 1
# Transfert starting pattern
elif found_start:
if (transfer_start == 1) and (error == 0):
thread_id = int(found_start.group(1))
if thread_id not in thread_infos:
continue
if (thread_infos[thread_id]["transfer_start"] == 1) and (thread_infos[thread_id]["error"] == 0):
transfer_succeed += 1
elif (transfer_start == 1) and (error == 1):
elif (thread_infos[thread_id]["transfer_start"] == 1) and (thread_infos[thread_id]["error"] == 1):
transfer_start_then_failed += 1
elif (transfer_start == 0) and (error == 1):
elif (thread_infos[thread_id]["transfer_start"] == 0) and (thread_infos[thread_id]["error"] == 1):
transfer_failed_before_starting += 1
# Remove the transfer infos from the list
del thread_infos[thread_id]
return transfer_succeed, transfer_start_then_failed, transfer_failed_before_starting
def main(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment