#!/usr/bin/env sh # Main WCBench script. WCBench wraps CBench in stuff to make it useful. # This script supports installing ODL, installing CBench, starting and # configuring ODL, running CBench against ODL, pinning ODL to a given # number of CPUs, using given-length CBench runs, collecting CBench # results and system stats, storing results in CSV format, stopping # ODL and removing all source/binaries installed by this script. # The main repo for WCBench is: https://github.com/dfarrell07/wcbench # See README.md for more details. # Exit codes EX_USAGE=64 EX_NOT_FOUND=65 EX_OK=0 EX_ERR=1 # Output verbose debug info (true) or not (anything else) VERBOSE=false # Params for CBench test and ODL config NUM_SWITCHES=32 # Default number of switches for CBench to simulate NUM_MACS=100000 # Default number of MACs for CBench to use TESTS_PER_SWITCH=10 # Default number of CBench tests to do per CBench run MS_PER_TEST=10000 # Default milliseconds to run each CBench test CBENCH_WARMUP=1 # Default number of warmup cycles to run CBench KARAF_SHELL_PORT=8101 # Port that the Karaf shell listens on CONTROLLER="OpenDaylight" # Currently only support ODL CONTROLLER_IP="localhost" # Change this to remote IP if running on two systems CONTROLLER_PORT=6633 # Default port for OpenDaylight SSH_HOSTNAME="cbenchc" # You'll need to update this to reflect ~/.ssh/config # Paths used in this script BASE_DIR=$HOME # Directory that code and such is dropped into OF_DIR=$BASE_DIR/openflow # Directory that contains OpenFlow code OFLOPS_DIR=$BASE_DIR/oflops # Directory that contains oflops repo ODL_DIR=$BASE_DIR/distribution-karaf-0.2.1-Helium-SR1 # Directory with ODL code ODL_ZIP="distribution-karaf-0.2.1-Helium-SR1.zip" # ODL zip name ODL_ZIP_PATH=$BASE_DIR/$ODL_ZIP # Full path to ODL zip PLUGIN_DIR=$ODL_DIR/plugins # ODL plugin directory RESULTS_FILE=$BASE_DIR/"results.csv" # File that results are stored in CBENCH_LOG=$BASE_DIR/"cbench.log" # Log file used to store strange error msgs CBENCH_BIN="/usr/local/bin/cbench" # Path to CBench binary OFLOPS_BIN="/usr/local/bin/oflops" # Path to oflops binary FEATURES_FILE=$ODL_DIR/etc/org.apache.karaf.features.cfg # Karaf features to install # Array that stores results in indexes defined by cols array declare -a results # The order of these array values determines column order in RESULTS_FILE cols=(run_num cbench_min cbench_max cbench_avg start_time end_time controller_ip human_time num_switches num_macs tests_per_switch ms_per_test start_steal_time end_steal_time total_ram used_ram free_ram cpus one_min_load five_min_load fifteen_min_load controller start_iowait end_iowait) # This two-stat-array system is needed until I find an answer to this question: # http://goo.gl/e0M8Tp # Associative array with stats-collecting commands for local system declare -A local_stats_cmds local_stats_cmds=([total_ram]="$(free -m | awk '/^Mem:/{print $2}')" [used_ram]="$(free -m | awk '/^Mem:/{print $3}')" [free_ram]="$(free -m | awk '/^Mem:/{print $4}')" [cpus]="`nproc`" [one_min_load]="`uptime | awk -F'[a-z]:' '{print $2}' | awk -F "," '{print $1}' | tr -d " "`" [five_min_load]="`uptime | awk -F'[a-z]:' '{print $2}' | awk -F "," '{print $2}' | tr -d " "`" [fifteen_min_load]="`uptime | awk -F'[a-z]:' '{print $2}' | awk -F "," '{print $3}' | tr -d " "`" [iowait]="`cat /proc/stat | awk 'NR==1 {print $6}'`" [steal_time]="`cat /proc/stat | awk 'NR==1 {print $9}'`") # Associative array with stats-collecting commands for remote system # See this for explanation of horrible-looking quoting: http://goo.gl/PMI5ag declare -A remote_stats_cmds remote_stats_cmds=([total_ram]='free -m | awk '"'"'/^Mem:/{print $2}'"'"'' [used_ram]='free -m | awk '"'"'/^Mem:/{print $3}'"'"'' [free_ram]='free -m | awk '"'"'/^Mem:/{print $4}'"'"'' [cpus]='nproc' [one_min_load]='uptime | awk -F'"'"'[a-z]:'"'"' '"'"'{print $2}'"'"' | awk -F "," '"'"'{print $1}'"'"' | tr -d " "' [five_min_load]='uptime | awk -F'"'"'[a-z]:'"'"' '"'"'{print $2}'"'"' | awk -F "," '"'"'{print $2}'"'"' | tr -d " "' [fifteen_min_load]='uptime | awk -F'"'"'[a-z]:'"'"' '"'"'{print $2}'"'"' | awk -F "," '"'"'{print $3}'"'"' | tr -d " "' [iowait]='cat /proc/stat | awk '"'"'NR==1 {print $6}'"'"'' [steal_time]='cat /proc/stat | awk '"'"'NR==1 {print $9}'"'"'') ############################################################################### # Prints usage message # Globals: # None # Arguments: # None # Returns: # None ############################################################################### usage() { cat << EOF Usage $0 [options] Setup and/or run CBench and/or OpenDaylight. OPTIONS: -h Show this message -v Output verbose debug info -c Install CBench -t