Rename ltsdb_report.send_report to ltsdb_record.record_observations
This commit is contained in:
parent
a83ebfcc99
commit
fdf782bc2f
|
@ -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
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue