List non-default gFlag settings

There are various configuration flags (called gFlags) for both YB-Master and YB-TServer nodes in a YugabyteDB universe.

These gFlags allow you to resolve issues, improve performance, and customize functionality.

Using YB Anywhere we can easily view the current and default values of a configuration flag.

Example (for the ysql_enable_packed_row gFlag):

But it’s not very easy in YB Anywhere to get a complete list of gFlags that have a current non-default value.

To do that, we can compare the current gFlag settings reported by the T-Server and Master UIs to the default values reported by the yb-tserver and yb-master binaries.

For convenience and ease of use, I’ve encapsulated that logic into a shell script.

				
					#!/bin/bash

# Script:      non-default-gflags.sh
# Description: This script will print gFlags that have non-default values
# Created:     02/01/2023
# Last update: 02/01/2023

# Notes:
#   1. The script accepts 3 parameters
#     1.1 server_type (required)     - "T" for T-Server, "M" for Master
#     1.2 server_endpoint (required) - IP Address:Port
#     1.3 gFlag (optional)           - Particular gFlag to check (used in wildcard grep search)
#   2. The scripts calls either the binary yb-tserver or yb-master without specify a full path.
#      Make sure either your $PATH includes the YB bin folder, or modify this script to point
#      directly to the relevant binary.
#   3. Example call, showing output is pipe delimited:
#        ./non-default-gflags.sh T yugabytedb.tech:9000 packed
#        gFlag|Current_Value|Default_Value
#        ysql_enable_packed_row|true|false
#
#      Use the column command to pretty up the output:
#        ./non-default-gflags.sh T yugabytedb.tech:9000 packed | column -t -s"|"
#        gFlag                   Current_Value  Default_Value
#        ysql_enable_packed_row  true           false

# Verify parameters
if [ -z "$1" ] || ([ "$1" != "T" ] && [ "$1" != "M" ])
then
  echo "Please specify server UI to query. Use \"T\" for T-Server or \"M\" for Master."
  exit 1
else
  YB_SERVER_TYPE=$1;
fi

if [ -z "$2" ]
then
  echo "Please provide a YB Server UI endpoint in the format IP:port"
  exit 1
else
  YB_SERVER=$2;
fi

if [ ! -z "$3" ]
then
  YB_GFLAG=$3;
fi

# Get Server current gFlag values
if [ ! -z "$YB_GFLAG" ]
then
  c_gFlags="$(curl -s http://$YB_SERVER/varz?raw | grep $YB_GFLAG | sed 's/\-\-//g' | sort)"
else
  c_gFlags="$(curl -s http://$YB_SERVER/varz?raw | sed 's/\-\-//g' | sort)"
fi

# Get Server default gFlag values
if [ "$YB_SERVER_TYPE" = "T" ]
then
  d_gFlags=$(yb-tserver --help)
else
  d_gFlags=$(yb-master --help)
fi

# Output
echo "gFlag|Current_Value|Default_Value"

while IFS= read -r line; do
    IFS='=' read -ra arrIN <<< "$line"
    default=$(echo "$d_gFlags" | sed -n -e "/-${arrIN[0]}/,/ default:/p" | grep -m 1 ' default:' | sed -n -e 's/^.*default: //p' | sed 's/currently:.*//' | xargs)

    if [ "$default" != "${arrIN[1]}" ]; then
      echo "${arrIN[0]}|${arrIN[1]}|$default"
    fi
done <<< "$c_gFlags"

exit 0
				
			

Example (for the ysql_enable_packed_row T-Server gFlag):

				
					[yugabyte@ip-10-38-1-248 ~]$ ./non-default-gflags.sh T 10.38.1.248:9000 ysql_enable_packed_row | column -t -s"|"
gFlag                   Current_Value  Default_Value
ysql_enable_packed_row  true           false
				
			

Example (for T-Server gFlag’s with “ysql_” in their name):

				
					[yugabyte@ip-10-38-1-248 ~]$ ./non-default-gflags.sh T 10.38.1.248:9000 ysql_ | column -t -s"|"
gFlag                        Current_Value  Default_Value
ysql_enable_auth             true           false
ysql_enable_packed_row       true           false
ysql_hba_conf                ****
ysql_hba_conf_csv            ****
ysql_num_shards_per_tserver  8              -1
				
			

If you want a complete list of gFlags having non-default values, simply leave off the the third parameter when calling the script.

Have Fun!

Anna Maria City Pier Anna Maria, FL