Using nodetool sjk
Use nodetool sjk mx to gather database information from MBeans.
Nodetool includes the open source Swiss Java Knife as a built-in command, nodetool sjk, for troubleshooting. This section focuses on using the mx
subcommand to get and set JMX MBean values.
Attention: The
nodetool sjk mxdump
command tries to
print all exposed MBeans to the console. The command can fail if it encounters an improperly
formatted MBean. To interact with a specific list of MBeans, use the nodetool sjk
mx
command.Listing MBean names
To get values from the command line, first get the complete name of the MBean.
Following is an example of how to use jmxterm to dump the full list of JMX MBeans from a database
node:
echo "beans" | java -jar jmxterm-1.0.0-uber.jar -l localhost:7199 -n 2>&1
Tip: Only perform this operation once because the list can be large or search MBeans with
particular names in the output by redirecting the result to another filter. For example to find
MBeans that contain the word
commitlog
:echo "beans" | java -jar /tmp/jmxterm-1.0.0-uber.jar -l localhost:7199 -n 2>&1 | grep -i commitlog
The results provide the exact MBean strings to use in
nodetool sjk mx
command.com.datastax.bdp.advrep.v2.metrics:name=CommitLogMessagesRead,type=ReplicationLog
com.datastax.bdp.advrep.v2.metrics:name=CommitLogsDeleted,type=ReplicationLog
com.datastax.bdp.advrep.v2.metrics:name=CommitLogsToConsume,type=ReplicationLog
org.apache.cassandra.db:type=Commitlog
org.apache.cassandra.metrics:name=CompletedTasks,type=CommitLog
org.apache.cassandra.metrics:name=PendingTasks,type=CommitLog
org.apache.cassandra.metrics:name=TotalCommitLogSize,type=CommitLog
org.apache.cassandra.metrics:name=WaitingOnCommit,type=CommitLog
org.apache.cassandra.metrics:name=WaitingOnSegmentAllocation,type=CommitLog
Getting the MBean options and values
Use the MBean information option to show available values. For example, to show the options
available for TotalCommitLogSize from the previous results, use the complete
name:
nodetool sjk mx -b "org.apache.cassandra.metrics:name=TotalCommitLogSize,type=CommitLog" -mi
org.apache.cassandra.metrics:type=CommitLog,name=TotalCommitLogSize
org.apache.cassandra.metrics.CassandraMetricsRegistry$JmxGauge
- Information on the management interface of the MBean
(A) Value : java.lang.Object
- Attribute exposed for management
(O) objectName() : javax.management.ObjectName
- Operation exposed for management
The MBean has a simple value. To read the single number, run the following
command:
nodetool sjk mx -b "org.apache.cassandra.metrics:name=TotalCommitLogSize,type=CommitLog" -f Value -mg
org.apache.cassandra.metrics:type=CommitLog,name=TotalCommitLogSize
67108864
Note: SJK is case-sensitive, enter the names exactly.
To check on a more complex metric such as latency, find out how many values are available by
using
-mi
option:nodetool sjk mx -b "org.apache.cassandra.metrics:name=Latency,scope=Read,type=ClientRequest" -mi
org.apache.cassandra.metrics:type=ClientRequest,scope=Read,name=Latency
org.apache.cassandra.metrics.CassandraMetricsRegistry$JmxTimer
- Information on the management interface of the MBean
(A) Max : double
- Attribute exposed for management
(A) Min : double
- Attribute exposed for management
(A) Mean : double
- Attribute exposed for management
(A) StdDev : double
- Attribute exposed for management
(A) 95thPercentile : double
- Attribute exposed for management
(A) DurationUnit : String
- Attribute exposed for management
(A) 50thPercentile : double
- Attribute exposed for management
(A) 75thPercentile : double
- Attribute exposed for management
(A) 98thPercentile : double
- Attribute exposed for management
(A) 99thPercentile : double
- Attribute exposed for management
(A) 999thPercentile : double
- Attribute exposed for management
(A) OneMinuteRate : double
- Attribute exposed for management
(A) FifteenMinuteRate : double
- Attribute exposed for management
(A) FiveMinuteRate : double
- Attribute exposed for management
(A) MeanRate : double
- Attribute exposed for management
(A) RateUnit : String
- Attribute exposed for management
(A) Count : long
- Attribute exposed for management
(O) values() : long[]
- Operation exposed for management
(O) objectName() : javax.management.ObjectName
- Operation exposed for management
Then to read out a single value from this metric, use the following
command:
nodetool sjk mx -b "org.apache.cassandra.metrics:name=Latency,scope=Read,type=ClientRequest" -f 99thPercentile -mg
org.apache.cassandra.metrics:type=ClientRequest,scope=Read,name=Latency
3379.391