From fdf782bc2f0c4d23837e22dd0492bbd56b8b21bf Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Sat, 7 Jan 2023 13:08:44 +0100 Subject: [PATCH] Rename ltsdb_report.send_report to ltsdb_record.record_observations --- clients/{ltsdb_report.py => ltsdb_record.py} | 8 ++++---- clients/record_https | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) rename clients/{ltsdb_report.py => ltsdb_record.py} (85%) diff --git a/clients/ltsdb_report.py b/clients/ltsdb_record.py similarity index 85% rename from clients/ltsdb_report.py rename to clients/ltsdb_record.py index 09b8057..0ac8770 100644 --- a/clients/ltsdb_report.py +++ b/clients/ltsdb_record.py @@ -7,7 +7,7 @@ import time import requests -def send_report(report): +def record_observations(observations): node = socket.gethostbyaddr(socket.gethostname())[0] for dir in (".", os.environ["HOME"] + "/.config/ltsdb", "/etc/ltsdb"): try: @@ -18,16 +18,16 @@ def send_report(report): except FileNotFoundError: pass while True: - for r in report: + for obs in observations: timestamp = time.time() msg = (node + " " + str(timestamp)).encode("UTF-8") digest = hmac.new(client_config["key"].encode("UTF-8"), msg, "SHA256").hexdigest() - r["auth"] = { + obs["auth"] = { "node": node, "timestamp": timestamp, "hmac": digest, } - r = requests.post(baseurl + "report", json=report) + r = requests.post(baseurl + "record", json=observations) print(r) if r.status_code == 200: return True diff --git a/clients/record_https b/clients/record_https index 310b6d8..ece9e53 100755 --- a/clients/record_https +++ b/clients/record_https @@ -14,7 +14,7 @@ import urllib.parse import requests -import ltsdb_report +import ltsdb_record ap = argparse.ArgumentParser() ap.add_argument("url") @@ -57,6 +57,6 @@ report = [ for r in report0 ] -success = ltsdb_report.send_report(report) +success = ltsdb_record.record_observations(report) exit(1 - success)