Fix uptime (#207)

* fix uptime
This commit is contained in:
Masoko
2025-03-27 22:18:17 +02:00
committed by GitHub
parent 182b431c8e
commit 5478f50783

View File

@@ -209,9 +209,11 @@ def check_sys_clock_speed():
def check_uptime(format):
if format == 'timestamp':
full_cmd = "uptime -s"
tz_cmd = "date +%z"
tz_str = subprocess.Popen(tz_cmd, shell=True, stdout=subprocess.PIPE).communicate()[0].decode('utf-8').strip()
timestamp_str = subprocess.Popen(full_cmd, shell=True, stdout=subprocess.PIPE).communicate()[0].decode('utf-8').strip()
timestamp = datetime.strptime(timestamp_str, '%Y-%m-%d %H:%M:%S')
iso_timestamp = timestamp.isoformat() + 'Z' # Append 'Z' to indicate UTC time
iso_timestamp = timestamp.isoformat() + tz_str # Append correct offset to indicate `local` time
return iso_timestamp
else:
full_cmd = "awk '{print int($1"+format+")}' /proc/uptime"