diff --git a/test/streaming/report.sh b/test/streaming/report.sh new file mode 100644 index 0000000000000000000000000000000000000000..ad1251a7cb908a97b4bb97834fc39c455cabbc5d --- /dev/null +++ b/test/streaming/report.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# This script reads stdin and expects the output of cvlc. +# It is used by the run.sh script and receives the output of the cvlc client. +# It counts the number of times the frame "dropping" error is seen and every 10 times it sends a message to telegraf reporting "another 10" errors. + +if [ "$#" -ne 1 ]; then + echo "Error: illegal number of arguments: "$# + echo "Usage: report.sh <client number>" + exit +fi + +COUNTER=$1 +TELEGRAF=http://localhost:8186 + +ERR_COUNT=0 +while read line; do + if [[ $line = *"dropping"* ]]; then + ERR_COUNT=$(($ERR_COUNT + 1)) + fi + TEN=$((ERR_COUNT % 10)) + if [ $TEN -eq 0 ]; then + curl -i -XPOST "${TELEGRAF}/write?precision=s" --data-binary "vlc,client=${COUNTER} drop_error=10 $(date +%s)" >& /dev/null + fi +done \ No newline at end of file diff --git a/test/streaming/run.sh b/test/streaming/run.sh index 2c8c930eee923ed84e22894ad5cf0f43cd865dfc..359204945167465d1920d88d6dc84930787fd9f1 100755 --- a/test/streaming/run.sh +++ b/test/streaming/run.sh @@ -31,7 +31,7 @@ if [ "$#" -ne 3 ]; then fi # create test directories -TEST_FOLDER=$(date +%Y%m%d%H%M%S) +TEST_FOLDER=$(date +%Y%m%d%H%M%S) TEST_RUN_DIR=$1 TEST_DIR=$TEST_RUN_DIR"/streaming/"$TEST_FOLDER echo "Test directory: "$TEST_DIR @@ -47,8 +47,8 @@ STREAM_URI=$2 COUNTER=0 MAX_CLIENTS=$3 while [ $COUNTER -lt $MAX_CLIENTS ]; do - cvlc -Vdummy --no-audio $STREAM_URI &>$TEST_DIR/stdout$COUNTER & - # cvlc -Vdummy --no-audio --verbose=0 --file-logging --logfile=$TEST_DIR/vlc-log$COUNTER.txt $STREAM_URI & + # run cvlc headless, redirect stderr into stdout, pipe that into the report.sh script + cvlc -Vdummy --no-audio $STREAM_URI 2>&1 | /home/ubuntu/flame-clmc/test/streaming/report.sh ${COUNTER} & sleep 1 let COUNTER=COUNTER+1 done diff --git a/test/streaming/stop.sh b/test/streaming/stop.sh index b9953899d5d08b3ead91d60438532524e5a19525..b332fe3b1d7d1e9ff2e974cb59b036e2252d0bc9 100755 --- a/test/streaming/stop.sh +++ b/test/streaming/stop.sh @@ -1,3 +1,4 @@ #!/bin/bash -for pid in $(ps -ef | grep "/usr/bin/vlc" | awk '{print $2}'); do kill -9 $pid; done \ No newline at end of file +for pid in $(ps -ef | grep "/usr/bin/vlc" | awk '{print $2}'); do kill -9 $pid; done +# TODO: 'killall vlc' should work: need to test though \ No newline at end of file