all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] applied: [PATCH api 1/2] api: node status: return structured info about current kernel
Date: Mon, 26 Feb 2024 16:15:45 +0100	[thread overview]
Message-ID: <20240226151546.2490216-1-t.lamprecht@proxmox.com> (raw)

Makes it easier to show selectively what's important, as the whole
string got quite a bit unwieldy lately.

Mirrors commit 20ad4e0e ("api: nodes: add full info about current
kernel from uname call") from pve-manager.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PMG/API2/Nodes.pm | 41 ++++++++++++++++++++++++++++++++++++++---
 1 file changed, 38 insertions(+), 3 deletions(-)

diff --git a/src/PMG/API2/Nodes.pm b/src/PMG/API2/Nodes.pm
index 873434b..c1a39e1 100644
--- a/src/PMG/API2/Nodes.pm
+++ b/src/PMG/API2/Nodes.pm
@@ -679,6 +679,19 @@ __PACKAGE__->register_method({
 	return undef;
     }});
 
+my sub get_current_kernel_info {
+    my ($sysname, $nodename, $release, $version, $machine) = POSIX::uname();
+
+    my $kernel_version_string = "$sysname $release $version"; # for legacy compat
+    my $current_kernel = {
+	sysname => $sysname,
+	release => $release,
+	version => $version,
+	machine => $machine,
+    };
+    return ($current_kernel, $kernel_version_string);
+}
+
 __PACKAGE__->register_method({
     name => 'status',
     path => 'status',
@@ -711,6 +724,28 @@ __PACKAGE__->register_method({
 		description => "Database is synced with other nodes.",
 		type => 'boolean',
 	    },
+	    'current-kernel' => {
+		description => "Meta-information about the currently booted kernel.",
+		type => 'object',
+		properties => {
+		    sysname => {
+			description => 'OS kernel name (e.g., "Linux")',
+			type => 'string',
+		    },
+		    release => {
+			description => 'OS kernel release (e.g., "6.8.0")',
+			type => 'string',
+		    },
+		    version => {
+			description => 'OS kernel version with build info',
+			type => 'string',
+		    },
+		    machine => {
+			description => 'Hardware (architecture) type',
+			type => 'string',
+		    },
+		},
+	    },
         },
     },
     code => sub {
@@ -737,9 +772,9 @@ __PACKAGE__->register_method({
 	my ($avg1, $avg5, $avg15) = PVE::ProcFSTools::read_loadavg();
 	$res->{loadavg} = [ $avg1, $avg5, $avg15];
 
-	my ($sysname, $nodename, $release, $version, $machine) = POSIX::uname();
-
-	$res->{kversion} = "$sysname $release $version";
+	my ($current_kernel_info, $kversion_string) = get_current_kernel_info();
+	$res->{kversion} = $kversion_string;
+	$res->{'current-kernel'} = $current_kernel_info;
 
 	$res->{cpuinfo} = PVE::ProcFSTools::read_cpuinfo();
 
-- 
2.39.2





             reply	other threads:[~2024-02-26 17:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-26 15:15 Thomas Lamprecht [this message]
2024-02-26 15:15 ` [pmg-devel] applied: [PATCH api 2/2] api: node status: return info about current boot mode Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240226151546.2490216-1-t.lamprecht@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=pmg-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal