From ca5e039f4684787db5d65e8333f843525b3b877b Mon Sep 17 00:00:00 2001 From: Javi Date: Thu, 13 Apr 2023 11:55:11 -0500 Subject: [PATCH] Add ambr_speed option, this allow to change the speed value and version value of the script --- misc/db/open5gs-dbctl | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/misc/db/open5gs-dbctl b/misc/db/open5gs-dbctl index 5f179322e..f543bc365 100755 --- a/misc/db/open5gs-dbctl +++ b/misc/db/open5gs-dbctl @@ -1,6 +1,6 @@ #!/bin/bash -version=0.10.2 +version=0.10.3 display_help() { echo "open5gs-dbctl: Open5GS Database Configuration Tool ($version)" @@ -24,6 +24,7 @@ display_help() { echo " showall: shows the list of subscriber in the db" echo " showpretty: shows the list of subscriber in the db in a pretty json tree format" echo " showfiltered: shows {imsi key opc apn ip} information of subscriber" + echo " ambr_speed {imsi dl_value dl_unit ul_value ul_unit}: Change AMBR speed from a specific user and the unit values are \"[0=bps 1=Kbps 2=Mbps 3=Gbps 4=Tbps ]\"" } @@ -785,4 +786,44 @@ if [ "$1" = "showfiltered" ]; then exit $? fi +if [ "$1" = "ambr_speed" ]; then + if [ "$#" -eq 6 ]; then + IMSI=$2 + DL_VALUE=$3 + DL_UNIT=$4 + UL_VALUE=$5 + UL_UNIT=$6 + mongosh --eval "db.subscribers.updateOne({\"imsi\": \"$IMSI\"}, + {\$set: { + \"ambr\" : { + \"downlink\" : { + \"value\" : NumberInt($DL_VALUE), + \"unit\" : NumberInt($DL_UNIT) + }, + \"uplink\" :{ + \"value\": NumberInt($UL_VALUE), + \"unit\" : NumberInt($UL_UNIT) + } + }, + \"slice.0.session.0.ambr\": { + \"downlink\" : { + \"value\" : NumberInt($DL_VALUE), + \"unit\" : NumberInt($DL_UNIT) + }, + \"uplink\" :{ + \"value\": NumberInt($UL_VALUE), + \"unit\" : NumberInt($UL_UNIT) + } + } + } + });" $DB_URI + + + exit $? + fi + echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl ambr_speed imsi dl_value dl_unit ul_value ul_unit dl is for download and ul is for upload and the unit values are[0=bps 1=Kbps 2=Mbps 3=Gbps 4=Tbps ] \"" + exit 1 +fi + + display_help