···1212 * Configured to generate concurrent requests and duration of load using ENVs
1313 * Randomized path (`RANDOMIZE=true`)
1414 * Randomized User-Agent
1515+* forked [goeffel](https://github.com/FoxxMD/goeffel) for capturing process activity
15161616-Additionally, the bash script [`bench.sh`](/bench.sh) can be used to orchestrate the load call, monitor the crowdsec process, and create a .png plot of CPU using [`goeffel`](https://github.com/jgehrcke/goeffel), if it installed.
1717+Additionally, the bash script [`bench.sh`](/bench.sh) can be used to orchestrate the load call, monitor the crowdsec process, and create a .png plot of CPU using [`goeffel`](https://github.com/jgehrcke/goeffel).
17181819# Usage
1920···30313132### Using `bench.sh`
32333333-Install latest development [`goeffel`](hhttps://github.com/jgehrcke/goeffel) version:
3434-3534```shell
3636-pipx install git+https://github.com/foxxmd/goeffel@flexplotStyling
3737-```
3838-3939-Run `bench.sh` from the project directory. It requires `sudo` to collect metrics.
4040-4141-```shell
4242-sudo ./bench.sh
3535+./bench.sh
4336```
44374545-If the script reports that `goeffel` can not be found you can specify the location of the binary as an argument:
4646-4747-```shell
4848-$ which goeffel
4949-/home/myUser/.local/bin/goeffel
5050-$ sudo ./bench.sh /home/myUser/.local/bin/goeffel
5151-```
5252-5353-After the run has finished an image `[date]_crowdsec-web-traffic-load-[unix_timestamp].png` will be generated in the project directory.
3838+After the run has finished an image `[date]_crowdsec-web-traffic-load-[unix_timestamp].png` will be generated in `./data/goeffel` directory.
54395540Additional graphs can be plotted from the generated `hdf5` file using [`goeffel-analysis`](https://github.com/jgehrcke/goeffel?tab=readme-ov-file#goeffel-analysis-data-inspection-and-visualization).
5641···6348```
644965502. Start any monitoring/profiling software for crowdsec
5151+5252+Using the goeffel container EX:
5353+5454+```shell
5555+docker compose run --rm --no-TTY goeffel goeffel --pid MY_COOL_PROGRAM_PID
5656+```
665767583. Run load
6859
+10-35
bench.sh
···11#!/bin/bash
2233-CMD=${1:-goeffel}
44-CMD_ANALYSIS="${CMD}-analysis"
55-66-if ! command -v $CMD >/dev/null 2>&1
77-then
88- echo "$CMD could not be found, please make sure it is installed and this shell can access it."
99- exit 1
1010-fi
1111-1212-## https://askubuntu.com/a/970898
1313-if ! [ $(id -u) = 0 ]; then
1414- echo "The script need to be run as root." >&2
1515- exit 1
1616-fi
1717-1818-if [ $SUDO_USER ]; then
1919- real_user=$SUDO_USER
2020-else
2121- real_user=$(whoami)
2222-fi
2323-2424-trap 'exit 0;' SIGHUP SIGINT SIGKILL
33+trap 'exit 0;' SIGHUP SIGINT
254265printf 'Starting traefik and echo...\n'
2727-sudo -u $real_user docker compose up traefik echo -d
66+docker compose up traefik echo -d
287298printf 'Starting crowdsec container...\n'
3030-sudo -u $real_user docker compose up crowdsec -d
99+docker compose up crowdsec -d
31103211CS_PID=$(pgrep crowdsec --newest | head -n 1)
3312while [ -z "$CS_PID" ]
···4019sleep 2
41204221printf 'Starting goeffel capture of crowdsec PID %s \n' "$CS_PID"
4343-$CMD --pid $CS_PID --no-system-metrics --label crowdsec &
4444-G_PID=$!
2222+docker compose run --rm --no-TTY goeffel goeffel --pid $CS_PID &
45234624printf 'Starting k6\n'
4747-sudo -u $real_user docker compose up k6 -d
2525+docker compose up k6 -d
48264949-#printf 'Waiting for k6 to finish...\n'
5027docker compose wait k6
5128printf 'k6 container exited!\n'
52295330printf 'Stopping crowdsec\n'
5454-sudo -u $real_user docker compose down crowdsec
3131+docker compose down crowdsec
55325656-while test -d /proc/$G_PID; do
5757- printf 'Waiting for goeffel to finish...\n'
5858- sleep 1
5959-done
3333+printf 'Waiting for goeffel to exit...\n'
3434+docker compose wait goeffel
60356161-DATA=$(ls -t1 *.hdf5 | head -n 1)
3636+DATA=$(cd ./data/goeffel && ls -t1 *.hdf5 | head -n 1)
62376338timestamp=$(date +%s)
64396540printf 'Generating plot for %s\n' "$DATA"
66416767-sudo -u $real_user $CMD_ANALYSIS flexplot \
4242+docker compose run --rm --no-TTY goeffel goeffel-analysis flexplot \
6843--series $DATA host \
6944--column proc_cpu_util_percent_total \
7045'CPU util (total) / %' \
+15
compose.yaml
···1919 image: mendhak/http-https-echo:36
2020 crowdsec:
2121 image: crowdsecurity/crowdsec:latest
2222+ depends_on:
2323+ - traefik
2224 environment:
2325 COLLECTIONS: "crowdsecurity/linux crowdsecurity/traefik"
2426 DISABLE_PARSERS: crowdsecurity/whitelists
···2628 - ./crowdsec/acquis.d:/etc/crowdsec/acquis.d
2729 - ./data/crowdsec/data:/var/lib/crowdsec/data
2830 - ./data/traefik-log:/var/log/traefik
3131+ goeffel:
3232+ image: foxxmd/goeffel:edge
3333+ # required for goeffel to share PID address space with host
3434+ pid: host
3535+ # required for goeffel to have permission to access PIDs
3636+ cap_add:
3737+ - CAP_SYS_PTRACE
3838+ volumes:
3939+ - "./data/goeffel:/app"
4040+ # you want to override this
4141+ command:
4242+ - 'goeffel'
4343+ - '-h'