nodetool statusautocompaction
Displays the auto-compaction status for specified keyspaces and tables.
Synopsis
Section titled “Synopsis”nodetool [connection_options] statusautocompaction [options] [--] [<keyspace> <tables>...]See connection options for connection options.
Description
Section titled “Description”nodetool statusautocompaction reports whether automatic compaction is enabled or disabled for specified tables. This command is essential for verifying the state of auto-compaction after enable/disable operations and for auditing cluster configuration.
Auto-compaction status is a per-table setting that determines whether Cassandra's compaction strategy will automatically schedule compaction tasks.
Arguments
Section titled “Arguments”| Argument | Description |
|---|---|
keyspace | Target keyspace name. If omitted, shows status for all keyspaces |
tables | Space-separated list of table names. If omitted, shows all tables in the keyspace |
Options
Section titled “Options”| Option | Description |
|---|---|
-a, --all | Show per-keyspace/table status instead of summary |
Output
Section titled “Output”Summary (Default)
Section titled “Summary (Default)”Without -a/--all, the command prints a summary:
runningPossible summary values:
| Output | Meaning |
|---|---|
running | All tables have auto-compaction enabled |
not running | All tables have auto-compaction disabled |
partially running | Some tables enabled, some disabled |
Detailed Output (with -a/--all)
Section titled “Detailed Output (with -a/--all)”With -a option, the command shows per-table status:
nodetool statusautocompaction -amy_keyspace.users running=truemy_keyspace.orders running=truemy_keyspace.products running=falseExamples
Section titled “Examples”Check All Tables
Section titled “Check All Tables”nodetool statusautocompactionCheck Specific Keyspace
Section titled “Check Specific Keyspace”nodetool statusautocompaction my_keyspaceCheck Specific Table
Section titled “Check Specific Table”nodetool statusautocompaction my_keyspace my_tableCheck Multiple Tables
Section titled “Check Multiple Tables”nodetool statusautocompaction my_keyspace users orders productsCheck Remote Node
Section titled “Check Remote Node”ssh 192.168.1.100 "nodetool statusautocompaction my_keyspace"Output Interpretation
Section titled “Output Interpretation”Summary Output (without -a)
Section titled “Summary Output (without -a)”| Output | Meaning | Action Needed |
|---|---|---|
running | All tables have auto-compaction enabled | None (normal state) |
not running | All tables have auto-compaction disabled | Investigate and re-enable |
partially running | Mixed status across tables | Use -a to identify disabled tables |
Detailed Output (with -a)
Section titled “Detailed Output (with -a)”| Output | Meaning | Action Needed |
|---|---|---|
running=true | Auto-compaction is enabled | None (normal state) |
running=false | Auto-compaction is disabled | Consider re-enabling |
Default State
All tables have auto-compaction enabled (running=true) by default. A running=false status indicates someone explicitly disabled it.
Use Cases
Section titled “Use Cases”Verify After Enable/Disable
Section titled “Verify After Enable/Disable”Confirm enable/disable commands took effect:
# After disablingnodetool disableautocompaction my_keyspace my_tablenodetool statusautocompaction my_keyspace my_table# Expected: my_keyspace.my_table running=false
# After enablingnodetool enableautocompaction my_keyspace my_tablenodetool statusautocompaction my_keyspace my_table# Expected: my_keyspace.my_table running=trueCluster Audit
Section titled “Cluster Audit”Check auto-compaction status across all tables:
# Quick check - summarynodetool statusautocompaction
# Find any tables with disabled auto-compaction (use -a for details)nodetool statusautocompaction -a | grep "running=false"Health Check Integration
Section titled “Health Check Integration”Include in operational health checks:
#!/bin/bash# Check for unexpectedly disabled auto-compaction
status=$(nodetool statusautocompaction 2>/dev/null)
if [ "$status" = "running" ]; then echo "OK: All tables have auto-compaction enabled" exit 0elif [ "$status" = "not running" ] || [ "$status" = "partially running" ]; then echo "WARNING: Auto-compaction is disabled or partially disabled" nodetool statusautocompaction -a | grep "running=false" exit 1else echo "ERROR: Could not determine status" exit 2fiPre-Maintenance Check
Section titled “Pre-Maintenance Check”Verify state before maintenance operations:
echo "=== Auto-Compaction Status Before Maintenance ==="nodetool statusautocompaction my_keyspace
# Perform maintenance...
echo "=== Auto-Compaction Status After Maintenance ==="nodetool statusautocompaction my_keyspaceMonitoring Integration
Section titled “Monitoring Integration”Prometheus Exporter
Section titled “Prometheus Exporter”Export status as a metric:
#!/bin/bash# Export auto-compaction status for monitoring
nodetool statusautocompaction -a 2>/dev/null | while read line; do table=$(echo $line | awk '{print $1}') status=$(echo $line | grep -c "running=true") echo "cassandra_autocompaction_enabled{table=\"$table\"} $status"doneNagios/Icinga Check
Section titled “Nagios/Icinga Check”#!/bin/bashstatus=$(nodetool statusautocompaction 2>/dev/null)
if [ $? -ne 0 ]; then echo "UNKNOWN - Cannot connect to Cassandra" exit 3fi
if [ "$status" = "running" ]; then echo "OK - All tables have auto-compaction enabled" exit 0elif [ "$status" = "partially running" ]; then disabled_count=$(nodetool statusautocompaction -a 2>/dev/null | grep -c "running=false") echo "WARNING - $disabled_count table(s) have auto-compaction disabled" exit 1else echo "CRITICAL - All tables have auto-compaction disabled" exit 2fiJSON Output for Monitoring
Section titled “JSON Output for Monitoring”#!/bin/bash# Output JSON for monitoring systems
echo "{"echo " \"timestamp\": \"$(date -Iseconds)\","echo " \"tables\": ["
first=truenodetool statusautocompaction -a 2>/dev/null | while read line; do table=$(echo $line | awk '{print $1}') enabled=$(echo $line | grep -q "running=true" && echo "true" || echo "false")
if [ "$first" = true ]; then first=false else echo "," fi echo -n " {\"table\": \"$table\", \"enabled\": $enabled}"done
echo ""echo " ]"echo "}"Cluster-Wide Audit
Section titled “Cluster-Wide Audit”Check All Nodes
Section titled “Check All Nodes”#!/bin/bashecho "=== Cluster Auto-Compaction Audit ==="echo ""
# Get list of node IPs from local nodetool statusnodes=$(nodetool status | grep "^UN" | awk '{print $2}')
for node in $nodes; do echo "=== Node: $node ===" status=$(ssh "$node" 'nodetool statusautocompaction 2>/dev/null') if [ "$status" = "running" ]; then echo "All tables have auto-compaction enabled" else echo "Status: $status" echo "Tables with disabled auto-compaction:" ssh "$node" 'nodetool statusautocompaction -a 2>/dev/null | grep "running=false"' fi echo ""doneCompare Across Nodes
Section titled “Compare Across Nodes”#!/bin/bash# Check if auto-compaction status is consistent across nodesKEYSPACE="my_keyspace"TABLE="my_table"
echo "Checking $KEYSPACE.$TABLE across cluster..."
# Get list of node IPs from local nodetool statusnodes=$(nodetool status | grep "^UN" | awk '{print $2}')statuses=""
for node in $nodes; do status=$(ssh "$node" 'nodetool statusautocompaction -a '"$KEYSPACE"' '"$TABLE"' 2>/dev/null | awk '"'"'{print $2}'"'"'') echo "$node: $status" statuses="$statuses$status\n"done
unique=$(echo -e "$statuses" | sort -u | grep -v "^$" | wc -l)
if [ "$unique" -eq 1 ]; then echo "" echo "Status is CONSISTENT across all nodes"else echo "" echo "WARNING: Status is INCONSISTENT across nodes!"fiCommon Scenarios
Section titled “Common Scenarios”Finding Forgotten Disabled Tables
Section titled “Finding Forgotten Disabled Tables”# List all tables with disabled auto-compactionnodetool statusautocompaction -a | grep "running=false"Verifying Bulk Load Set up
Section titled “Verifying Bulk Load Set up”# Before bulk load - verify target table is disablednodetool statusautocompaction my_keyspace load_target# Expected: running=false
# After bulk load - verify re-enablednodetool statusautocompaction my_keyspace load_target# Expected: running=trueChecking System Tables
Section titled “Checking System Tables”# System tables should always have auto-compaction enablednodetool statusautocompaction systemnodetool statusautocompaction system_schemaTroubleshooting
Section titled “Troubleshooting”Command Returns No Output
Section titled “Command Returns No Output”If no output is returned:
# Verify keyspace existsnodetool tablestats | grep "Keyspace:"
# Check specific keyspacenodetool statusautocompaction existing_keyspaceConnection Errors
Section titled “Connection Errors”# Check JMX connectivitynodetool info
# Verify Cassandra is runningpgrep -f CassandraDaemonInconsistent Status Across Nodes
Section titled “Inconsistent Status Across Nodes”If nodes show different statuses:
# Each node maintains its own auto-compaction state# After cluster-wide disable, re-enable on all nodes:
for node in $(nodetool status | grep "^UN" | awk '{print $2}'); do ssh "$node" "nodetool enableautocompaction my_keyspace my_table"doneAutomation Script
Section titled “Automation Script”#!/bin/bashOUTPUT_FILE="/var/log/cassandra/autocompaction_status_$(date +%Y%m%d).log"
echo "=== Auto-Compaction Status Report ===" | tee $OUTPUT_FILEecho "Generated: $(date)" | tee -a $OUTPUT_FILEecho "" | tee -a $OUTPUT_FILE
# Count totalstotal=$(nodetool statusautocompaction 2>/dev/null | wc -l)enabled=$(nodetool statusautocompaction -a 2>/dev/null | grep -c "running=true")disabled=$(nodetool statusautocompaction -a 2>/dev/null | grep -c "running=false")
echo "Summary:" | tee -a $OUTPUT_FILEecho " Total tables: $total" | tee -a $OUTPUT_FILEecho " Enabled: $enabled" | tee -a $OUTPUT_FILEecho " Disabled: $disabled" | tee -a $OUTPUT_FILEecho "" | tee -a $OUTPUT_FILE
if [ "$disabled" -gt 0 ]; then echo "Tables with disabled auto-compaction:" | tee -a $OUTPUT_FILE nodetool statusautocompaction -a | grep "running=false" | tee -a $OUTPUT_FILE echo "" | tee -a $OUTPUT_FILE echo "ACTION REQUIRED: Review and re-enable if appropriate" | tee -a $OUTPUT_FILEelse echo "All tables have auto-compaction enabled." | tee -a $OUTPUT_FILEfiBest Practices
Section titled “Best Practices”Status Monitoring Guidelines
- Regular audits - Periodically check for disabled auto-compaction
- Include in health checks - Add to monitoring and alerting
- Verify after changes - Always check status after enable/disable
- Document disabled tables - Know why any table has it disabled
- Cluster consistency - Verify status is consistent across nodes
- Alert on disabled - Set up alerts for
running=falsestatus
Disabled Auto-Compaction
If statusautocompaction shows running=false for any table, investigate immediately:
- Was it intentionally disabled?
- How long has it been disabled?
- Is there a plan to re-enable?
- What is the current SSTable count?
Related Commands
Section titled “Related Commands”| Command | Relationship |
|---|---|
| enableautocompaction | Enable auto-compaction |
| disableautocompaction | Disable auto-compaction |
| compactionstats | View active compactions |
| tablestats | View SSTable counts |
| compact | Force manual compaction |