diff --git a/AirlockTools.py b/AirlockTools.py index 14dee05..fca4c2d 100644 --- a/AirlockTools.py +++ b/AirlockTools.py @@ -53,12 +53,14 @@ def main(): if args.monitorOTP: # Non-interactive logic - if not os.path.exists("scheduling"): os.makedirs("scheduling") - if not os.path.exists("OTP"): os.makedirs("OTP") - if not os.path.exists("OTP\\HTML"): os.mkdir("OTP\\HTML") - if not os.path.exists("OTP\\PARQ"): os.mkdir("OTP\\PARQ") - apivalidation() print(f"Running non-interactively to start monitoring OTP") + + os.makedirs("scheduling", exist_ok=True) + os.makedirs("OTP/HTML", exist_ok=True) + os.makedirs("OTP/PARQ", exist_ok=True) + + apivalidation() + register_function("monitorOTP", utils.otpfunctions.monitorOTP) if not os.path.exists("scheduling\\jobs.json"): recurring_job("monitor", "monitorOTP", interval=60, unit="seconds", args=[url]) diff --git a/scheduling/jobs.json b/scheduling/jobs.json deleted file mode 100644 index e75d055..0000000 --- a/scheduling/jobs.json +++ /dev/null @@ -1,13 +0,0 @@ -[ - { - "id": "monitor", - "type": "recurring", - "interval": 10, - "unit": "seconds", - "function": "monitorOTP", - "args": [ - "https://172.17.22.240:3129" - ], - "kwargs": {} - } -] \ No newline at end of file diff --git a/utils/otpfunctions.py b/utils/otpfunctions.py index d4776ee..a14d3b4 100644 --- a/utils/otpfunctions.py +++ b/utils/otpfunctions.py @@ -85,8 +85,8 @@ def monitorOTP(url, pups): pid = row['otpid'] early = math.floor(duration * .9) - run_once_job(f"Add activity hashes for {pid}, for {hostname} for the purpose: {purpose}", "addhash", time.time() + early, args=[url, clientid, pid, pups]) - run_once_job(f"Add activity hashes for {pid}, for {hostname} for the purpose: {purpose}", "addhash", time.time() + duration, args=[url, clientid, pid, pups]) + run_once_job(f"Add activity hashes for {pid}, for {hostname} for the purpose: {purpose}, early run", "addhash", time.time() + early, args=[url, clientid, pid, pups]) + run_once_job(f"Add activity hashes for {pid}, for {hostname} for the purpose: {purpose}, duration complete run", "addhash", time.time() + duration, args=[url, clientid, pid, pups]) print(f"Processing: {pid} with other data: {row}")