| 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 | 
| Dean Troyer | ad5cc98 | 2014-12-10 16:35:32 -0600 | [diff] [blame] | 23 | DSTAT_FILE=${DSTAT_FILE:-"dstat.log"} | 
| Joe Gordon | e0b08d0 | 2014-08-20 00:34:55 -0700 | [diff] [blame] | 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 | 
| Joe Gordon | 0600572 | 2015-01-13 16:36:43 +1300 | [diff] [blame] | 29 | DSTAT_OPTS="-tcmndrylpg --top-cpu-adv --top-io-adv" | 
| Dean Troyer | dde41d0 | 2014-12-09 17:47:57 -0600 | [diff] [blame] | 30 | if [[ -n ${LOGDIR} ]]; then | 
|  | 31 | screen_it dstat "cd $TOP_DIR; dstat $DSTAT_OPTS | tee $LOGDIR/$DSTAT_FILE" | 
| Daniel P. Berrange | 901dbec | 2015-01-30 17:03:32 +0000 | [diff] [blame] | 32 | if [[ -n ${SCREEN_LOGDIR} && ${SCREEN_LOGDIR} != ${LOGDIR} ]]; then | 
| Dean Troyer | dde41d0 | 2014-12-09 17:47:57 -0600 | [diff] [blame] | 33 | # Drop the backward-compat symlink | 
|  | 34 | ln -sf $LOGDIR/$DSTAT_FILE ${SCREEN_LOGDIR}/$DSTAT_FILE | 
|  | 35 | fi | 
| Joe Gordon | e0b08d0 | 2014-08-20 00:34:55 -0700 | [diff] [blame] | 36 | else | 
|  | 37 | screen_it dstat "dstat $DSTAT_OPTS" | 
|  | 38 | fi | 
|  | 39 | } | 
|  | 40 |  | 
|  | 41 | # stop_dstat() stop dstat process | 
|  | 42 | function stop_dstat { | 
|  | 43 | screen_stop dstat | 
|  | 44 | } | 
|  | 45 |  | 
|  | 46 | # Restore xtrace | 
|  | 47 | $XTRACE |