Merge "Added missing sudo when killing ns-metadata"
diff --git a/stack.sh b/stack.sh
index 621a058..efdee64 100755
--- a/stack.sh
+++ b/stack.sh
@@ -860,11 +860,17 @@
# -------
# If enabled, systat has to start early to track OpenStack service startup.
-if is_service_enabled sysstat;then
+if is_service_enabled sysstat; then
+ # what we want to measure
+ # -u : cpu statitics
+ # -q : load
+ # -b : io load rates
+ # -w : process creation and context switch rates
+ SYSSTAT_OPTS="-u -q -b -w"
if [[ -n ${SCREEN_LOGDIR} ]]; then
- screen_it sysstat "cd ; sar -o $SCREEN_LOGDIR/$SYSSTAT_FILE $SYSSTAT_INTERVAL"
+ screen_it sysstat "cd $TOP_DIR; ./tools/sar_filter.py $SYSSTAT_OPTS -o $SCREEN_LOGDIR/$SYSSTAT_FILE $SYSSTAT_INTERVAL"
else
- screen_it sysstat "sar $SYSSTAT_INTERVAL"
+ screen_it sysstat "./tools/sar_filter.py $SYSSTAT_OPTS $SYSSTAT_INTERVAL"
fi
fi
diff --git a/tools/sar_filter.py b/tools/sar_filter.py
new file mode 100755
index 0000000..ed8c196
--- /dev/null
+++ b/tools/sar_filter.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+#
+# Copyright 2014 Samsung Electronics Corp. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import re
+import subprocess
+import sys
+
+
+def is_data_line(line):
+ timestamp, data = parse_line(line)
+ return re.search('\d\.d', data)
+
+
+def parse_line(line):
+ m = re.search('(\d\d:\d\d:\d\d \w\w)(\s+((\S+)\s*)+)', line)
+ if m:
+ date = m.group(1)
+ data = m.group(2).rstrip()
+ return date, data
+ else:
+ return None, None
+
+
+process = subprocess.Popen(
+ "sar %s" % " ".join(sys.argv[1:]),
+ shell=True,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+
+# Poll process for new output until finished
+
+start_time = ""
+header = ""
+data_line = ""
+printed_header = False
+current_ts = None
+while True:
+ nextline = process.stdout.readline()
+ if nextline == '' and process.poll() is not None:
+ break
+
+ date, data = parse_line(nextline)
+ # stop until we get to the first set of real lines
+ if not date:
+ continue
+
+ # now we eat the header lines, and only print out the header
+ # if we've never seen them before
+ if not start_time:
+ start_time = date
+ header += "%s %s" % (date, data)
+ elif date == start_time:
+ header += " %s" % data
+ elif not printed_header:
+ printed_header = True
+ print header
+
+ # now we know this is a data line, printing out if the timestamp
+ # has changed, and stacking up otherwise.
+ nextline = process.stdout.readline()
+ date, data = parse_line(nextline)
+ if date != current_ts:
+ current_ts = date
+ print data_line
+ data_line = "%s %s" % (date, data)
+ else:
+ data_line += " %s" % data
+
+ sys.stdout.flush()