diff --git a/.ci.yml b/.ci.yml index 5bf5c6c..5709f60 100644 --- a/.ci.yml +++ b/.ci.yml @@ -1,36 +1,19 @@ image: debian:bullseye before_script: - - chmod +x scripts/install_dependencies.sh - - ./scripts/install_dependencies.sh -simple_test: - variables: - FAKE_DISK: "fake_disk.ext4" - FAKE_MOUNTPOINT: "fake_mountpoint" - script: - - chmod +x scripts/test.sh - - ./scripts/test.sh svg png ascii - artifacts: - when: always - paths: - - "*.svg" - - "*.png" - - "*.ascii" - - "*.txt" - - "*.log" - -interactive_plot_test: - variables: - FAKE_DISK: "fake_disk.ext4" - FAKE_MOUNTPOINT: "fake_mountpoint" - script: - - chmod +x scripts/test.sh - - ./scripts/test.sh html - artifacts: - when: always - paths: - - "*.txt" - - "*.log" - - "*.html" + - apt-get update + - apt-get install -qqy --no-install-recommends python3 python3-pip git + - pip3 install git+https://github.com/antmicro/tuttest.git - +simple_test: + script: + - ./scripts/test.sh + artifacts: + when: always + paths: + - "*.svg" + - "*.png" + - "*.ascii" + - "*.html" + - "*.txt" + - "*.log" diff --git a/README.md b/README.md index e1b4eb7..df2ea28 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,32 @@ The process runs in background and can be controlled with a set of sargraph sub- The tool can use "gnuplot" to optionally plot the data it collected. Supported plot formats are PNG, SVG and ASCII, they are determined by filename extensions. +# Install requirements + +The sargraph requires `gnuplot`, `sysstat` (`sar`), `python3`, `coreutils` and `screen` to operate. +In Debian you can install as: + +``` +# install system dependencies +apt-get update +apt-get install -qqy --no-install-recommends \ + coreutils \ + git \ + gnuplot-nox \ + python3 \ + python3-pip \ + screen \ + sysstat + +# install Python dependencies +pip3 install -r requirements.txt +``` + +For rendering HTML plots, you additionally have to install: + +``` +pip3 install git+https://github.com/antmicro/servis#egg=servis[bokeh] +``` # Example graph @@ -16,53 +42,88 @@ Supported plot formats are PNG, SVG and ASCII, they are determined by filename e # Usage All sargraph commands use the following pattern: + ``` $ ./sargraph.py [session_name] [command] [args...] ``` +Let's create a sample disk on which we will run stress tests: + +``` +dd if=/dev/zero of=sample_disk.ext4 bs=1M count=130 +mkfs.ext4 sample_disk.ext4 +mkdir -p ./mountpoint && mount sample_disk.ext4 ./mountpoint +``` + +For the purpose of stress tests let's install `stress`: + +``` +apt-get install stress +``` + ## Starting a session + Start a background session and name it `example`: ``` -$ ./sargraph.py example start +./sargraph.py example start -m ./mountpoint ``` The data will be saved in `example.txt`. Logs from screen will be written to `example.log`. +`-m` flag allows to specify a chosen filesystem/mountpoint. + ## Adding a label + Add labels that will be placed as comments in the collected dataset. They will be also visible on the plots: ``` -$ ./sargraph.py example label "Compilation start" +./sargraph.py example label "Compilation start" ``` -## Plotting a running session -Plot data collected so far in a still running session: +After this, let's simulate some processing: + ``` -$ ./sargraph.py example save plot.svg +pushd ./mountpoint +stress -c 16 -i 1 -m 1 --vm-bytes 512M -d 1 --hdd-bytes 70M -t 160s +popd ``` -## Plotting a closed session -Plot data collected in a session that is not running anymore. +## Plotting a running session + +It is possible to plot data collected so far in a still running session: ``` -$ ./sargraph.py example plot plot.ascii +# Save plot to SVG +./sargraph.py example save plot.svg +# Save plot to PNG +./sargraph.py example save plot.png +# Save plot to ASCII that can be printed in terminal +./sargraph.py example save plot.ascii +# Save plot to interactive HTML plot +./sargraph.py example save plot.html ``` -The command requires the `example.txt` log file to be present in the working directory. -## Supported formats - -Plots can be saved in: +The supported formats are: * `png` format * `svg` format +* `html` format * `ascii` format - plot is rendered to text file that can be displayed in terminal ## Stopping a session + Stop a session and create a final `plot.png` plot file if no other plot was created so far: ``` -$ ./sargraph.py example stop +./sargraph.py example stop ``` The filename of the final plot can be changed if its placed after the `stop` command. If the name is `none` then no plot will be created. +## Plotting a closed session + +Plot data collected in a session that is not running anymore. +``` +./sargraph.py example plot plot.ascii +``` +The command requires the `example.txt` log file to be present in the working directory. diff --git a/scripts/install_dependencies.sh b/scripts/install_dependencies.sh deleted file mode 100644 index 4a0a562..0000000 --- a/scripts/install_dependencies.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -apt -qqy update > /dev/null -apt -qqy install --no-install-recommends screen sysstat gnuplot-nox python3 python3-pip git stress coreutils > /dev/null -pip install -r requirements.txt -ln -s $(realpath sargraph.py) /usr/bin/sargraph \ No newline at end of file diff --git a/scripts/test.sh b/scripts/test.sh old mode 100644 new mode 100755 index f3daf54..1b5b8cc --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1,38 +1,5 @@ #!/bin/bash -if [[ "$@" =~ 'html' ]] -then - pip install git+https://github.com/antmicro/servis#egg=servis[bokeh] -fi +set -e -dd if=/dev/zero of=$FAKE_DISK bs=1M count=130 -mkfs.ext4 $FAKE_DISK -mkdir -p $FAKE_MOUNTPOINT && mount $FAKE_DISK $FAKE_MOUNTPOINT - -sargraph chart start -m $FAKE_MOUNTPOINT - -pushd $FAKE_MOUNTPOINT -df -h . -stress -c 16 -i 1 -m 1 --vm-bytes 512M -d 1 --hdd-bytes 70M -t 160s - -popd - -for ext in "$@" -do - sargraph chart save "plot.${ext}" -done - -sargraph chart stop - -for ext in "$@" -do - test -f "plot.${ext}" -done - -cat chart.log - -if [[ "$@" =~ 'ascii' ]] -then - echo '------Sample plot------' - cat plot.ascii -fi \ No newline at end of file +tuttest README.md | grep -v '^\$' | bash -