From 07305d87992a83ab343aebe13080510d3f4eda26 Mon Sep 17 00:00:00 2001 From: reyesj2 <94730068+reyesj2@users.noreply.github.com> Date: Tue, 29 Jul 2025 14:15:43 -0500 Subject: [PATCH] only show data nodes in disk usage output --- salt/elasticsearch/tools/sbin/so-elasticsearch-troubleshoot | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/salt/elasticsearch/tools/sbin/so-elasticsearch-troubleshoot b/salt/elasticsearch/tools/sbin/so-elasticsearch-troubleshoot index b6b201c3c..1f59610e9 100644 --- a/salt/elasticsearch/tools/sbin/so-elasticsearch-troubleshoot +++ b/salt/elasticsearch/tools/sbin/so-elasticsearch-troubleshoot @@ -121,7 +121,7 @@ watermark_settings() { return 1 fi - if ! disk_allocation_output=$(so-elasticsearch-query _cat/nodes?v\&h=name,ip,disk.used_percent,disk.avail,disk.total\&format=json --fail 2>/dev/null); then + if ! disk_allocation_output=$(so-elasticsearch-query _cat/nodes?v\&h=name,ip,disk.used_percent,disk.avail,disk.total,node.role\&format=json --fail 2>/dev/null); then log_title "ERROR" "Failed to retrieve disk allocation data from Elasticsearch" return 1 fi @@ -139,7 +139,8 @@ watermark_settings() { log_title "LOG" "Disk Usage Check" echo -e "${BOLD}LOW:${GREEN}$low${NC}${BOLD} HIGH:${YELLOW}${high}${NC}${BOLD} FLOOD:${RED}${flood}${NC}\n" - echo "$disk_allocation_output" | jq -r '.[] | "\(.name)|\(.["disk.used_percent"])"' | while IFS='|' read -r node_name disk_used; do + # Only show data nodes (d=data, h=hot, w=warm, c=cold, f=frozen, s=content) + echo "$disk_allocation_output" | jq -r '.[] | select(.["node.role"] | test("[dhwcfs]")) | "\(.name)|\(.["disk.used_percent"])"' | while IFS='|' read -r node_name disk_used; do disk_used_num=$(echo $disk_used | bc) if (( $(echo "$disk_used_num >= $flood_num" | bc -l) )); then