From b455e18eef18d5fcf30cd1fe2ee83906a6b0ee12 Mon Sep 17 00:00:00 2001 From: Michael McMahon Date: Thu, 16 Nov 2017 12:06:30 -0500 Subject: [PATCH] Add stress bundle --- src/.config | 7 ++++ src/README | 4 ++ src/minimal_overlay/bundles/stress/01_get.sh | 41 +++++++++++++++++++ .../bundles/stress/02_build.sh | 38 +++++++++++++++++ src/minimal_overlay/bundles/stress/bundle.sh | 9 ++++ 5 files changed, 99 insertions(+) create mode 100755 src/minimal_overlay/bundles/stress/01_get.sh create mode 100755 src/minimal_overlay/bundles/stress/02_build.sh create mode 100755 src/minimal_overlay/bundles/stress/bundle.sh diff --git a/src/.config b/src/.config index b13145492..7628b6da3 100644 --- a/src/.config +++ b/src/.config @@ -133,6 +133,12 @@ OPENJDK_URL=http://download.java.net/java/GA/jdk9/9/binaries/jdk-9+181_linux-x64 # STATIC_GET_SOURCE_URL=http://s.minos.io/s +# You can find the latest stress archives here: +# +# https://people.seas.harvard.edu/~apw/stress/ +# +STRESS_SOURCE_URL=https://people.seas.harvard.edu/~apw/stress/stress-1.0.4.tar.gz + # You can find the latest util_linux archives here: # # https://www.kernel.org/pub/linux/utils/util-linux/ @@ -245,6 +251,7 @@ COPY_SOURCE_ISO=true # nweb - simple mini http server. # openjdk - installs Open JDK. All operations are automated. # static_get - portable binaries for Linux (http://s.minos.io). +# stress - CPU and RAM load generator. # util_linux - set of executable utilities distributed by the Linux Kernel Org. # vim - an advanced text editor. # zlib - DEFLATE compression/decompression library. diff --git a/src/README b/src/README index d96b286ee..b63b32837 100644 --- a/src/README +++ b/src/README @@ -94,6 +94,10 @@ Currently available overlay bundles: '-net nic,model=e1000 -net user,hostfwd=tcp::8080-:80' to 'cmd' in the qemu.sh file. +* stress - simple workload generator. Imposes a configurable amount of CPU, + memory, I/O, and disk stress on the system. stress is useful for + troubleshooting CPU and RAM. + * util_linux - Set of executable utilities distributed by the Linux Kernel similar to busybox or GNU Core Utils. diff --git a/src/minimal_overlay/bundles/stress/01_get.sh b/src/minimal_overlay/bundles/stress/01_get.sh new file mode 100755 index 000000000..c355eba02 --- /dev/null +++ b/src/minimal_overlay/bundles/stress/01_get.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +SRC_DIR=$(pwd) + +. ../../common.sh + +# Grab everything after the '=' character. +DOWNLOAD_URL=$(grep -i STRESS_SOURCE_URL $MAIN_SRC_DIR/.config | cut -f2 -d'=') + +# Grab everything after the last '/' character. +ARCHIVE_FILE=${DOWNLOAD_URL##*/} + +# Read the 'USE_LOCAL_SOURCE' property from '.config' +USE_LOCAL_SOURCE="$(grep -i USE_LOCAL_SOURCE $MAIN_SRC_DIR/.config | cut -f2 -d'=')" + +if [ "$USE_LOCAL_SOURCE" = "true" -a ! -f $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE ] ; then + echo "Source bundle $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE is missing and will be downloaded." + USE_LOCAL_SOURCE="false" +fi + +cd $MAIN_SRC_DIR/source/overlay + +if [ ! "$USE_LOCAL_SOURCE" = "true" ] ; then + # Downloading stress source bundle file. The '-c' option allows the download to resume. + echo "Downloading stress source bundle from $DOWNLOAD_URL" + wget -c $DOWNLOAD_URL +else + echo "Using local stress source bundle $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE" +fi + +# Delete folder with previously extracted stress. +echo "Removing stress work area. This may take a while..." +rm -rf $WORK_DIR/overlay/stress +mkdir $WORK_DIR/overlay/stress + +# Extract stress to folder 'work/overlay/stress'. +# Full path will be something like 'work/overlay/stress/stress-1.0.4'. +tar -xvf $ARCHIVE_FILE -C $WORK_DIR/overlay/stress + +cd $SRC_DIR + diff --git a/src/minimal_overlay/bundles/stress/02_build.sh b/src/minimal_overlay/bundles/stress/02_build.sh new file mode 100755 index 000000000..6c1598a64 --- /dev/null +++ b/src/minimal_overlay/bundles/stress/02_build.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +SRC_DIR=$(pwd) + +. ../../common.sh + +cd $WORK_DIR/overlay/stress + +DESTDIR="$PWD/stress_installed" + +# Change to the stress source directory which ls finds, e.g. 'stress-1.0.4'. +cd $(ls -d stress-*) + +echo "Preparing stress work area. This may take a while..." +make -j $NUM_JOBS clean + +rm -rf $DESTDIR + +echo "Configuring stress..." +CFLAGS="$CFLAGS" ./configure \ + --prefix=/usr + +echo "Building stress..." +make -j $NUM_JOBS + +echo "Installing stress..." +make -j $NUM_JOBS install DESTDIR=$DESTDIR + +echo "Reducing stress size..." +strip -g $DESTDIR/usr/bin/* + +ROOTFS="$WORK_DIR/src/minimal_overlay/rootfs" + +cp -r $DESTDIR/* $ROOTFS + +echo "stress has been installed." + +cd $SRC_DIR diff --git a/src/minimal_overlay/bundles/stress/bundle.sh b/src/minimal_overlay/bundles/stress/bundle.sh new file mode 100755 index 000000000..ffd32c002 --- /dev/null +++ b/src/minimal_overlay/bundles/stress/bundle.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +SRC_DIR=$(pwd) + +./01_get.sh +./02_build.sh + +cd $SRC_DIR +