blob: e6cbb0f21c33838f0b0ca7618f4cb265304695dc [file] [log] [blame]
Tim Buckleya83e90b2015-08-05 10:25:00 -06001#!/bin/bash
2
3# **tools/dstat.sh** - Execute instances of DStat to log system load info
4#
5# Multiple instances of DStat are executed in order to take advantage of
6# incompatible features, particularly CSV output and the "top-cpu-adv" and
7# "top-io-adv" flags.
8#
9# Assumes:
10# - dstat command is installed
11
youri jeongf68f6f22017-04-12 19:23:40 +090012# Retrieve log directory as argument from calling script.
Tim Buckleya83e90b2015-08-05 10:25:00 -060013LOGDIR=$1
14
Ian Wienand1124a052019-02-11 13:35:43 +110015DSTAT_TOP_OPTS="--top-cpu-adv --top-io-adv --top-mem"
16if dstat --version | grep -q 'pcp-dstat' ; then
17 # dstat is unmaintained, and moving to a plugin of performance
18 # co-pilot. Fedora 29 for example has rolled this out. It's
19 # mostly compatible, except for a few options which are not
20 # implemented (yet?)
21 DSTAT_TOP_OPTS=""
22fi
23
Tim Buckleya83e90b2015-08-05 10:25:00 -060024# Command line arguments for primary DStat process.
Ian Wienand1124a052019-02-11 13:35:43 +110025DSTAT_OPTS="-tcmndrylpg ${DSTAT_TOP_OPTS} --swap --tcp"
Tim Buckleya83e90b2015-08-05 10:25:00 -060026
27# Command-line arguments for secondary background DStat process.
melanie wittfc572a52017-05-16 23:04:46 +000028DSTAT_CSV_OPTS="-tcmndrylpg --tcp --output $LOGDIR/dstat-csv.log"
Tim Buckleya83e90b2015-08-05 10:25:00 -060029
30# Execute and background the secondary dstat process and discard its output.
31dstat $DSTAT_CSV_OPTS >& /dev/null &
32
33# Execute and background the primary dstat process, but keep its output in this
34# TTY.
35dstat $DSTAT_OPTS &
36
37# Catch any exit signals, making sure to also terminate any child processes.
38trap "kill -- -$$" EXIT
39
40# Keep this script running as long as child dstat processes are alive.
41wait