blob: ae7306ecb7ef622f15e277bd216b0f34bb00e230 [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
15# Command line arguments for primary DStat process.
Matthew Treinish6d79ebc2017-02-02 10:52:53 -050016DSTAT_OPTS="-tcmndrylpg --top-cpu-adv --top-io-adv --top-mem --swap"
Tim Buckleya83e90b2015-08-05 10:25:00 -060017
18# Command-line arguments for secondary background DStat process.
19DSTAT_CSV_OPTS="-tcmndrylpg --output $LOGDIR/dstat-csv.log"
20
21# Execute and background the secondary dstat process and discard its output.
22dstat $DSTAT_CSV_OPTS >& /dev/null &
23
24# Execute and background the primary dstat process, but keep its output in this
25# TTY.
26dstat $DSTAT_OPTS &
27
28# Catch any exit signals, making sure to also terminate any child processes.
29trap "kill -- -$$" EXIT
30
31# Keep this script running as long as child dstat processes are alive.
32wait