Skip to content

Commit 543625a

Browse files
author
tongjixianing
committed
When listen_address is configured with the hostname, the output dir of the node is with the hostname instead of IP address
1 parent 7bc6cfc commit 543625a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

collect_node_diag.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ function get_node_ip {
180180
fi
181181
if [ -z "$NODE_ADDR" ]; then
182182
NODE_ADDR="$(grep -e '^listen_address: ' "$CONF_DIR/cassandra.yaml" |sed -e 's|^[^:]*:[ ]*\([^ ]*\)[ ]*$|\1|'|tr -d "'")"
183-
if [ -z "$NODE_ADDR" ] || [ "$NODE_ADDR" = "127.0.0.1" ] || [ "$NODE_ADDR" = "localhost" ]; then
184-
# echo "Can't detect node's address from cassandra.yaml, or it's set to localhost. Trying to use the 'hostname'"
183+
if [ -z "$NODE_ADDR" ] || [ "$NODE_ADDR" = "127.0.0.1" ] || [ "$NODE_ADDR" = "localhost" ] || [ $(checkIP $NODE_ADDR) = "false" ]; then
184+
echo "Can't detect node's address from cassandra.yaml, or it's set to localhost. Trying to use the 'hostname'"
185185
if [ "$HOST_OS" = "Linux" ]; then
186186
NODE_ADDR="$(hostname -i)"
187187
else
@@ -1068,6 +1068,16 @@ function adjust_nodetool_params {
10681068
JMX_OPTS="$JMX_OPTS -s $jmx_host:$jmx_port"
10691069
}
10701070

1071+
function checkIP() {
1072+
1073+
if [[ $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
1074+
echo "true"
1075+
else
1076+
echo "false"
1077+
fi
1078+
1079+
}
1080+
10711081
# Call functions in order
10721082

10731083
debug "Collection mode: $MODE"

0 commit comments

Comments
 (0)