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