| Sean Dague | e263c82 | 2014-12-05 14:25:28 -0500 | [diff] [blame] | 1 | #!/bin/bash | 
 | 2 | # | 
| YAMAMOTO Takashi | 42373c7 | 2014-11-18 12:30:16 +0900 | [diff] [blame] | 3 | # lib/dstat | 
| Joe Gordon | e0b08d0 | 2014-08-20 00:34:55 -0700 | [diff] [blame] | 4 | # Functions to start and stop dstat | 
 | 5 |  | 
 | 6 | # Dependencies: | 
 | 7 | # | 
 | 8 | # - ``functions`` file | 
 | 9 |  | 
 | 10 | # ``stack.sh`` calls the entry points in this order: | 
 | 11 | # | 
 | 12 | # - start_dstat | 
 | 13 | # - stop_dstat | 
 | 14 |  | 
 | 15 | # Save trace setting | 
 | 16 | XTRACE=$(set +o | grep xtrace) | 
 | 17 | set +o xtrace | 
 | 18 |  | 
 | 19 |  | 
 | 20 | # Defaults | 
 | 21 | # -------- | 
 | 22 | # for DSTAT logging | 
 | 23 | DSTAT_FILE=${DSTAT_FILE:-"dstat.txt"} | 
 | 24 |  | 
 | 25 |  | 
 | 26 | # start_dstat() - Start running processes, including screen | 
 | 27 | function start_dstat { | 
 | 28 |     # A better kind of sysstat, with the top process per time slice | 
| YAMAMOTO Takashi | 44f4e20 | 2014-11-18 13:03:08 +0900 | [diff] [blame] | 29 |     DSTAT_OPTS="-tcmndrylpg --top-cpu-adv" | 
| Joe Gordon | e0b08d0 | 2014-08-20 00:34:55 -0700 | [diff] [blame] | 30 |     if [[ -n ${SCREEN_LOGDIR} ]]; then | 
 | 31 |         screen_it dstat "cd $TOP_DIR; dstat $DSTAT_OPTS | tee $SCREEN_LOGDIR/$DSTAT_FILE" | 
 | 32 |     else | 
 | 33 |         screen_it dstat "dstat $DSTAT_OPTS" | 
 | 34 |     fi | 
 | 35 | } | 
 | 36 |  | 
 | 37 | # stop_dstat() stop dstat process | 
 | 38 | function stop_dstat { | 
 | 39 |     screen_stop dstat | 
 | 40 | } | 
 | 41 |  | 
 | 42 | # Restore xtrace | 
 | 43 | $XTRACE |