minor fix
This commit is contained in:
1 parent
fd11784744
commit
99ca593c06
2 files changed
+6
-5
No files matched your search
+5
-3
@@ -74,10 +74,11 @@ def grep_all_ips(ips, cmd, if_unit_test):
|
|||||||
|
|
||||||
#main
|
#main
|
||||||
#if unit test flag exists, then use the test log files instead of the actual log files
|
#if unit test flag exists, then use the test log files instead of the actual log files
|
||||||
cmd = ["grep ", *[arg for arg in sys.argv[1:] if arg != "-t"]]
|
cmd = ["grep", *[arg for arg in sys.argv[1:] if arg != "-t"]]
|
||||||
#track time
|
#track time
|
||||||
start_time = time.perf_counter()
|
start_time = time.perf_counter()
|
||||||
match_count = grep_all_ips(ALL_IPS, cmd, if_unit_test=[x for x in sys.argv].count("-t") > 0)
|
is_unit_test = "-t" in sys.argv
|
||||||
|
match_count = grep_all_ips(ALL_IPS, cmd, if_unit_test=is_unit_test)
|
||||||
end_time = time.perf_counter()
|
end_time = time.perf_counter()
|
||||||
|
|
||||||
print("=========================== SUMMARY ===========================")
|
print("=========================== SUMMARY ===========================")
|
||||||
@@ -92,6 +93,7 @@ for i, count in enumerate(match_count):
|
|||||||
print(f"machine.{i + 1}.test.log: {count} matches")
|
print(f"machine.{i + 1}.test.log: {count} matches")
|
||||||
else:
|
else:
|
||||||
print(f"machine.{i + 1}.log: {count} matches")
|
print(f"machine.{i + 1}.log: {count} matches")
|
||||||
print(f"Total matches: {max(0, sum(match_count))}")
|
total_matches = sum(count for count in match_count if count > 0)
|
||||||
|
print(f"Total matches: {total_matches}")
|
||||||
print("===============================================================")
|
print("===============================================================")
|
||||||
print(f"Time taken: {end_time - start_time:.2f} seconds")
|
print(f"Time taken: {end_time - start_time:.2f} seconds")
|
||||||
+1
-2
@@ -59,8 +59,7 @@ while True:
|
|||||||
send_message(conn, result.stdout + result.stderr)
|
send_message(conn, result.stdout + result.stderr)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error_message = f"Error executing command: {e}"
|
None
|
||||||
send_message(conn, error_message)
|
|
||||||
finally:
|
finally:
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user