From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id CE8821FF0B3 for ; Thu, 26 Nov 2026 14:43:36 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id F27782186B; Thu, 26 Nov 2026 14:42:36 +0100 (CET) From: Jonas Theisen To: pve-devel@lists.proxmox.com Subject: [PATCH manager 13/16] api: nodes: time: report clock synchronization status Date: Thu, 26 Nov 2026 14:40:10 +0100 Message-ID: <20261126134128.316681-14-j.theisen@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261126134128.316681-1-j.theisen@proxmox.com> References: <20261126134128.316681-1-j.theisen@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795700525408 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.067 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) 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_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: IG7AXI4UO5A5J3CEO5OQEQJKKVKYUQ6S X-Message-ID-Hash: IG7AXI4UO5A5J3CEO5OQEQJKKVKYUQ6S X-MailFrom: j.theisen@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Return whether the system clock is synchronized, so admins can check that a node's time synchronization works without logging in to the shell, for example after changing the NTP servers. If the status cannot be queried, for example because timedatectl fails, it is left out and only a warning is logged, so reading the time zone and NTP settings keeps working. Signed-off-by: Jonas Theisen --- Notes: This depends on the clock synchronization helper in PVE::Systemd from pve-common. PVE/API2/Nodes.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm index c7d8b139..819114c5 100644 --- a/PVE/API2/Nodes.pm +++ b/PVE/API2/Nodes.pm @@ -1756,6 +1756,13 @@ __PACKAGE__->register_method({ type => 'boolean', optional => 1, }, + 'ntp-synchronized' => { + description => "Whether the system clock is synchronized, independent of the" + . " time synchronization service in use. Not set if the status cannot be" + . " determined.", + type => 'boolean', + optional => 1, + }, time => { description => "Seconds since 1970-01-01 00:00:00 UTC.", type => 'integer', @@ -1781,6 +1788,14 @@ __PACKAGE__->register_method({ localtime => $ltime, }; + # failing to query the status must not prevent reading the time zone and NTP settings + my $synchronized = eval { PVE::Systemd::is_clock_synchronized() }; + if (my $err = $@) { + warn "unable to get clock synchronization status - $err"; + } else { + $res->{'ntp-synchronized'} = $synchronized; + } + if (my $service = PVE::Systemd::get_ntp_service()) { $res->{'ntp-service'} = $service; $res->{'ntp-pools-supported'} = PVE::Systemd::is_ntp_pools_supported($service); -- 2.47.3