From fcac1bc4ccef7bb180d97a47a9f84a097ef70e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Lindh=C3=A9?= Date: Sat, 14 Oct 2017 16:37:37 +0200 Subject: Start by analyzing cpu idle load in script --- broccoli/script/measure-packets.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/broccoli/script/measure-packets.sh b/broccoli/script/measure-packets.sh index d79902e..9db9228 100644 --- a/broccoli/script/measure-packets.sh +++ b/broccoli/script/measure-packets.sh @@ -18,11 +18,10 @@ function measure_packets { BRO_PID=$(execute_command "bro -i \"${BRO_INTERFACE}\" -C -b Log::default_writer=Log::WRITER_NONE \"${BRO_SCRIPT}\" > ${BRO_DIR}/bro-out.txt 2> ${BRO_DIR}/bro-err.txt & echo \$!") - tcpreplay -i ${TCPREPLAY_INTERFACE} -M ${TCPREPLAY_SPEED} -L ${TCPREPLAY_COUNT} ${TCPREPLAY_DUMP} > /dev/null 2> /dev/null PCPU="100.0" - while [[ $(echo "${PCPU}>50" | bc) -eq 1 ]] + while [[ $(echo "${PCPU}>${IDLE}" | bc) -eq 1 ]] do sleep 1 PCPU=$(execute_command "ps -q ${BRO_PID} -o pcpu --no-headers") @@ -67,6 +66,14 @@ TCPREPLAY_DUMP=$(realpath "${TCPREPLAY_DUMP}") BRO_DIR=$(execute_command "mktemp --directory --tmpdir bro.XXX") +# First run a test to measure what CPU base load to wait for +BRO_PID=$(execute_command "bro -i \"${BRO_INTERFACE}\" -C -b Log::default_writer=Log::WRITER_NONE \"${BRO_SCRIPT}\" > ${BRO_DIR}/bro-out.txt 2> ${BRO_DIR}/bro-err.txt & echo \$!") +sleep 10 +IDLECPU=$(execute_command "ps -q ${BRO_PID} -o pcpu --no-headers") +IDLE=$(echo "${IDLECPU}+5.0" | bc); +echo "Idle baseload is: $IDLE"; +execute_command "killall bro" + echo -ne "sent\t" for SPEED in ${SPEEDS[@]} do -- cgit v1.2.1