Browse code

Merge "Pull dstat logic into its own function so grenade can use it"

Jenkins authored on 2014/09/07 08:59:11
Showing 3 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,41 @@
0
+# lib/apache
1
+# Functions to start and stop dstat
2
+
3
+# Dependencies:
4
+#
5
+# - ``functions`` file
6
+
7
+# ``stack.sh`` calls the entry points in this order:
8
+#
9
+# - start_dstat
10
+# - stop_dstat
11
+
12
+# Save trace setting
13
+XTRACE=$(set +o | grep xtrace)
14
+set +o xtrace
15
+
16
+
17
+# Defaults
18
+# --------
19
+# for DSTAT logging
20
+DSTAT_FILE=${DSTAT_FILE:-"dstat.txt"}
21
+
22
+
23
+# start_dstat() - Start running processes, including screen
24
+function start_dstat {
25
+    # A better kind of sysstat, with the top process per time slice
26
+    DSTAT_OPTS="-tcmndrylp --top-cpu-adv"
27
+    if [[ -n ${SCREEN_LOGDIR} ]]; then
28
+        screen_it dstat "cd $TOP_DIR; dstat $DSTAT_OPTS | tee $SCREEN_LOGDIR/$DSTAT_FILE"
29
+    else
30
+        screen_it dstat "dstat $DSTAT_OPTS"
31
+    fi
32
+}
33
+
34
+# stop_dstat() stop dstat process
35
+function stop_dstat {
36
+    screen_stop dstat
37
+}
38
+
39
+# Restore xtrace
40
+$XTRACE
... ...
@@ -323,9 +323,6 @@ SYSLOG=`trueorfalse False $SYSLOG`
323 323
 SYSLOG_HOST=${SYSLOG_HOST:-$HOST_IP}
324 324
 SYSLOG_PORT=${SYSLOG_PORT:-516}
325 325
 
326
-# for DSTAT logging
327
-DSTAT_FILE=${DSTAT_FILE:-"dstat.txt"}
328
-
329 326
 # Use color for logging output (only available if syslog is not used)
330 327
 LOG_COLOR=`trueorfalse True $LOG_COLOR`
331 328
 
... ...
@@ -369,6 +366,7 @@ source $TOP_DIR/lib/heat
369 369
 source $TOP_DIR/lib/neutron
370 370
 source $TOP_DIR/lib/baremetal
371 371
 source $TOP_DIR/lib/ldap
372
+source $TOP_DIR/lib/dstat
372 373
 
373 374
 # Extras Source
374 375
 # --------------
... ...
@@ -948,12 +946,7 @@ init_service_check
948 948
 # -------
949 949
 
950 950
 # A better kind of sysstat, with the top process per time slice
951
-DSTAT_OPTS="-tcmndrylp --top-cpu-adv"
952
-if [[ -n ${SCREEN_LOGDIR} ]]; then
953
-    screen_it dstat "cd $TOP_DIR; dstat $DSTAT_OPTS | tee $SCREEN_LOGDIR/$DSTAT_FILE"
954
-else
955
-    screen_it dstat "dstat $DSTAT_OPTS"
956
-fi
951
+start_dstat
957 952
 
958 953
 # Start Services
959 954
 # ==============
... ...
@@ -162,6 +162,8 @@ if is_service_enabled trove; then
162 162
     cleanup_trove
163 163
 fi
164 164
 
165
+stop_dstat
166
+
165 167
 # Clean up the remainder of the screen processes
166 168
 SCREEN=$(which screen)
167 169
 if [[ -n "$SCREEN" ]]; then