You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
3.3 KiB

  1. #!/bin/bash
  2. # start-virl-topology-benchmark.sh
  3. # HS-Fulda - sebastian.rieger@informatik.hs-fulda.de
  4. #
  5. # changelog:
  6. # V1.0 initial version
  7. # usage
  8. if [ ! $# -gt 4 ] ; then
  9. echo -e "usage: $0 <my-topology.virl> <number of concurrent simulations> <username> <password> <timeout> [debug level], e.g.,\n"
  10. echo "$0 /home/virl/git-virl-hs-fulda/GIT-VIRL-HS-Fulda/advcompnet-lab2-dcn-fabricpath.virl 6 guest password"
  11. exit -1
  12. fi
  13. TOPOLOGY=$1
  14. RUNCOUNT=$2
  15. USERNAME=$3
  16. PASSWORD=$4
  17. TIMEOUT=$5
  18. if [ $6 ]; then
  19. DEBUG=$6
  20. else
  21. DEBUG=0
  22. fi
  23. TOPOLOGYFILENAME=$(basename $TOPOLOGY)
  24. TIMESTAMP=$(date +%H%M%S)
  25. FILENAME="VIRLBENCH-$TIMESTAMP@$TOPOLOGYFILENAME"
  26. DATE=$(date)
  27. echo "Script started at $DATE"
  28. # start the simulations
  29. RUN=0
  30. while [ $RUN -lt $RUNCOUNT ]
  31. do
  32. # use simengine-launch to start the simulation
  33. if [ $DEBUG -lt 2 ]; then
  34. virl_std_client --username $USERNAME --password $PASSWORD simengine-launch \
  35. --virl-file $TOPOLOGY --file-name $FILENAME >/dev/null 2>&1
  36. else
  37. virl_std_client --username $USERNAME --password $PASSWORD simengine-launch \
  38. --virl-file $TOPOLOGY --file-name $FILENAME
  39. fi
  40. RUN=$(expr $RUN + 1)
  41. done
  42. DATE=$(date)
  43. echo "Started at $DATE"
  44. RUNNING=true
  45. # wait for simulations to start
  46. sleep 5
  47. # get all running benchmark simulations
  48. SIMS=$(virl_std_client --username $USERNAME --password $PASSWORD --quiet --json simengine-list 2>&1 | egrep -o -e "VIRLBENCH-$TIMESTAMP@(.*)-[_a-zA-Z0-9]{6}")
  49. if [ $DEBUG -gt 1 ]; then
  50. echo "Running simulations:"
  51. for SIM in $SIMS; do
  52. echo $SIM
  53. done
  54. echo
  55. fi
  56. # count nodes in the running benchmark simulations
  57. NODE_COUNT=0
  58. for SIM in $SIMS; do
  59. SIM_NODE_COUNT=$(virl_std_client --username $USERNAME --password $PASSWORD simengine-nodes --session-id $SIM 2>&1 | grep -c state)
  60. if [ $DEBUG -gt 1 ]; then
  61. echo "$SIM has $SIM_NODE_COUNT nodes"
  62. fi
  63. NODE_COUNT=$(expr $NODE_COUNT + $SIM_NODE_COUNT)
  64. done
  65. if [ $DEBUG -gt 0 ] ; then echo "$NODE_COUNT nodes"; fi
  66. # continuously count all ACTIVE nodes in running benchmark simulations until all nodes are ACTIVE
  67. ACTIVE_COUNT=0
  68. while [ $ACTIVE_COUNT -lt $NODE_COUNT ]
  69. do
  70. ACTIVE_COUNT=0
  71. for SIM in $SIMS; do
  72. SIM_NODE_ACTIVE_COUNT=$(virl_std_client --username $USERNAME --password $PASSWORD simengine-nodes --session-id $SIM 2>&1 | grep -c ACTIVE)
  73. if [ $DEBUG -gt 1 ]; then
  74. echo "$SIM has $SIM_NODE_ACTIVE_COUNT active nodes"
  75. fi
  76. ACTIVE_COUNT=$(expr $ACTIVE_COUNT + $SIM_NODE_ACTIVE_COUNT)
  77. done
  78. if [ $DEBUG -gt 0 ] ; then echo "$ACTIVE_COUNT of $NODE_COUNT are ACTIVE"; fi
  79. sleep 1
  80. done
  81. DATE=$(date)
  82. echo "Active at $DATE"
  83. # Check if the nodes are ready-for-use using expect
  84. ./check-reachability $USERNAME $TIMEOUT "VIRLBENCH-$TIMESTAMP" $DEBUG
  85. # Check using load
  86. # Alternative to check if nodes are ready, use CPU load threshold for VMs (IOSv and IOSvL2 have a high CPU load during initial boot)
  87. #THRESHOLD="70.0"
  88. #while $RUNNING = true
  89. #do
  90. # VM_LOADS=$(top -n 1 | grep kvm.real | tr -s " " | cut -d " " -f 9)
  91. #
  92. # VMS_WITH_HIGH_CPU_LOAD=0
  93. # for VM_LOAD in $VM_LOADS
  94. # do
  95. # if [ $(echo "$VM_LOAD > $THRESHOLD" | bc) -eq 1 ] ; then
  96. # VMS_WITH_HIGH_CPU_LOAD=$(expr $VMS_WITH_HIGH_CPU_LOAD + 1)
  97. # echo "$VM_LOAD > 6x0.0"
  98. # fi
  99. # done
  100. #
  101. # if [ $VMS_WITH_HIGH_CPU_LOAD -gt 0 ]; then
  102. # echo "cpu load = high"
  103. # else
  104. # RUNNING=false
  105. # fi
  106. #done
  107. DATE=$(date)
  108. echo "Finished at $DATE"