summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfumingwei <[email protected]>2022-10-09 15:26:11 +0800
committerfumingwei <[email protected]>2022-10-09 17:28:31 +0800
commit01cf2b263940cb5313218e54660ca289307f1248 (patch)
tree6dcdbf558958a8e433fbd48b76388d4e74ed03b8
parente5a79a44ac009d9f360a5a002f31d6f61b8a49f3 (diff)
feature:新增max_service_function_index和list_service_function_index输入配置项v2.0.3
-rw-r--r--images_build/client/dign_client/bin/client.py27
-rw-r--r--scripts/tsg-diagnose-oneshot23
-rw-r--r--scripts/tsg-diagnose-periodical23
3 files changed, 53 insertions, 20 deletions
diff --git a/images_build/client/dign_client/bin/client.py b/images_build/client/dign_client/bin/client.py
index d3a3d29..bf5d18c 100644
--- a/images_build/client/dign_client/bin/client.py
+++ b/images_build/client/dign_client/bin/client.py
@@ -1254,7 +1254,8 @@ class TsgDiagnose:
self.client = None
self.config_dict = {}
self.dign_duration = 0
- self.count_service_function = 1
+ self.max_service_function_index = 1
+ self.list_service_function_index = []
def _get_dign_option(self):
parser = argparse.ArgumentParser(description="Tsg Tools - tsg diagnose", epilog = "Example:help")
@@ -1262,13 +1263,15 @@ class TsgDiagnose:
parser.add_argument('-c','--count', type = int, default = 1, help='Specifies the count of tsg diagnoses ,range:1-65535')
parser.add_argument('-p','--configpath', type = str, default = '/opt/dign_client/etc/client.conf',help='Specifies the config file, default /opt/dign_client/etc/client.conf')
parser.add_argument('-l','--loop', action='store_true', default = False, help='Tsg diagnose loop, exit when recv a signal')
- parser.add_argument('-C','--count_service_function', type = int, default = 1, help='Specifies the counts of service_function ,range:1-256')
+ parser.add_argument('-m','--max_service_function_index', type = int, default = 1, help='Specifies the max index of service_function,range:1-256')
+ parser.add_argument('-d','--list_service_function_index', nargs='+', type = int, help='Specifies the list of service function index')
args = parser.parse_args()
self.interval = args.interval
self.loop = args.loop
self.count = args.count
self.config = args.configpath
- self.count_service_function = args.count_service_function
+ self.max_service_function_index = args.max_service_function_index
+ self.list_service_function_index = args.list_service_function_index
if self.count == 0:
print("Error: bad number of tsg diagnose and will exit")
parser.print_help()
@@ -1359,11 +1362,19 @@ class TsgDiagnose:
print(format(("Service function id:" + str(id_service_function) + ",Test end time: " + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())),'=^70s'))
def _dign_service_function_running(self):
- for id_service_function in range(1,self.count_service_function + 1):
- set_http_request_resolve(id_service_function)
- set_dns_server_ip(id_service_function)
- #print(REQUEST_RESOLVE)
- self._dign_running(id_service_function)
+ if self.list_service_function_index == None:
+ for id_service_function in range(1,self.max_service_function_index + 1):
+ set_http_request_resolve(id_service_function)
+ set_dns_server_ip(id_service_function)
+ #print(REQUEST_RESOLVE)
+ self._dign_running(id_service_function)
+ else:
+ self.list_service_function_index.sort()
+ for id_service_function in self.list_service_function_index:
+ set_http_request_resolve(id_service_function)
+ set_dns_server_ip(id_service_function)
+ #print(REQUEST_RESOLVE)
+ self._dign_running(id_service_function)
def dign_exec(self):
self._get_dign_option()
diff --git a/scripts/tsg-diagnose-oneshot b/scripts/tsg-diagnose-oneshot
index 6a973fc..059bf3c 100644
--- a/scripts/tsg-diagnose-oneshot
+++ b/scripts/tsg-diagnose-oneshot
@@ -1,8 +1,9 @@
#!/bin/bash -e
K3S_BIN_PATH="/usr/bin/k3s"
-count_service_function=1
+max_service_function_index=1
+service_function_index=""
-ARGS=`getopt -a -o c:h -l count-service-function:,help -- "$@"`
+ARGS=`getopt -a -o m:i:h -l max-service-function-index:,service-function-index:,help -- "$@"`
eval set -- "${ARGS}"
usage(){
echo ""
@@ -10,7 +11,10 @@ usage(){
echo ""
echo "Options:"
echo " -h --help Detailed usage syntax"
- echo " -c --count-service-function Count of service-function,default:1"
+ echo " -m --max-service-function-index Count of service-function,default:1"
+ echo " -i --service-function-index List of service-function index"
+ echo "Example: tsg-diagnose-oneshot -m 5"
+ echo " or tsg-diagnose-oneshot -i 1 -i 2 -i 3"
exit 0
}
@@ -18,8 +22,11 @@ function get_args(){
while true
do
case "$1" in
- -c|--count-sf)
- export count_service_function=$2
+ -m|--max-service-function-index)
+ export max_service_function_index=$2
+ ;;
+ -i|--service-function-index)
+ export service_function_index="$2 $service_function_index"
;;
-h|--help)
usage
@@ -36,7 +43,11 @@ function get_args(){
get_args $@
if [ -f "$K3S_BIN_PATH" ]; then
- kubectl exec -it daemonset/dign-client -- python bin/client.py -C $count_service_function
+ if [ -z "$service_function_index" ]; then
+ kubectl exec -it daemonset/dign-client -- python bin/client.py -m $max_service_function_index
+ else
+ kubectl exec -it daemonset/dign-client -- python bin/client.py -d $service_function_index
+ fi
else
systemctl start tsg-diagnose
sleep 10
diff --git a/scripts/tsg-diagnose-periodical b/scripts/tsg-diagnose-periodical
index c4d83a9..e758154 100644
--- a/scripts/tsg-diagnose-periodical
+++ b/scripts/tsg-diagnose-periodical
@@ -1,8 +1,9 @@
#!/bin/bash -e
K3S_BIN_PATH="/usr/bin/k3s"
-count_service_function=1
+max_service_function_index=1
+service_function_index=""
-ARGS=`getopt -a -o c:h -l count-service-function:,help -- "$@"`
+ARGS=`getopt -a -o m:i:h -l max-service-function-index:,service-function-index:,help -- "$@"`
eval set -- "${ARGS}"
usage(){
echo ""
@@ -10,7 +11,10 @@ usage(){
echo ""
echo "Options:"
echo " -h --help Detailed usage syntax"
- echo " -c --count-service-function Count of service-function,default:1"
+ echo " -m --max-service-function-index Count of service-function,default:1"
+ echo " -i --service-function-index List of service-function index"
+ echo "Example: tsg-diagnose-oneshot -m 5"
+ echo " or tsg-diagnose-oneshot -i 1 -i 2 -i 3"
exit 0
}
@@ -18,8 +22,11 @@ function get_args(){
while true
do
case "$1" in
- -c|--count-sf)
- export count_service_function=$2
+ -m|--max-service-function-index)
+ export max_service_function_index=$2
+ ;;
+ -i|--service-function-index)
+ export service_function_index="$2 $service_function_index"
;;
-h|--help)
usage
@@ -36,7 +43,11 @@ function get_args(){
get_args $@
if [ -f "$K3S_BIN_PATH" ]; then
- kubectl exec -it daemonset/dign-client -- python bin/client.py -C $count_service_function
+ if [ -z "$service_function_index" ]; then
+ kubectl exec -it daemonset/dign-client -- python bin/client.py -m $max_service_function_index -l
+ else
+ kubectl exec -it daemonset/dign-client -- python bin/client.py -d $service_function_index -l
+ fi
else
systemctl start tsg-diagnose
sleep 10