Browse code

Merge "updated sar options to collect more data"

Jenkins authored on 2014/01/21 19:07:52
Showing 2 changed files
... ...
@@ -860,11 +860,17 @@ init_service_check
860 860
 # -------
861 861
 
862 862
 # If enabled, systat has to start early to track OpenStack service startup.
863
-if is_service_enabled sysstat;then
863
+if is_service_enabled sysstat; then
864
+    # what we want to measure
865
+    # -u : cpu statitics
866
+    # -q : load
867
+    # -b : io load rates
868
+    # -w : process creation and context switch rates
869
+    SYSSTAT_OPTS="-u -q -b -w"
864 870
     if [[ -n ${SCREEN_LOGDIR} ]]; then
865
-        screen_it sysstat "cd ; sar -o $SCREEN_LOGDIR/$SYSSTAT_FILE $SYSSTAT_INTERVAL"
871
+        screen_it sysstat "cd $TOP_DIR; ./tools/sar_filter.py $SYSSTAT_OPTS -o $SCREEN_LOGDIR/$SYSSTAT_FILE $SYSSTAT_INTERVAL"
866 872
     else
867
-        screen_it sysstat "sar $SYSSTAT_INTERVAL"
873
+        screen_it sysstat "./tools/sar_filter.py $SYSSTAT_OPTS $SYSSTAT_INTERVAL"
868 874
     fi
869 875
 fi
870 876
 
871 877
new file mode 100755
... ...
@@ -0,0 +1,82 @@
0
+#!/usr/bin/env python
1
+#
2
+# Copyright 2014 Samsung Electronics Corp. All Rights Reserved.
3
+#
4
+# Licensed under the Apache License, Version 2.0 (the "License");
5
+# you may not use this file except in compliance with the License.
6
+# You may obtain a copy of the License at
7
+#
8
+#    http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+# Unless required by applicable law or agreed to in writing, software
11
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+# License for the specific language governing permissions and limitations
14
+# under the License.
15
+
16
+import re
17
+import subprocess
18
+import sys
19
+
20
+
21
+def is_data_line(line):
22
+    timestamp, data = parse_line(line)
23
+    return re.search('\d\.d', data)
24
+
25
+
26
+def parse_line(line):
27
+    m = re.search('(\d\d:\d\d:\d\d \w\w)(\s+((\S+)\s*)+)', line)
28
+    if m:
29
+        date = m.group(1)
30
+        data = m.group(2).rstrip()
31
+        return date, data
32
+    else:
33
+        return None, None
34
+
35
+
36
+process = subprocess.Popen(
37
+    "sar %s" % " ".join(sys.argv[1:]),
38
+    shell=True,
39
+    stdout=subprocess.PIPE,
40
+    stderr=subprocess.STDOUT)
41
+
42
+# Poll process for new output until finished
43
+
44
+start_time = ""
45
+header = ""
46
+data_line = ""
47
+printed_header = False
48
+current_ts = None
49
+while True:
50
+    nextline = process.stdout.readline()
51
+    if nextline == '' and process.poll() is not None:
52
+        break
53
+
54
+    date, data = parse_line(nextline)
55
+    # stop until we get to the first set of real lines
56
+    if not date:
57
+        continue
58
+
59
+    # now we eat the header lines, and only print out the header
60
+    # if we've never seen them before
61
+    if not start_time:
62
+        start_time = date
63
+        header += "%s   %s" % (date, data)
64
+    elif date == start_time:
65
+        header += "   %s" % data
66
+    elif not printed_header:
67
+        printed_header = True
68
+        print header
69
+
70
+    # now we know this is a data line, printing out if the timestamp
71
+    # has changed, and stacking up otherwise.
72
+    nextline = process.stdout.readline()
73
+    date, data = parse_line(nextline)
74
+    if date != current_ts:
75
+        current_ts = date
76
+        print data_line
77
+        data_line = "%s   %s" % (date, data)
78
+    else:
79
+        data_line += "   %s" % data
80
+
81
+    sys.stdout.flush()