Getting the status of each node in the cluster


Is there any function in the C client library to find the status of each node in the cluster? Basically, I need the output to have each node’s IP along with it’s status e.g. UP, DOWN.

as_nodes* nodes = as_nodes_reserve(as->cluster);

for (uint32_t i = 0; i < nodes->size; i++) {
    as_node* node = nodes->array[i];
    printf("Node %s active=%d\n", as_node_get_address_string(node), node->active);


Hi Brian,

Thanks for your response. I tested this code in a cluster of 2 nodes and found that it only gives info about the active node i.e. if I shut down 1 of the 2 nodes, the code gives info about only 1 node. I don’t know what’s missing here, because, node->active seems to be of no use.

In order to get info about the node which is no longer working(down) I used “services-alumni” in aerospike_info_foreach() and by finding the node which was present in it’s output but was absent in the output of your code, I got the node which was down.


The client only tracks active nodes. node->active is only false when the node is marked for deletion, but not deleted yet.

If you just want to know when a node is added or dropped from the cluster, subscribe to cluster event callback.

void my_event_callback(as_cluster_event* ce)
  switch (ce->type) {
    printf("Add node %s\n", ce->node_address);
    printf("Remove node %s\n", ce->node_address);
    printf("Cluster disconnected\n");

as_config c;
c.event_callback = my_event_callback;
c.event_callback_udata = NULL;


If ‘services-alumni’ is the command you need, you should also be aware of ‘services-alumni-reset’ which sets the alumni list to the current set of nodes observed by the cluster. If you ever make permanent changes to the cluster membership, you will likely want to run this command to manage the alumni lists on each node.


This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.