summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Rutkovsky <[email protected]>2025-02-20 20:13:28 +0300
committerGitHub <[email protected]>2025-02-20 17:13:28 +0000
commitbd6334dce34ab159d7970ab70a1abbb14ea25fe6 (patch)
tree2a4ccdeaff6b47d09e9d30851a96e542430679cd
parent90a6e2776aa3b6861c767555284edfdeb796769a (diff)
Improve NW and distconf HTML monitoring (#14854)
-rw-r--r--ydb/core/blobstorage/nodewarden/distconf_mon.cpp4
-rw-r--r--ydb/core/blobstorage/nodewarden/node_warden_impl.h1
-rw-r--r--ydb/core/blobstorage/nodewarden/node_warden_mon.cpp40
3 files changed, 33 insertions, 12 deletions
diff --git a/ydb/core/blobstorage/nodewarden/distconf_mon.cpp b/ydb/core/blobstorage/nodewarden/distconf_mon.cpp
index a9e9b2e5d4a..2db211ff112 100644
--- a/ydb/core/blobstorage/nodewarden/distconf_mon.cpp
+++ b/ydb/core/blobstorage/nodewarden/distconf_mon.cpp
@@ -170,10 +170,8 @@ namespace NKikimr::NStorage {
}
DIV_CLASS("panel-body") {
if (config) {
- TString s;
- NProtoBuf::TextFormat::PrintToString(*config, &s);
out << "<pre>";
- EscapeHtmlString(out, s);
+ OutputPrettyMessage(out, *config);
out << "</pre>";
} else {
out << "not defined";
diff --git a/ydb/core/blobstorage/nodewarden/node_warden_impl.h b/ydb/core/blobstorage/nodewarden/node_warden_impl.h
index dbf9f7423cd..580ce60fe13 100644
--- a/ydb/core/blobstorage/nodewarden/node_warden_impl.h
+++ b/ydb/core/blobstorage/nodewarden/node_warden_impl.h
@@ -685,6 +685,7 @@ namespace NKikimr::NStorage {
TString *errorReason);
void EscapeHtmlString(IOutputStream& out, const TString& s);
+ void OutputPrettyMessage(IOutputStream& out, const NProtoBuf::Message& message);
}
diff --git a/ydb/core/blobstorage/nodewarden/node_warden_mon.cpp b/ydb/core/blobstorage/nodewarden/node_warden_mon.cpp
index 8aa7d36c8bc..f10006ca2c8 100644
--- a/ydb/core/blobstorage/nodewarden/node_warden_mon.cpp
+++ b/ydb/core/blobstorage/nodewarden/node_warden_mon.cpp
@@ -106,28 +106,22 @@ void TNodeWarden::RenderWholePage(IOutputStream& out) {
TAG(TH3) { out << "StorageConfig"; }
DIV() {
out << "<p>Self-management enabled: " << (SelfManagementEnabled ? "yes" : "no") << "</p>";
- TString s;
- NProtoBuf::TextFormat::PrintToString(StorageConfig, &s);
out << "<pre>";
- EscapeHtmlString(out, s);
+ OutputPrettyMessage(out, StorageConfig);
out << "</pre>";
}
TAG(TH3) { out << "Static service set"; }
DIV() {
- TString s;
- NProtoBuf::TextFormat::PrintToString(StaticServices, &s);
out << "<pre>";
- EscapeHtmlString(out, s);
+ OutputPrettyMessage(out, StaticServices);
out << "</pre>";
}
TAG(TH3) { out << "Dynamic service set"; }
DIV() {
- TString s;
- NProtoBuf::TextFormat::PrintToString(DynamicServices, &s);
out << "<pre>";
- EscapeHtmlString(out, s);
+ OutputPrettyMessage(out, DynamicServices);
out << "</pre>";
}
@@ -406,3 +400,31 @@ void NKikimr::NStorage::EscapeHtmlString(IOutputStream& out, const TString& s) {
}
dump(s.size());
}
+
+void NKikimr::NStorage::OutputPrettyMessage(IOutputStream& out, const NProtoBuf::Message& message) {
+ class TFieldPrinter : public NProtoBuf::TextFormat::FastFieldValuePrinter {
+ public:
+ void PrintBytes(const TProtoStringType& value, NProtoBuf::TextFormat::BaseTextGenerator *generator) const override {
+ TStringStream newValue;
+ constexpr size_t maxPrintedLen = 32;
+ for (size_t i = 0; i < Min<size_t>(value.size(), maxPrintedLen); ++i) {
+ if (i) {
+ newValue << ' ';
+ }
+ newValue << Sprintf("%02x", static_cast<std::byte>(value[i]));
+ }
+ if (value.size() > maxPrintedLen) {
+ newValue << " ... (total " << value.size() << " bytes)";
+ }
+ TString& s = newValue.Str();
+ generator->Print(s.data(), s.size());
+ }
+ };
+
+ NProtoBuf::TextFormat::Printer p;
+ p.SetDefaultFieldValuePrinter(new TFieldPrinter);
+
+ TString s;
+ p.PrintToString(message, &s);
+ EscapeHtmlString(out, s);
+}