This script is endless; you should echo a result for capturing a variable in WLSDM.

You should use the ping command like i.e. “ping $servername –c 1” then extract output from the ping command.

We are recommending you to use the script which is available in WLSDM README for pinging database. Please follow the readme link here: http://www.wlsdm.com/docs/README#VI.ConsoleUsage&DevOpsMBean

Also we are pasting below.

Step-1 Write Shell Script: Ping database and calculate database response time using WebLogic API (weblogic.jar)

#Variables _dbStatus=0 #0:DB_DOWN,1:DB_UP #start DB Ping _startTime=$(($(date +%s%N)/1000000)) _pingResult=`java -cp weblogic.jar utils.dbping ORACLE_THIN $YOUR_USER_NAME $YOUR_PASSWORD $YOUR_IP:$YOUR_PORT/$YOUR_SERVICE_NAME` _endTime=$(($(date +%s%N)/1000000)) _dbResponseTime=`expr $_endTime - $_startTime` if [[ "$_pingResult" == *"Success!!!"* ]]; then _dbStatus=1 #echo "Database connection SUCCESS!!!" #DB_UP echo DatabaseStatus=$_dbStatus else _dbStatus=0 #echo "Database connection FAILURE!!!" #DB_DOWN echo DatabaseStatus=$_dbStatus fi echo DatabaseResponseTime=$_dbResponseTime```