Commit db9743af authored by jan.koester's avatar jan.koester
Browse files

test

parent ed637679
Loading
Loading
Loading
Loading
Loading
+2 −1
Changes for data/admin.html: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -1023,8 +1023,9 @@ function loadClusterStatus() {
                for (var i = 0; i < data.nodes.length; i++) {
                    var n = data.nodes[i];
                    var nclass = (n.status === 'OK') ? 'msg-ok' : 'msg-error';
                    var nlabel = n.label ? n.label : ('Node ' + n.index);
                    html += '<tr>';
                    html += '<td>Node ' + n.index + '</td>';
                    html += '<td>' + nlabel + '</td>';
                    html += '<td class="' + nclass + '">' + n.status + '</td>';
                    html += '<td>' + n.blocks + '</td>';
                    html += '<td>' + n.groups + '</td>';
+22 −2
Changes for src/admin.cpp: 22 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -601,6 +601,10 @@ namespace authdb {
                std::lock_guard<std::mutex> lock(g_Cluster->getClientMutex());
                auto health = pclient->get_cluster_status();

                // Include local node in the counts (+1 for ourselves)
                uint32_t total = health.nodes_total + 1;
                uint32_t online = health.nodes_online + 1;

                const char *statusStr = "OK";
                if (health.overall == paritypp::node_status::DEGRADED)
                    statusStr = "DEGRADED";
@@ -608,10 +612,26 @@ namespace authdb {
                    statusStr = "REBUILD";

                json_object_object_add(jobj, "status", json_object_new_string(statusStr));
                json_object_object_add(jobj, "nodes_total", json_object_new_int(health.nodes_total));
                json_object_object_add(jobj, "nodes_online", json_object_new_int(health.nodes_online));
                json_object_object_add(jobj, "nodes_total", json_object_new_int(total));
                json_object_object_add(jobj, "nodes_online", json_object_new_int(online));

                json_object *jnodes = json_object_new_array();

                // Local node (this node, index -1 / "local")
                {
                    auto &store = g_Cluster->getStore();
                    json_object *jn = json_object_new_object();
                    json_object_object_add(jn, "index", json_object_new_int(-1));
                    json_object_object_add(jn, "label", json_object_new_string("local"));
                    json_object_object_add(jn, "status", json_object_new_string("OK"));
                    json_object_object_add(jn, "blocks", json_object_new_int(store.total_blocks()));
                    json_object_object_add(jn, "groups", json_object_new_int(store.total_groups()));
                    json_object_object_add(jn, "peers_total", json_object_new_int(health.nodes_total));
                    json_object_object_add(jn, "peers_online", json_object_new_int(health.nodes_online));
                    json_object_array_add(jnodes, jn);
                }

                // Remote peer nodes
                for (const auto &[idx, info] : health.node_statuses) {
                    json_object *jn = json_object_new_object();
                    json_object_object_add(jn, "index", json_object_new_int(static_cast<int>(idx)));