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
This commit is contained in:
Zain Budhwani 2023-05-04 16:47:02 -07:00 committed by GitHub
parent 9e2b181fdc
commit 4974b5c49c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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}