devstack/lib/dstat
Sean Dague 9a413abcd4 add gating up/down script for devstack
This adds the test infrastructure for testing that unstack.sh and
clean.sh do the right thing, and actually stop what's expected. This
is designed to be used in upstream testing to make unstack and clean a
bit more certain.

It includes numerous fixes to make these pass in an errexit
environment with the gate config. The scripts still don't run under
errexit because we don't assume we've handled all possible cleanup safely.

Change-Id: I774dfb2cc934367eef2bb7ea5123197f6da7565b
2015-02-11 06:10:38 -05:00

51 lines
1.2 KiB
Bash

#!/bin/bash
#
# lib/dstat
# Functions to start and stop dstat
# Dependencies:
#
# - ``functions`` file
# ``stack.sh`` calls the entry points in this order:
#
# - start_dstat
# - stop_dstat
# Save trace setting
XTRACE=$(set +o | grep xtrace)
set +o xtrace
# Defaults
# --------
# for DSTAT logging
DSTAT_FILE=${DSTAT_FILE:-"dstat.log"}
# start_dstat() - Start running processes, including screen
function start_dstat {
# A better kind of sysstat, with the top process per time slice
DSTAT_OPTS="-tcmndrylpg --top-cpu-adv --top-io-adv"
if [[ -n ${LOGDIR} ]]; then
screen_it dstat "cd $TOP_DIR; dstat $DSTAT_OPTS | tee $LOGDIR/$DSTAT_FILE"
if [[ -n ${SCREEN_LOGDIR} && ${SCREEN_LOGDIR} != ${LOGDIR} ]]; then
# Drop the backward-compat symlink
ln -sf $LOGDIR/$DSTAT_FILE ${SCREEN_LOGDIR}/$DSTAT_FILE
fi
else
screen_it dstat "dstat $DSTAT_OPTS"
fi
}
# stop_dstat() stop dstat process
function stop_dstat {
# dstat runs as a console, not as a service, and isn't trackable
# via the normal mechanisms for devstack. So lets just do a
# killall and move on.
killall dstat || /bin/true
}
# Restore xtrace
$XTRACE