aboutsummaryrefslogtreecommitdiff
path: root/broccoli/script/measure-packets.sh
diff options
context:
space:
mode:
authorAndreas Lindhé <andreas@lindhe.io>2017-10-14 16:37:37 +0200
committerAndreas Lindhé <andreas@lindhe.io>2017-10-14 16:37:37 +0200
commitfcac1bc4ccef7bb180d97a47a9f84a097ef70e75 (patch)
tree1f491be967e599fd66bb9f3f9eb7575f2f649f1d /broccoli/script/measure-packets.sh
parent796ae574439a9532bb2988b53a999db265b8a4a6 (diff)
downloadmidbro-fcac1bc4ccef7bb180d97a47a9f84a097ef70e75.tar.gz
midbro-fcac1bc4ccef7bb180d97a47a9f84a097ef70e75.tar.bz2
Start by analyzing cpu idle load in script
Diffstat (limited to 'broccoli/script/measure-packets.sh')
-rw-r--r--broccoli/script/measure-packets.sh11
1 files 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