system: add kern.boot_id to sysctl values and output (#11279)

This commit is contained in:
Konstantinos Spartalis authored and GitHub committed 2026-12-01 13:50:54 +01:00
1 parent 7aa1f99463
commit a7f4972b65
2 files changed
+7 -3

No files matched your search

@@ -132,7 +132,7 @@ class SystemController extends ApiControllerBase
public function systemTimeAction()
{
$config = Config::getInstance()->object();
$boottime = json_decode((new Backend())->configdRun('system sysctl values kern.boottime,vm.loadavg'), true);
$boottime = json_decode((new Backend())->configdRun('system sysctl values kern.boottime,kern.boot_id,vm.loadavg'), true);
preg_match("/sec = (\d+)/", $boottime['kern.boottime'], $matches);
$last_change = date("D M j G:i:s T Y", !empty($config->revision->time) ? intval($config->revision->time) : 0);
@@ -147,6 +147,7 @@ class SystemController extends ApiControllerBase
'uptime' => $this->formatUptime(time() - $matches[1]),
'datetime' => date("D M j G:i:s T Y"),
'boottime' => date("D M j G:i:s T Y", $matches[1]),
'bootid' => $boottime['kern.boot_id'] ?? gettext('N/A'),
'config' => $last_change,
'loadavg' => $loadavg,
];
+5 -2
View File
@@ -48,12 +48,15 @@ if __name__ == '__main__':
if inputargs.values:
params = inputargs.values.split(',')
sp = subprocess.run(['/sbin/sysctl', '-i'] + params, capture_output=True, text=True)
sp = subprocess.run(['/sbin/sysctl', '-ix'] + params, capture_output=True, text=True)
for line in sp.stdout.split("\n"):
# include original oid in output so caller can match back
parts = line.strip().split(": ", 1)
if len(parts) > 1:
result[parts[0]] = parts[1].strip()
value = parts[1].strip()
if value.startswith('Format:') and 'Dump:0x' in value:
value = value.split('Dump:0x', 1)[1].strip()
result[parts[0]] = value
output = ujson.dumps(result)
elif inputargs.gather:
sp = subprocess.run(['/sbin/sysctl', '-a'], capture_output=True, text=True)