From 1a8ccd6fbe9bd960ab9eaf80b049a2576f44a594 Mon Sep 17 00:00:00 2001 From: vitrinekast Date: Wed, 13 Mar 2024 18:02:19 +0000 Subject: [PATCH] add grab-data.py --- grab-data.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 grab-data.py diff --git a/grab-data.py b/grab-data.py new file mode 100644 index 0000000..fa9ae1a --- /dev/null +++ b/grab-data.py @@ -0,0 +1,18 @@ +import json +import subprocess +from datetime import datetime + +## creating the JSON + +## grabbing the logged in users since yesterday +last_here = subprocess.run(["last", "-s", "today"], capture_output=True) +logged_in_today = subprocess.run(["sudo journalctl -S yesterday _COMM=systemd-logind -o json"], capture_output=True) +output = json.loads(last_here) + +print(output) + +today = datetime.today().strftime('%Y-%m-%d-%H:%M:%S') + +with open("data_" + today + ".json", 'w') as f: + print(output, file = f) +