| 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 |  | 
| youri jeong | f68f6f2 | 2017-04-12 19:23:40 +0900 | [diff] [blame] | 12 | # Retrieve log directory as argument from calling script. | 
| Tim Buckley | a83e90b | 2015-08-05 10:25:00 -0600 | [diff] [blame] | 13 | LOGDIR=$1 | 
|  | 14 |  | 
|  | 15 | # Command line arguments for primary DStat process. | 
| melanie witt | fc572a5 | 2017-05-16 23:04:46 +0000 | [diff] [blame] | 16 | DSTAT_OPTS="-tcmndrylpg --top-cpu-adv --top-io-adv --top-mem --swap --tcp" | 
| Tim Buckley | a83e90b | 2015-08-05 10:25:00 -0600 | [diff] [blame] | 17 |  | 
|  | 18 | # Command-line arguments for secondary background DStat process. | 
| melanie witt | fc572a5 | 2017-05-16 23:04:46 +0000 | [diff] [blame] | 19 | DSTAT_CSV_OPTS="-tcmndrylpg --tcp --output $LOGDIR/dstat-csv.log" | 
| Tim Buckley | a83e90b | 2015-08-05 10:25:00 -0600 | [diff] [blame] | 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 |