Tim Buckley | a83e90b | 2015-08-05 10:25:00 -0600 | [diff] [blame] | 1 | #!/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 | |
| 12 | # Retreive log directory as argument from calling script. |
| 13 | LOGDIR=$1 |
| 14 | |
| 15 | # Command line arguments for primary DStat process. |
Hongbin Lu | bfdd47c | 2015-12-20 16:30:36 -0500 | [diff] [blame] | 16 | DSTAT_OPTS="-tcmndrylpg --top-cpu-adv --top-io-adv --swap" |
Tim Buckley | a83e90b | 2015-08-05 10:25:00 -0600 | [diff] [blame] | 17 | |
| 18 | # Command-line arguments for secondary background DStat process. |
| 19 | DSTAT_CSV_OPTS="-tcmndrylpg --output $LOGDIR/dstat-csv.log" |
| 20 | |
| 21 | # Execute and background the secondary dstat process and discard its output. |
| 22 | dstat $DSTAT_CSV_OPTS >& /dev/null & |
| 23 | |
| 24 | # Execute and background the primary dstat process, but keep its output in this |
| 25 | # TTY. |
| 26 | dstat $DSTAT_OPTS & |
| 27 | |
| 28 | # Catch any exit signals, making sure to also terminate any child processes. |
| 29 | trap "kill -- -$$" EXIT |
| 30 | |
| 31 | # Keep this script running as long as child dstat processes are alive. |
| 32 | wait |