cassandradatastax-enterpriseuniqueidentifiercassandra-3.0nodetool

Is there any other way to get a cassandra hostid other than using nodetool status?


I can list complete cluster information using nodetool status which outputs something like this.

Datacenter: bi
==============
Status=Up/Down|/ State=Normal/Leaving/Joining/Moving
--  Address       Load       Tokens       Owns    Host ID                               
Rack
UN  10.132.2.93   19.88 GiB  32           ?       g94eee1f-1ge1-45c3-8cfgb-643719456c4fd  us-east-1a
UN  10.221.1.140  11.64 GiB  32           ?       b38f2fb2-fcf2-4567-b0cc-1548f63f0f24  us-east-1c

Is there a simpler way to grab the Host ID from the current node (the one the terminal is ssh'ed into) without having to parse it from the status output?

I'm using datastax enterprise... in case that helps


Solution

  • Every node saves information about itself in the system.local table. You could use cqlsh to get this information.

    cqlsh 10.132.2.93 -e 'SELECT host_id FROM system.local;'
    cqlsh 10.221.1.140 -e 'SELECT host_id FROM system.local;'
    

    It also saves the same type of information in system.peers table but this is only for all other nodes but itself. That's why I think it's easier to do one query for each node.