From 4974b5c49c321f68404f9bda84fb898cd2df16ab Mon Sep 17 00:00:00 2001 From: Zain Budhwani <99770260+zbud-msft@users.noreply.github.com> Date: Thu, 4 May 2023 16:47:02 -0700 Subject: [PATCH] Add idle conn duration config to telemetry.sh (#14903) Why I did it Supports new field in sonic-net/sonic-gnmi@258b887 Work item tracking Microsoft ADO (number only): 13468195 How I did it Add new field in telemetry.sh How to verify it Pipeline --- dockers/docker-sonic-telemetry/telemetry.sh | 23 ++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/dockers/docker-sonic-telemetry/telemetry.sh b/dockers/docker-sonic-telemetry/telemetry.sh index f0d16b212..c7693adc1 100755 --- a/dockers/docker-sonic-telemetry/telemetry.sh +++ b/dockers/docker-sonic-telemetry/telemetry.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash EXIT_TELEMETRY_VARS_FILE_NOT_FOUND=1 +INCORRECT_TELEMETRY_VALUE = 2 TELEMETRY_VARS_FILE=/usr/share/sonic/templates/telemetry_vars.j2 if [ ! -f "$TELEMETRY_VARS_FILE" ]; then @@ -69,11 +70,31 @@ else TELEMETRY_ARGS+=" -v=2" fi +# Server will handle threshold connections consecutively THRESHOLD_CONNECTIONS=$(echo $GNMI | jq -r '.threshold') if [[ $THRESHOLD_CONNECTIONS =~ ^[0-9]+$ ]]; then TELEMETRY_ARGS+=" --threshold $THRESHOLD_CONNECTIONS" else - TELEMETRY_ARGS+=" --threshold 100" + if [[ $THRESHOLD_CONNECTIONS == "null" ]]; then + TELEMETRY_ARGS+=" --threshold 100" + else + echo "Incorrect threshold value, expecting positive integers" >&2 + exit $INCORRECT_TELEMETRY_VALUE + fi fi +# Close idle connections after certain duration (in seconds) +IDLE_CONN_DURATION=$(echo $GNMI | jq -r '.idle_conn_duration') +if [[ $IDLE_CONN_DURATION =~ ^[0-9]+$ ]]; then + TELEMETRY_ARGS+=" --idle_conn_duration $IDLE_CONN_DURATION" +else + if [[ $IDLE_CONN_DURATION == "null" ]]; then + TELEMETRY_ARGS+=" --idle_conn_duration 5" + else + echo "Incorrect idle_conn_duration value, expecting positive integers" >&2 + exit $INCORRECT_TELEMETRY_VALUE + fi +fi + + exec /usr/sbin/telemetry ${TELEMETRY_ARGS}