From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id D0AA29D250 for ; Thu, 23 Nov 2023 14:10:10 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B9FC237A07 for ; Thu, 23 Nov 2023 14:09:40 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 23 Nov 2023 14:09:40 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 0EE9E42F2C for ; Thu, 23 Nov 2023 14:09:40 +0100 (CET) From: Gabriel Goller To: pbs-devel@lists.proxmox.com Date: Thu, 23 Nov 2023 14:09:35 +0100 Message-Id: <20231123130935.207013-3-g.goller@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231123130935.207013-1-g.goller@proxmox.com> References: <20231123130935.207013-1-g.goller@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.240 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [PATCH proxmox-backup 2/2] node: status: declutter kernel-version X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Nov 2023 13:10:10 -0000 Return a struct with all the components of the kernel version like it has been done in pve. Extract and display the build version and kernel release nicely. Signed-off-by: Gabriel Goller --- pbs-api-types/src/node.rs | 16 +++++++++++++++- src/api2/node/status.rs | 17 ++++++++--------- www/panel/NodeInfo.js | 4 ++++ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/pbs-api-types/src/node.rs b/pbs-api-types/src/node.rs index 6d1fa7f0..5963658a 100644 --- a/pbs-api-types/src/node.rs +++ b/pbs-api-types/src/node.rs @@ -38,6 +38,20 @@ pub struct NodeInformation { pub fingerprint: String, } +#[api] +#[derive(Serialize, Deserialize, Default)] +#[serde(rename_all = "lowercase")] +/// The current kernel version (output of `uname`) +pub struct KernelVersionInformation { + /// The systemname/nodename + pub sysname: String, + /// The kernel release number + pub release: String, + /// The kernel version + pub version: String, + /// The machine architecture + pub machine: String, +} #[api] #[derive(Serialize, Deserialize, Default)] @@ -104,7 +118,7 @@ pub struct NodeStatus { /// Load for 1, 5 and 15 minutes. pub loadavg: [f64; 3], /// The current kernel version. - pub kversion: String, + pub kversion: KernelVersionInformation, /// Total CPU usage since last query. pub cpu: f64, /// Total IO wait since last query. diff --git a/src/api2/node/status.rs b/src/api2/node/status.rs index 1b3b9e33..fae2b49b 100644 --- a/src/api2/node/status.rs +++ b/src/api2/node/status.rs @@ -1,6 +1,5 @@ use std::fs::File; use std::io::Read; -use std::os::unix::prelude::OsStrExt; use std::path::Path; use std::process::Command; @@ -13,8 +12,8 @@ use proxmox_router::{ApiMethod, Permission, Router, RpcEnvironment}; use proxmox_schema::api; use pbs_api_types::{ - BootModeInformation, NodePowerCommand, StorageStatus, NODE_SCHEMA, PRIV_SYS_AUDIT, - PRIV_SYS_POWER_MANAGEMENT, + BootModeInformation, KernelVersionInformation, NodePowerCommand, StorageStatus, NODE_SCHEMA, + PRIV_SYS_AUDIT, PRIV_SYS_POWER_MANAGEMENT, }; use pbs_api_types::{ @@ -74,12 +73,12 @@ async fn get_status( let cpuinfo = procfs_to_node_cpu_info(cpuinfo); let uname = nix::sys::utsname::uname()?; - let kversion = format!( - "{} {} {}", - std::str::from_utf8(uname.sysname().as_bytes())?, - std::str::from_utf8(uname.release().as_bytes())?, - std::str::from_utf8(uname.version().as_bytes())? - ); + let kversion = KernelVersionInformation { + sysname: uname.sysname().to_os_string().into_string().unwrap(), + release: uname.release().to_os_string().into_string().unwrap(), + version: uname.version().to_os_string().into_string().unwrap(), + machine: uname.machine().to_os_string().into_string().unwrap(), + }; let disk = crate::tools::fs::fs_info_static(proxmox_lang::c_str!("/")).await?; diff --git a/www/panel/NodeInfo.js b/www/panel/NodeInfo.js index 14f84a2e..25927ebc 100644 --- a/www/panel/NodeInfo.js +++ b/www/panel/NodeInfo.js @@ -145,6 +145,10 @@ Ext.define('PBS.NodeInfoPanel', { title: gettext('Kernel Version'), printBar: false, textField: 'kversion', + renderer: (kernel) => { + let buildDate = kernel.version.match(/\((.+)\)\s*$/)[1] ?? 'unknown'; + return `${kernel.sysname} ${kernel.release} (${buildDate})`; + }, value: '', }, { -- 2.39.2