feat(master : nicsensor) update to 1.9.7 【重要】
1.原生支持 stress 压力测试 2.新增stress_test插件
This commit is contained in:
parent
c7730923a1
commit
27ae0a4dc4
20
nicsensor.sh
20
nicsensor.sh
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
set -eo pipefail
|
||||
SCRIPT_VERSION="1.9.6"
|
||||
SCRIPT_VERSION="1.9.7"
|
||||
# ---------------------------------------------------------
|
||||
# Project Feature Varible (Change if need)
|
||||
# ---------------------------------------------------------
|
||||
@ -165,11 +165,16 @@ CONFIG_DIR="/tmp/nicsensor_config/"
|
||||
# ---------------------------------------------------------
|
||||
search_plugin_help(){
|
||||
PMBUS_PLUGIN="./pmbus_cmd_list.sh"
|
||||
STRESS_PLUGIN="./stress_test.sh"
|
||||
plugin_flag=0
|
||||
if [ -e ${PMBUS_PLUGIN} ];then
|
||||
$PMBUS_PLUGIN "help"
|
||||
plugin_flag=1
|
||||
fi
|
||||
if [ -e ${STRESS_PLUGIN} ];then
|
||||
$STRESS_PLUGIN "help"
|
||||
plugin_flag=1
|
||||
fi
|
||||
if [ $plugin_flag -eq 0 ];then
|
||||
echo " No Plugin found in file system"
|
||||
fi
|
||||
@ -591,6 +596,17 @@ pre_exec_hook(){
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$Param2" = "stress" ];then
|
||||
STRESS_PLUGIN="./stress_test.sh"
|
||||
if [ -e ${STRESS_PLUGIN} ];then
|
||||
${STRESS_PLUGIN} $Param3 $option_data
|
||||
exit 0
|
||||
else
|
||||
fmt_print "console" $ERROR "Can't find stress plugin file, please copy stress_test.sh to here!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# if the action is fru write, need pre-process fru data
|
||||
if [ "$Param2" = "fru" ];then
|
||||
if [ "$option_data" = "write" ];then
|
||||
@ -1722,8 +1738,6 @@ start_detect_device(){
|
||||
pre_exec_hook
|
||||
if [ "$1" = "version" ];then
|
||||
echo "Script Version : $SCRIPT_VERSION"
|
||||
echo "Debug Mode : $DEBUG_MODE"
|
||||
echo "Disable Detect : $DISABLE_DETECT"
|
||||
exit 0
|
||||
fi
|
||||
if [ "$1" = "detect" ];then
|
||||
|
||||
208
stress_test.sh
Normal file
208
stress_test.sh
Normal file
@ -0,0 +1,208 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Desc: Stress test script for nicsensor
|
||||
# Detail: This script will stress test the nicsensor by reading the sensor data
|
||||
# and print the result to the console.
|
||||
|
||||
EXTENSION_VERSION="v1.0"
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Varible Define
|
||||
# ---------------------------------------------------------
|
||||
Param1=$1
|
||||
Param2=$2
|
||||
|
||||
CONFIG_DIR="/tmp/nicsensor_config"
|
||||
CONFIG_NICSENSOR="${CONFIG_DIR}/stress_tool"
|
||||
CONFIG_SLOT="${CONFIG_DIR}/stress_slot"
|
||||
CONFIG_SENSOR="${CONFIG_DIR}/stress_sensor"
|
||||
CONFIG_ROUND="${CONFIG_DIR}/stress_round"
|
||||
CONFIG_INTERVAL="${CONFIG_DIR}/stress_interval"
|
||||
CONFIG_SLAVE="${CONFIG_DIR}/stress_slave"
|
||||
|
||||
config_tool=""
|
||||
# ---------------------------------------------------------
|
||||
# Function Define
|
||||
# ---------------------------------------------------------
|
||||
print_usage(){
|
||||
echo " Extend Function - Stress Test"
|
||||
echo " Version: $EXTENSION_VERSION"
|
||||
echo " 1) Description"
|
||||
echo " This plugin will stress test the nicsensor by reading the sensor data"
|
||||
echo " and print the result to the console."
|
||||
echo " 2) Command Format : ./nicsensor.sh [slot] stress [option] [data]"
|
||||
echo " 3) Option Detail"
|
||||
echo " - [slot] : The nicsensor slot number"
|
||||
echo " - [option] : start|show|round|tool|interval|slot|sensor|slave"
|
||||
echo " - [data] : The option data"
|
||||
echo " 4) Example"
|
||||
echo " Case: Test PCIe1 Nic's INA3221, slave=0x42, round=1000, interval=3s"
|
||||
echo " Step 1 : Set the stress test parameter"
|
||||
echo " ./nicsensor.sh pcie1 stress slot pcie1"
|
||||
echo " ./nicsensor.sh pcie1 stress round 1000"
|
||||
echo " ./nicsensor.sh pcie1 stress interval 3"
|
||||
echo " ./nicsensor.sh pcie1 stress sensor ina3221"
|
||||
echo " ./nicsensor.sh pcie1 stress slave 0x42"
|
||||
echo " Step 2 : Check the stress test configuration"
|
||||
echo " ./nicsensor.sh pcie1 stress show"
|
||||
echo " Step 3 : Start the stress test"
|
||||
echo " ./nicsensor.sh pcie1 stress start"
|
||||
}
|
||||
|
||||
set_stress_config(){
|
||||
case ${Param1} in
|
||||
"round")
|
||||
echo "Set the stress test round to ${Param2}"
|
||||
echo ${Param2} > ${CONFIG_ROUND}
|
||||
;;
|
||||
"interval")
|
||||
echo "Set the stress test interval to ${Param2}s"
|
||||
echo ${Param2} > ${CONFIG_INTERVAL}
|
||||
;;
|
||||
"sensor")
|
||||
echo "Set the stress test sensor to ${Param2}"
|
||||
echo ${Param2} > ${CONFIG_SENSOR}
|
||||
;;
|
||||
"slave")
|
||||
echo "Set the stress test slave to ${Param2}"
|
||||
echo ${Param2} > ${CONFIG_SLAVE}
|
||||
;;
|
||||
"slot")
|
||||
echo "Set the stress test slot to ${Param2}"
|
||||
echo ${Param2} > ${CONFIG_SLOT}
|
||||
;;
|
||||
"tool")
|
||||
echo "Set the stress test tool to ${Param2}"
|
||||
echo ${Param2} > ${CONFIG_NICSENSOR}
|
||||
;;
|
||||
*)
|
||||
echo "Invalid option: ${Param1}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
get_stress_all_config(){
|
||||
echo "Stress Test Config:"
|
||||
if [ -f ${CONFIG_NICSENSOR} ]; then
|
||||
echo " Tool : $(cat ${CONFIG_NICSENSOR})"
|
||||
else
|
||||
echo " Tool : nicsensor.sh"
|
||||
fi
|
||||
if [ -f ${CONFIG_ROUND} ]; then
|
||||
echo " Round : $(cat ${CONFIG_ROUND})"
|
||||
else
|
||||
echo " Round : Not Set"
|
||||
fi
|
||||
if [ -f ${CONFIG_INTERVAL} ]; then
|
||||
echo " Interval: $(cat ${CONFIG_INTERVAL})s"
|
||||
else
|
||||
echo " Interval: Not Set"
|
||||
fi
|
||||
if [ -f ${CONFIG_SLOT} ]; then
|
||||
echo " Slot : $(cat ${CONFIG_SLOT})"
|
||||
else
|
||||
echo " Slot : Not Set"
|
||||
fi
|
||||
if [ -f ${CONFIG_SENSOR} ]; then
|
||||
echo " Sensor : $(cat ${CONFIG_SENSOR})"
|
||||
else
|
||||
echo " Sensor : Not Set"
|
||||
fi
|
||||
if [ -f ${CONFIG_SLAVE} ]; then
|
||||
echo " Slave : $(cat ${CONFIG_SLAVE})"
|
||||
else
|
||||
echo " Slave : Not Set"
|
||||
fi
|
||||
}
|
||||
|
||||
start_stress_test(){
|
||||
# nicsensor tool check
|
||||
if [ -f ${CONFIG_NICSENSOR} ]; then
|
||||
config_tool=$(cat ${CONFIG_NICSENSOR})
|
||||
else
|
||||
config_tool="nicsensor.sh"
|
||||
fi
|
||||
if [ ! -f "./${config_tool}" ]; then
|
||||
echo "Error: ${config_tool} tool not found"
|
||||
echo "Info : Please check the nicsensor tool path and name"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# option check
|
||||
if [ ! -f ${CONFIG_ROUND} ]; then
|
||||
echo "Error: Round is not set"
|
||||
echo "Info : Please set the stress test round first, use command: ./nicsensor.sh [slot] stress round [data]"
|
||||
return 1
|
||||
fi
|
||||
if [ ! -f ${CONFIG_INTERVAL} ]; then
|
||||
echo "Error: Interval is not set"
|
||||
echo "Info : Please set the stress test interval first, use command: ./nicsensor.sh [slot] stress interval [data]"
|
||||
return 1
|
||||
fi
|
||||
if [ ! -f ${CONFIG_SLOT} ]; then
|
||||
echo "Error: Slot is not set"
|
||||
echo "Info : Please set the stress test slot first, use command: ./nicsensor.sh [slot] stress slot [data]"
|
||||
return 1
|
||||
fi
|
||||
if [ ! -f ${CONFIG_SENSOR} ]; then
|
||||
echo "Error: Sensor is not set"
|
||||
echo "Info : Please set the stress test sensor first, use command: ./nicsensor.sh [slot] stress sensor [data]"
|
||||
return 1
|
||||
fi
|
||||
if [ ! -f ${CONFIG_SLAVE} ]; then
|
||||
echo "Error: Slave is not set"
|
||||
echo "Info : Please set the stress test slave first, use command: ./nicsensor.sh [slot] stress slave [data]"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# start stress test
|
||||
echo "Stress Test Config Info:"
|
||||
config_round=$(cat ${CONFIG_ROUND})
|
||||
config_interval=$(cat ${CONFIG_INTERVAL})
|
||||
config_slot=$(cat ${CONFIG_SLOT})
|
||||
config_sensor=$(cat ${CONFIG_SENSOR})
|
||||
config_slave=$(cat ${CONFIG_SLAVE})
|
||||
echo " Round : ${config_round}"
|
||||
echo " Interval: ${config_interval}s"
|
||||
echo " Slot : ${config_slot}"
|
||||
echo " Sensor : ${config_sensor}"
|
||||
echo " Slave : ${config_slave}"
|
||||
|
||||
run_count=1
|
||||
while [ ${run_count} -le ${config_round} ]; do
|
||||
timestamp=$(date +"%Y-%m-%dT%H:%M:%S")
|
||||
echo "====== ${timestamp}, Run Count: ${run_count}"
|
||||
exec_cmd="./${config_tool} ${config_slot} ${config_sensor} ${config_slave}"
|
||||
${exec_cmd}
|
||||
sleep ${config_interval}
|
||||
run_count=$((run_count+1))
|
||||
done
|
||||
|
||||
echo "==========================================="
|
||||
echo " Stress Test Completed"
|
||||
}
|
||||
|
||||
main(){
|
||||
cmd=${Param1}
|
||||
case ${cmd} in
|
||||
"start")
|
||||
echo "Start the stress test"
|
||||
start_stress_test
|
||||
;;
|
||||
"show")
|
||||
echo "Show the stress test configuration"
|
||||
get_stress_all_config
|
||||
;;
|
||||
"help")
|
||||
print_usage
|
||||
;;
|
||||
*)
|
||||
echo "Set Stress Config"
|
||||
set_stress_config
|
||||
;;
|
||||
esac
|
||||
}
|
||||
# ---------------------------------------------------------
|
||||
# Start Execute Script(main)
|
||||
# ---------------------------------------------------------
|
||||
main
|
||||
Loading…
Reference in New Issue
Block a user