blob: c8faa6578c8139b3e5e75f5b3b7bee9daeaf6b9c [file] [log] [blame]
Sean Daguee263c822014-12-05 14:25:28 -05001#!/bin/bash
2#
YAMAMOTO Takashi42373c72014-11-18 12:30:16 +09003# lib/dstat
Joe Gordone0b08d02014-08-20 00:34:55 -07004# 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
16XTRACE=$(set +o | grep xtrace)
17set +o xtrace
18
19
20# Defaults
21# --------
22# for DSTAT logging
Dean Troyerad5cc982014-12-10 16:35:32 -060023DSTAT_FILE=${DSTAT_FILE:-"dstat.log"}
Joe Gordone0b08d02014-08-20 00:34:55 -070024
25
26# start_dstat() - Start running processes, including screen
27function start_dstat {
28 # A better kind of sysstat, with the top process per time slice
Joe Gordon06005722015-01-13 16:36:43 +130029 DSTAT_OPTS="-tcmndrylpg --top-cpu-adv --top-io-adv"
Dean Troyerdde41d02014-12-09 17:47:57 -060030 if [[ -n ${LOGDIR} ]]; then
31 screen_it dstat "cd $TOP_DIR; dstat $DSTAT_OPTS | tee $LOGDIR/$DSTAT_FILE"
Daniel P. Berrange901dbec2015-01-30 17:03:32 +000032 if [[ -n ${SCREEN_LOGDIR} && ${SCREEN_LOGDIR} != ${LOGDIR} ]]; then
Dean Troyerdde41d02014-12-09 17:47:57 -060033 # Drop the backward-compat symlink
34 ln -sf $LOGDIR/$DSTAT_FILE ${SCREEN_LOGDIR}/$DSTAT_FILE
35 fi
Joe Gordone0b08d02014-08-20 00:34:55 -070036 else
37 screen_it dstat "dstat $DSTAT_OPTS"
38 fi
39}
40
41# stop_dstat() stop dstat process
42function stop_dstat {
Sean Dague9a413ab2015-02-04 12:44:18 -050043 # dstat runs as a console, not as a service, and isn't trackable
Dean Troyerdc97cb72015-03-28 08:20:50 -050044 # via the normal mechanisms for DevStack. So lets just do a
Sean Dague9a413ab2015-02-04 12:44:18 -050045 # killall and move on.
46 killall dstat || /bin/true
Joe Gordone0b08d02014-08-20 00:34:55 -070047}
48
49# Restore xtrace
50$XTRACE