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 1B71B61AAB for ; Fri, 10 Jul 2020 10:51:19 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 16D10190EF for ; Fri, 10 Jul 2020 10:51:19 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 id BDC15190DC for ; Fri, 10 Jul 2020 10:51:17 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 8917542F77 for ; Fri, 10 Jul 2020 10:51:17 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Fri, 10 Jul 2020 10:51:12 +0200 Message-Id: <20200710085113.19732-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200710085113.19732-1-d.csapak@proxmox.com> References: <20200710085113.19732-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.000 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods NO_DNS_FOR_FROM 0.379 Envelope sender has no MX or A DNS records RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [status.rs] Subject: [pbs-devel] [PATCH proxmox-backup 2/3] api2/node/status: add fingerprint 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: Fri, 10 Jul 2020 08:51:19 -0000 and rename get_usage to get_status (since its not usage only anymore) Signed-off-by: Dominik Csapak --- src/api2/node/status.rs | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/api2/node/status.rs b/src/api2/node/status.rs index 970c136..14d4b58 100644 --- a/src/api2/node/status.rs +++ b/src/api2/node/status.rs @@ -10,6 +10,7 @@ use proxmox::api::{api, ApiMethod, Router, RpcEnvironment, Permission}; use crate::api2::types::*; use crate::config::acl::{PRIV_SYS_AUDIT, PRIV_SYS_POWER_MANAGEMENT}; +use crate::tools::cert::CertInfo; #[api( input: { @@ -46,14 +47,24 @@ use crate::config::acl::{PRIV_SYS_AUDIT, PRIV_SYS_POWER_MANAGEMENT}; description: "Total CPU usage since last query.", optional: true, }, - } + info: { + type: Object, + description: "contains node information", + properties: { + fingerprint: { + description: "The SSL Fingerprint", + type: String, + }, + }, + }, + }, }, access: { permission: &Permission::Privilege(&["system", "status"], PRIV_SYS_AUDIT, false), }, )] /// Read node memory, CPU and (root) disk usage -fn get_usage( +fn get_status( _param: Value, _info: &ApiMethod, _rpcenv: &mut dyn RpcEnvironment, @@ -63,6 +74,10 @@ fn get_usage( let kstat: procfs::ProcFsStat = procfs::read_proc_stat()?; let disk_usage = crate::tools::disks::disk_usage(Path::new("/"))?; + // get fingerprint + let cert = CertInfo::new()?; + let fp = cert.fingerprint()?; + Ok(json!({ "memory": { "total": meminfo.memtotal, @@ -74,7 +89,10 @@ fn get_usage( "total": disk_usage.total, "used": disk_usage.used, "free": disk_usage.avail, - } + }, + "info": { + "fingerprint": fp, + }, })) } @@ -122,5 +140,5 @@ fn reboot_or_shutdown(command: NodePowerCommand) -> Result<(), Error> { } pub const ROUTER: Router = Router::new() - .get(&API_METHOD_GET_USAGE) + .get(&API_METHOD_GET_STATUS) .post(&API_METHOD_REBOOT_OR_SHUTDOWN); -- 2.20.1