aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzalyalov <zalyalov@yandex-team.com>2023-09-04 17:06:15 +0300
committerzalyalov <zalyalov@yandex-team.com>2023-09-04 17:36:34 +0300
commit85e84d92745050b5e893862bf344e6958ef9e8e1 (patch)
treed39d41b62f30ddc4ae2f1680344024af155f6929
parent9d7eb61fa52b47766c6fb632783c4b1736a99aa5 (diff)
downloadydb-85e84d92745050b5e893862bf344e6958ef9e8e1.tar.gz
improve colored values in hive ui
-rw-r--r--ydb/core/mind/hive/hive_impl.h2
-rw-r--r--ydb/core/mind/hive/hive_statics.cpp19
-rw-r--r--ydb/core/mind/hive/monitoring.cpp8
3 files changed, 17 insertions, 12 deletions
diff --git a/ydb/core/mind/hive/hive_impl.h b/ydb/core/mind/hive/hive_impl.h
index 5c63f0cbae..a59d598da5 100644
--- a/ydb/core/mind/hive/hive_impl.h
+++ b/ydb/core/mind/hive/hive_impl.h
@@ -139,7 +139,7 @@ TString GetTimes(ui64 times, const TString& zero = "0.00%");
TString GetConditionalGreyString(const TString& str, bool condition);
TString GetConditionalBoldString(const TString& str, bool condition);
TString GetConditionalRedString(const TString& str, bool condition);
-TString GetColoredValue(double val, double maxVal);
+TString GetValueWithColoredGlyph(double val, double maxVal);
TString GetDataCenterName(ui64 dataCenterId);
TString LongToShortTabletName(const TString& longTabletName);
TString GetLocationString(const NActors::TNodeLocation& location);
diff --git a/ydb/core/mind/hive/hive_statics.cpp b/ydb/core/mind/hive/hive_statics.cpp
index c1e672ea12..bf1736e5f6 100644
--- a/ydb/core/mind/hive/hive_statics.cpp
+++ b/ydb/core/mind/hive/hive_statics.cpp
@@ -196,18 +196,23 @@ TString GetConditionalRedString(const TString& str, bool condition) {
}
}
-TString GetColoredValue(double val, double maxVal) {
- double ratio = val / maxVal;
- TString color;
+TString GetValueWithColoredGlyph(double val, double maxVal) {
+ double ratio;
+ if (maxVal != 0) {
+ ratio = val / maxVal;
+ } else {
+ ratio = 1.0;
+ }
+ TString glyph;
if (ratio < 0.9) {
- color = "green";
+ glyph = "<span class='glyphicon glyphicon-ok-sign' style='color:green; margin-left:4px'></span>";
} else if (ratio < 1.0) {
- color = "yellow";
+ glyph = "<span class='glyphicon glyphicon-exclamation-sign' style='color:#FFEA00; margin-left:4px'></span>";
} else {
- color = "red";
+ glyph = "<span class='glyphicon glyphicon-exclamation-sign' style='color:red; margin-left:4px'></span>";
}
- return Sprintf("<span style='color:%s'>%.2f</span>", color.c_str(), val);
+ return Sprintf("<span>%.2f</span>", val) + glyph;
}
ui64 GetReadThroughput(const NKikimrTabletBase::TMetrics& values) {
diff --git a/ydb/core/mind/hive/monitoring.cpp b/ydb/core/mind/hive/monitoring.cpp
index d27a3f481c..d197f5b065 100644
--- a/ydb/core/mind/hive/monitoring.cpp
+++ b/ydb/core/mind/hive/monitoring.cpp
@@ -1359,8 +1359,8 @@ public:
out << "<tr><td>" << "Resource StDev: " << "</td><td id='resourceVariance'>"
<< convert(Self->GetStDevResourceValues(), [](double d) -> TString { return Sprintf("%.9f", d); }) << "</td></tr>";
THive::THiveStats stats = Self->GetStats();
- out << "<tr><td>" << "Max usage:" << "<td id='maxUsage'>" << GetColoredValue(stats.MaxUsage, Self->GetMaxNodeUsageToKick()) << "</td></tr>";
- out << "<tr><td>" << "Scatter:" << "<td id='scatter'>" << GetColoredValue(stats.Scatter, Self->GetMinScatterToBalance()) << "</td></tr>";
+ out << "<tr><td>" << "Max usage:" << "<td id='maxUsage'>" << GetValueWithColoredGlyph(stats.MaxUsage, Self->GetMaxNodeUsageToKick()) << "</td></tr>";
+ out << "<tr><td>" << "Scatter:" << "<td id='scatter'>" << GetValueWithColoredGlyph(stats.Scatter, Self->GetMinScatterToBalance()) << "</td></tr>";
out << "</table>";
out << "<table id='node_table' class='table simple-table2 table-hover table-condensed'>";
@@ -2063,8 +2063,8 @@ public:
jsonData["BootQueueSize"] = Self->BootQueue.BootQueue.size();
jsonData["WaitQueueSize"] = Self->BootQueue.WaitQueue.size();
jsonData["BalancerProgress"] = GetBalancerProgressText(Self->BalancerProgress, Self->LastBalancerTrigger);
- jsonData["MaxUsage"] = GetColoredValue(stats.MaxUsage, Self->GetMaxNodeUsageToKick()) ;
- jsonData["Scatter"] = GetColoredValue(stats.Scatter, Self->GetMinScatterToBalance());
+ jsonData["MaxUsage"] = GetValueWithColoredGlyph(stats.MaxUsage, Self->GetMaxNodeUsageToKick()) ;
+ jsonData["Scatter"] = GetValueWithColoredGlyph(stats.Scatter, Self->GetMinScatterToBalance());
jsonData["RunningTabletsText"] = GetRunningTabletsText(runningTablets, tablets, Self->WarmUp);
TVector<TNodeInfo*> nodeInfos;