From: Jonas Theisen <j.theisen@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH widget-toolkit 11/16] node: time: add window listing the current NTP sources
Date: Thu, 26 Nov 2026 14:40:08 +0100 [thread overview]
Message-ID: <20261126134128.316681-12-j.theisen@proxmox.com> (raw)
In-Reply-To: <20261126134128.316681-1-j.theisen@proxmox.com>
Add a "Sources" button to the time view that opens a window listing
the sources the time synchronization service currently uses, including
the members of pools, with their selection state, stratum, polling
interval, reachability, age of the last sample and offset. This helps
to find out why the clock is not synchronized, or how far off a node
is compared to its sources. Double clicking the clock synchronization
row opens the window as well.
The list refreshes every five seconds while the window is open. The
button and the row action are only available if the API reports that
the active service supports listing its sources, which also keeps them
hidden for products whose time API does not provide it.
Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
src/Makefile | 1 +
src/node/TimeView.js | 32 +++++++-
src/window/NTPSources.js | 155 +++++++++++++++++++++++++++++++++++++++
3 files changed, 185 insertions(+), 3 deletions(-)
create mode 100644 src/window/NTPSources.js
diff --git a/src/Makefile b/src/Makefile
index 24bd719..72bac69 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -91,6 +91,7 @@ JSSRC= \
window/PackageVersions.js \
window/PackageChangelog.js \
window/ServiceLog.js \
+ window/NTPSources.js \
window/TaskViewer.js \
window/LanguageEdit.js \
window/DiskSmart.js \
diff --git a/src/node/TimeView.js b/src/node/TimeView.js
index 0c08e31..ecae553 100644
--- a/src/node/TimeView.js
+++ b/src/node/TimeView.js
@@ -37,13 +37,26 @@ Ext.define('Proxmox.node.TimeView', {
autoShow: true,
});
- // double click or enter on the NTP service row shows its log instead of the editor, the rows
- // with read-only status information have no action
+ let sources_supported = () => !!me.rstore.getById('ntp-sources-supported')?.data.value;
+
+ let view_sources = () =>
+ Ext.create('Proxmox.window.NTPSources', {
+ nodename: me.nodename,
+ autoShow: true,
+ });
+
+ // Double click or enter on the NTP service row shows its log instead of the editor, and on
+ // the clock synchronization row the sources it is synchronized to, if supported. The rows
+ // with read-only status information have no action otherwise.
let run_row_action = () => {
let key = me.getSelectionModel().getSelection()[0]?.data.key;
if (key === 'ntp-service') {
view_service_log();
- } else if (key !== 'localtime' && key !== 'ntp-synchronized') {
+ } else if (key === 'ntp-synchronized') {
+ if (sources_supported()) {
+ view_sources();
+ }
+ } else if (key !== 'localtime') {
run_editor();
}
};
@@ -156,6 +169,13 @@ Ext.define('Proxmox.node.TimeView', {
handler: confirm_sync,
});
+ // only shown if the API reports that the NTP service supports it
+ let sources_btn = new Ext.Button({
+ text: gettext('Sources'),
+ hidden: true,
+ handler: view_sources,
+ });
+
let rows = {
timezone: {
header: gettext('Time zone'),
@@ -201,6 +221,10 @@ Ext.define('Proxmox.node.TimeView', {
clustered: {
visible: false,
},
+ // same for the sources button
+ 'ntp-sources-supported': {
+ visible: false,
+ },
'ntp-synchronized': {
header: gettext('Clock synchronized'),
renderer: Proxmox.Utils.format_boolean,
@@ -222,6 +246,7 @@ Ext.define('Proxmox.node.TimeView', {
handler: run_editor,
},
sync_btn,
+ sources_btn,
syslog_btn,
],
listeners: {
@@ -240,6 +265,7 @@ Ext.define('Proxmox.node.TimeView', {
me.mon(me.rstore, 'load', () => {
syslog_btn.setVisible(!!get_ntp_service());
sync_btn.setVisible(!!me.rstore.getById('ntp-sync-supported')?.data.value);
+ sources_btn.setVisible(sources_supported());
});
me.on('activate', me.rstore.startUpdate);
diff --git a/src/window/NTPSources.js b/src/window/NTPSources.js
new file mode 100644
index 0000000..178bfbb
--- /dev/null
+++ b/src/window/NTPSources.js
@@ -0,0 +1,155 @@
+Ext.define('proxmox-ntp-sources', {
+ extend: 'Ext.data.Model',
+ // not every service reports all values, keep missing ones null instead of converting to 0
+ fields: [
+ 'address',
+ 'name',
+ {
+ name: 'state',
+ // sort by how usable the source is, instead of alphabetically
+ sortType: (state) =>
+ ['unusable', 'falseticker', 'candidate', 'combined', 'selected'].indexOf(state),
+ },
+ { name: 'stratum', type: 'integer', allowNull: true },
+ { name: 'poll', type: 'number', allowNull: true },
+ { name: 'reach', type: 'integer', allowNull: true },
+ { name: 'last-rx', type: 'integer', allowNull: true },
+ { name: 'offset', type: 'number', allowNull: true },
+ ],
+ idProperty: 'address',
+});
+
+Ext.define('Proxmox.window.NTPSources', {
+ extend: 'Ext.window.Window',
+ alias: 'widget.proxmoxNTPSources',
+
+ title: gettext('NTP Sources'),
+ modal: true,
+ layout: 'fit',
+ width: 900,
+ height: 400,
+
+ initComponent: function () {
+ let me = this;
+
+ if (!me.nodename) {
+ throw 'no node name specified';
+ }
+
+ let rstore = Ext.create('Proxmox.data.UpdateStore', {
+ interval: 5000,
+ model: 'proxmox-ntp-sources',
+ proxy: {
+ type: 'proxmox',
+ url: `/api2/json/nodes/${me.nodename}/time/sources`,
+ },
+ });
+
+ // updates the rows in place, so the grid does not show its load mask on every refresh
+ let store = Ext.create('Proxmox.data.DiffStore', {
+ rstore: rstore,
+ // best first, kept when sources are added or change their state on a refresh
+ sortAfterUpdate: true,
+ sorters: [
+ {
+ property: 'state',
+ direction: 'DESC',
+ },
+ ],
+ });
+
+ let renderOptional = (renderer) => (value) =>
+ value === undefined || value === null ? '-' : renderer(value);
+
+ let renderState = function (state) {
+ let [icon, text] = {
+ selected: ['check-circle good', gettext('Selected')],
+ combined: ['check-circle good', gettext('Combined')],
+ candidate: ['circle-o', gettext('Candidate')],
+ falseticker: ['exclamation-circle warning', gettext('Falseticker')],
+ unusable: ['times-circle critical', gettext('Unusable')],
+ }[state] ?? ['question-circle', Ext.htmlEncode(state)];
+
+ return `<i class="fa fa-fw fa-${icon}"></i> ${text}`;
+ };
+
+ // the offset in the most readable unit, as it ranges from microseconds to seconds
+ let renderOffset = function (offset) {
+ let abs = Math.abs(offset);
+ let sign = offset < 0 ? '-' : '+';
+ if (abs < 0.001) {
+ return `${sign}${(abs * 1e6).toFixed(0)} us`;
+ } else if (abs < 1) {
+ return `${sign}${(abs * 1e3).toFixed(3)} ms`;
+ }
+ return `${sign}${abs.toFixed(3)} s`;
+ };
+
+ Ext.apply(me, {
+ items: {
+ xtype: 'grid',
+ store: store,
+ emptyText: gettext('No sources'),
+ columns: [
+ {
+ header: gettext('State'),
+ dataIndex: 'state',
+ width: 130,
+ renderer: renderState,
+ },
+ {
+ header: gettext('Address'),
+ dataIndex: 'address',
+ flex: 1,
+ renderer: Ext.htmlEncode,
+ },
+ {
+ header: gettext('Name'),
+ dataIndex: 'name',
+ flex: 1,
+ renderer: Ext.htmlEncode,
+ },
+ {
+ header: gettext('Stratum'),
+ dataIndex: 'stratum',
+ width: 80,
+ renderer: renderOptional((value) => value),
+ },
+ {
+ header: gettext('Poll interval'),
+ dataIndex: 'poll',
+ width: 100,
+ renderer: renderOptional(Proxmox.Utils.format_duration_human),
+ },
+ {
+ // octal, like the NTP tools show it, i.e. 377 if all of the last 8 polls
+ // got a response
+ header: gettext('Reach'),
+ dataIndex: 'reach',
+ width: 70,
+ renderer: renderOptional((value) => value.toString(8)),
+ },
+ {
+ header: gettext('Last sample'),
+ dataIndex: 'last-rx',
+ width: 100,
+ renderer: renderOptional(Proxmox.Utils.format_duration_human),
+ },
+ {
+ header: gettext('Offset'),
+ dataIndex: 'offset',
+ width: 100,
+ align: 'right',
+ renderer: renderOptional(renderOffset),
+ },
+ ],
+ },
+ });
+
+ me.callParent();
+
+ Proxmox.Utils.monStoreErrors(me.down('grid'), rstore);
+ me.on('destroy', rstore.stopUpdate);
+ rstore.startUpdate();
+ },
+});
--
2.47.3
next prev parent reply other threads:[~2026-11-26 13:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 13:39 [PATCH common/manager/widget-toolkit 00/16] partially fix #3809: configure and monitor NTP in the node time panel Jonas Theisen
2026-11-26 13:39 ` [PATCH common 01/16] systemd: add helpers to get and set NTP servers Jonas Theisen
2026-11-26 13:39 ` [PATCH common 02/16] systemd: add helper to query clock synchronization status Jonas Theisen
2026-11-26 13:40 ` [PATCH common 03/16] systemd: add helpers to synchronize the clock immediately Jonas Theisen
2026-11-26 13:40 ` [PATCH common 04/16] systemd: add helper to list the current NTP sources Jonas Theisen
2026-11-26 13:40 ` [PATCH widget-toolkit 05/16] node: time: do not open the editor for the server time row Jonas Theisen
2026-11-26 13:40 ` [PATCH widget-toolkit 06/16] partially fix #3809: node: time: show and edit NTP servers if supported Jonas Theisen
2026-11-26 13:40 ` [PATCH widget-toolkit 07/16] node: time: show clock synchronization status Jonas Theisen
2026-11-26 13:40 ` [PATCH widget-toolkit 08/16] window: add reusable service log window Jonas Theisen
2026-11-26 13:40 ` [PATCH widget-toolkit 09/16] node: time: add button to open the NTP service log Jonas Theisen
2026-11-26 13:40 ` [PATCH widget-toolkit 10/16] node: time: add button to synchronize the clock immediately Jonas Theisen
2026-11-26 13:40 ` Jonas Theisen [this message]
2026-11-26 13:40 ` [PATCH manager 12/16] partially fix #3809: api: nodes: time: allow configuring NTP servers Jonas Theisen
2026-11-26 13:40 ` [PATCH manager 13/16] api: nodes: time: report clock synchronization status Jonas Theisen
2026-11-26 13:40 ` [PATCH manager 14/16] ui: node: time: use journal for the NTP service log Jonas Theisen
2026-11-26 13:40 ` [PATCH manager 15/16] api: nodes: time: add endpoint to synchronize the clock immediately Jonas Theisen
2026-11-26 13:40 ` [PATCH manager 16/16] api: nodes: time: add endpoint to list the current NTP sources Jonas Theisen
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=20261126134128.316681-12-j.theisen@proxmox.com \
--to=j.theisen@proxmox.com \
--cc=pve-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.