summaryrefslogtreecommitdiff
path: root/service/ControlPlane.cpp
diff options
context:
space:
mode:
authorGrant Limberg <glimberg@gmail.com>2015-10-26 18:10:27 -0700
committerGrant Limberg <glimberg@gmail.com>2015-10-26 18:10:27 -0700
commit352b83252fb2617a15cde0927cc30110b729e46d (patch)
tree38569e4f6c1c162cdaabf7ac8c9d6b7917d71ffd /service/ControlPlane.cpp
parenta0c3083af0821db0303c62dfae9ebc560c3c147a (diff)
parent6625d7929654803f99b7a69f56a400046314acac (diff)
downloadinfinitytier-352b83252fb2617a15cde0927cc30110b729e46d.tar.gz
infinitytier-352b83252fb2617a15cde0927cc30110b729e46d.zip
Merge branch 'adamierymenko-dev' into windows-ui
Diffstat (limited to 'service/ControlPlane.cpp')
-rw-r--r--service/ControlPlane.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/service/ControlPlane.cpp b/service/ControlPlane.cpp
index 7affb08c..31eca7b6 100644
--- a/service/ControlPlane.cpp
+++ b/service/ControlPlane.cpp
@@ -354,8 +354,38 @@ unsigned int ControlPlane::handleRequest(
if (ps[0] == "status") {
responseContentType = "application/json";
+
ZT_NodeStatus status;
_node->status(&status);
+
+ std::string clusterJson;
+#ifdef ZT_ENABLE_CLUSTER
+ {
+ ZT_ClusterStatus cs;
+ _node->clusterStatus(&cs);
+
+ if (cs.clusterSize >= 1) {
+ char t[4096];
+ Utils::snprintf(t,sizeof(t),"{\n\t\t\"myId\": %u,\n\t\t\"clusterSize\": %u,\n\t\t\"members: [\n",cs.myId,cs.clusterSize);
+ clusterJson.append(t);
+ for(unsigned int i=0;i<cs.clusterSize;++i) {
+ Utils::snprintf(t,sizeof(t),"\t\t\t{\n\t\t\t\t\"id\": %u,\n\t\t\t\t\"msSinceLastHeartbeat\": %u,\n\t\t\t\t\"alive\": %s,\n\t\t\t\t\"x\": %d,\n\t\t\t\t\"y\": %d,\n\t\t\t\t\"z\": %d,\n\t\t\t\t\"load\": %llu\n\t\t\t\t\"peers\": %llu\n\t\t\t}%s",
+ cs.members[i].id,
+ cs.members[i].msSinceLastHeartbeat,
+ (cs.members[i].alive != 0) ? "true" : "false",
+ cs.members[i].x,
+ cs.members[i].y,
+ cs.members[i].z,
+ cs.members[i].load,
+ cs.members[i].peers,
+ (i == (cs.clusterSize - 1)) ? "," : "");
+ clusterJson.append(t);
+ }
+ clusterJson.append(" ]\n\t\t}");
+ }
+ }
+#endif
+
Utils::snprintf(json,sizeof(json),
"{\n"
"\t\"address\": \"%.10llx\",\n"
@@ -368,7 +398,8 @@ unsigned int ControlPlane::handleRequest(
"\t\"versionMinor\": %d,\n"
"\t\"versionRev\": %d,\n"
"\t\"version\": \"%d.%d.%d\",\n"
- "\t\"clock\": %llu\n"
+ "\t\"clock\": %llu,\n"
+ "\t\"cluster\": %s\n"
"}\n",
status.address,
status.publicIdentity,
@@ -380,7 +411,8 @@ unsigned int ControlPlane::handleRequest(
ZEROTIER_ONE_VERSION_MINOR,
ZEROTIER_ONE_VERSION_REVISION,
ZEROTIER_ONE_VERSION_MAJOR,ZEROTIER_ONE_VERSION_MINOR,ZEROTIER_ONE_VERSION_REVISION,
- (unsigned long long)OSUtils::now());
+ (unsigned long long)OSUtils::now(),
+ ((clusterJson.length() > 0) ? clusterJson.c_str() : "null"));
responseBody = json;
scode = 200;
} else if (ps[0] == "config") {