blob: 01c6d9b7e90c44db4491f5f956121994f08fd3e4 [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.
melanie wittfc572a52017-05-16 23:04:46 +000016DSTAT_OPTS="-tcmndrylpg --top-cpu-adv --top-io-adv --top-mem --swap --tcp"
Tim Buckleya83e90b2015-08-05 10:25:00 -060017
18# Command-line arguments for secondary background DStat process.
melanie wittfc572a52017-05-16 23:04:46 +000019DSTAT_CSV_OPTS="-tcmndrylpg --tcp --output $LOGDIR/dstat-csv.log"
Tim Buckleya83e90b2015-08-05 10:25:00 -060020
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