From ecc66d5cb34096604cee2a638ce643c50d7e67a7 Mon Sep 17 00:00:00 2001 From: liupei Date: Thu, 20 Nov 2025 19:52:56 +0800 Subject: [PATCH] DRBDmon: page command now switches from cursor to page mode --- ...and-now-switches-from-cursor-to-page.patch | 160 ++++++++++++++++++ drbd.spec | 7 +- 2 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 backport-DRBDmon-page-command-now-switches-from-cursor-to-page.patch diff --git a/backport-DRBDmon-page-command-now-switches-from-cursor-to-page.patch b/backport-DRBDmon-page-command-now-switches-from-cursor-to-page.patch new file mode 100644 index 0000000..192a55e --- /dev/null +++ b/backport-DRBDmon-page-command-now-switches-from-cursor-to-page.patch @@ -0,0 +1,160 @@ +From 6962c1dc0dbf544c92162f27eb4bc7c232d506cc Mon Sep 17 00:00:00 2001 +From: Robert Altnoeder +Date: Thu, 16 Jan 2025 17:28:00 +0100 +Subject: [PATCH 072/200] DRBDmon: /page command now switches from cursor to + page mode + +--- + user/drbdmon/terminal/MDspBase.cpp | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/user/drbdmon/terminal/MDspBase.cpp b/user/drbdmon/terminal/MDspBase.cpp +index d28bac25..69b4d034 100644 +--- a/user/drbdmon/terminal/MDspBase.cpp ++++ b/user/drbdmon/terminal/MDspBase.cpp +@@ -449,6 +449,7 @@ bool MDspBase::execute_command(const std::string& command, StringTokenizer& toke + if (arg_page_nr >= 1 && arg_page_nr <= DisplayConsts::MAX_PAGE_NR) + { + set_page_nr(arg_page_nr); ++ leave_page_nav_mode(page_change_type::PG_CHG_CHANGED); + cmd_valid = true; + } + } +@@ -458,6 +459,7 @@ bool MDspBase::execute_command(const std::string& command, StringTokenizer& toke + if (upper_arg_page == KEYWORD_PAGE_LAST) + { + set_page_nr(DisplayConsts::MAX_PAGE_NR); ++ leave_page_nav_mode(page_change_type::PG_CHG_CHANGED); + cmd_valid = true; + } + } +-- +2.33.1.windows.1 + +From 8b87c53dccb860ac9fc29bcc9d15aedf19b60280 Mon Sep 17 00:00:00 2001 +From: Robert Altnoeder +Date: Thu, 3 Apr 2025 17:40:59 +0200 +Subject: [PATCH 073/200] DRBDmon: drbd-events-log-supplier timestamps + compatibility + +Enables loading of event files into DRBDmon that were created +using the --timestamps option with drbdsetup events2 by +preprocessing the event lines before they are passed on to +DRBDmon. +--- + user/drbdmon/drbd-events-log-supplier.cpp | 75 +++++++++++++++++++---- + 1 file changed, 64 insertions(+), 11 deletions(-) + +diff --git a/user/drbdmon/drbd-events-log-supplier.cpp b/user/drbdmon/drbd-events-log-supplier.cpp +index 9fe48f0c..2abaa7d0 100644 +--- a/user/drbdmon/drbd-events-log-supplier.cpp ++++ b/user/drbdmon/drbd-events-log-supplier.cpp +@@ -11,11 +11,28 @@ extern "C" + constexpr int ERR_OUT_OF_MEMORY = 2; + constexpr int ERR_IO = 3; + ++const std::string EVENT_EXISTS("exists"); ++const std::string EVENT_CREATE("create"); ++const std::string EVENT_CHANGE("change"); ++const std::string EVENT_DESTROY("destroy"); ++const std::string* const EVENT_TYPES[] = ++{ ++ &EVENT_EXISTS, ++ &EVENT_CREATE, ++ &EVENT_CHANGE, ++ &EVENT_DESTROY, ++ nullptr ++}; + const std::string INIT_STATE_SEPA("exists -"); + const size_t INIT_STATE_SEPA_LENGTH = INIT_STATE_SEPA.length(); + + int process_events(const std::string& path); + bool is_init_state_sepa(const std::string& event_line); ++static inline void process_event_line( ++ const bool skip_timestamp, ++ bool& have_init_state_sepa, ++ std::string& event_line ++); + + /** + * DRBD events log file supplier for DRBDmon +@@ -49,6 +66,40 @@ int main(int argc, char* argv[]) + return exit_code; + } + ++static inline void process_event_line( ++ const bool skip_timestamp, ++ bool& have_init_state_sepa, ++ std::string& event_line ++) ++{ ++ if (skip_timestamp) ++ { ++ size_t event_idx = 0; ++ size_t event_pos = std::string::npos; ++ while (event_pos == std::string::npos && EVENT_TYPES[event_idx] != nullptr) ++ { ++ const std::string* const event_str = EVENT_TYPES[event_idx]; ++ event_pos = event_line.find(*event_str); ++ ++event_idx; ++ } ++ if (event_pos != std::string::npos) ++ { ++ event_line = event_line.substr(event_pos); ++ } ++ } ++ ++ if (event_line.length() > 0) ++ { ++ std::cout << event_line << '\n'; ++ } ++ if (is_init_state_sepa(event_line)) ++ { ++ have_init_state_sepa = true; ++ } ++ ++ event_line.clear(); ++} ++ + /** + * Emits event lines from an events log file and appends the initial state separator + * if it is absent from the file. The output is stdout, which DRBDmon pipes to itself. +@@ -70,22 +121,24 @@ int process_events(const std::string& path) + if (in_file.good()) + { + bool have_init_state_sepa = false; ++ bool skip_timestamp = false; + +- // Emit events from the file to DRBDmon + std::string event_line; +- while (in_file.good()) ++ ++ // Determine presence of a timestamp before the event type by ++ // analyzing the first line + { + std::getline(in_file, event_line); +- if (event_line.length() > 0) +- { +- std::cout << event_line << '\n'; +- } +- if (is_init_state_sepa(event_line)) +- { +- have_init_state_sepa = true; +- } ++ const size_t event_pos = event_line.find(EVENT_EXISTS); ++ skip_timestamp = event_pos != std::string::npos && event_pos != 0; ++ process_event_line(skip_timestamp, have_init_state_sepa, event_line); ++ } + +- event_line.clear(); ++ // Emit events from the file to DRBDmon ++ while (in_file.good()) ++ { ++ std::getline(in_file, event_line); ++ process_event_line(skip_timestamp, have_init_state_sepa, event_line); + } + + if (in_file.eof()) +-- +2.33.1.windows.1 + diff --git a/drbd.spec b/drbd.spec index ecf4e89..f63925f 100644 --- a/drbd.spec +++ b/drbd.spec @@ -1,10 +1,11 @@ Name: drbd Summary: DRBD user-land tools and scripts Version: 9.31.0 -Release: 1 +Release: 2 Source0: http://www.linbit.com/downloads/%{name}/utils/%{name}-utils-%{version}.tar.gz Patch0: drbd-utils-9.12.2-disable_xsltproc_network_read.patch Patch1: drbd-utils-9.15.0-make_configure-workaround.patch +Patch2: backport-DRBDmon-page-command-now-switches-from-cursor-to-page.patch License: GPL-2.0-or-later ExclusiveOS: linux @@ -196,6 +197,10 @@ management utility. %systemd_preun drbd.service %changelog +* Thu Nov 20 2025 liupei - 9.31.0-2 +- DRBDmon: /page command now switches from cursor to page mode +- DRBDmon: drbd-events-log-supplier timestamps compatibility + * Tue Nov 18 2025 liupei - 9.31.0-1 - update to 9.31.0 -- Gitee