summaryrefslogtreecommitdiffstats
path: root/Bombs/cpu/sx.sh
blob: e028787845935878f56e21053ac6606c5c62bcea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
export TERM=xterm
pid=0

function display_container_header {
    echo "+====================================================="
    echo "| Container   : $HOSTNAME"
    echo "| OS          : $(</etc/redhat-release)"
    echo "| kubernetes  : $KUBERNETES_SERVICE_HOST"
    echo "| user        : $(</etc/whoami)"
    echo "+====================================================="
}

function start_service {
    if [ ! -v TEST_DURATION ]; then
        TEST_DURATION=10;
        export TEST_DURATION;
    fi
    if echo $TEST_DURATION | egrep -q '^[0-9]+$'; then
        echo "" > /dev/null &
    else
        TEST_DURATION=10;
    fi
    echo "+====================================================="
    echo "| Container $HOSTNAME is now bombing CPU for $TEST_DURATION sec"
    echo "+====================================================="
    /bin/bomb > /dev/null &
    TASK_PID=$!
    sleep $TEST_DURATION
    kill $TASK_PID
    exit 0
}

display_container_header
start_service