]> granicus.if.org Git - icinga2/commitdiff
Move the endpoint list into a new line for the 'cluster' check 6010/head
authorMichael Friedrich <michael.friedrich@icinga.com>
Thu, 18 Jan 2018 14:18:50 +0000 (15:18 +0100)
committerMichael Friedrich <michael.friedrich@icinga.com>
Thu, 18 Jan 2018 14:43:01 +0000 (15:43 +0100)
If you have many satellites/clients, the list view in Icinga Web 2
will get overly long. Moving the list for connected/not connected
endpoints into a new line makes this check more beautiful.

fixes #5444

lib/methods/clusterchecktask.cpp

index 35cede3c3c1784c1abba84f9d332f2a53f13d98c..85604dd621bcae0ebb1fddb2fbdac30b19840ab8 100644 (file)
@@ -58,19 +58,25 @@ void ClusterCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRe
        std::pair<Dictionary::Ptr, Array::Ptr> feature_stats = CIB::GetFeatureStats();
        cr->SetPerformanceData(feature_stats.second);
 
-       String connected_endpoints = FormatArray(status->Get("conn_endpoints"));
-       String not_connected_endpoints = FormatArray(status->Get("not_conn_endpoints"));
+       int numConnEndpoints = status->Get("num_conn_endpoints");
+       int numNotConnEndpoints = status->Get("num_not_conn_endpoints");
+
+       String output = "Icinga 2 Cluster";
+
+       if (numNotConnEndpoints > 0) {
+               output += " Problem: " + Convert::ToString(numNotConnEndpoints) + " endpoints are not connected.";
+               output += "\n(" + FormatArray(status->Get("not_conn_endpoints")) + ")";
 
-       if (status->Get("num_not_conn_endpoints") > 0) {
                cr->SetState(ServiceCritical);
-               cr->SetOutput("Icinga 2 Cluster Problem: " + Convert::ToString(status->Get("num_not_conn_endpoints")) +
-                       " Endpoints (" + not_connected_endpoints + ") not connected.");
        } else {
+               output += " OK: " + Convert::ToString(numConnEndpoints) + " endpoints are connected.";
+               output += "\n(" + FormatArray(status->Get("conn_endpoints")) + ")";
+
                cr->SetState(ServiceOK);
-               cr->SetOutput("Icinga 2 Cluster is running: Connected Endpoints: "+ Convert::ToString(status->Get("num_conn_endpoints")) +
-                       " (" + connected_endpoints + ").");
        }
 
+       cr->SetOutput(output);
+
        checkable->ProcessCheckResult(cr);
 }