-
Notifications
You must be signed in to change notification settings - Fork 0
/
per_worker_smem
executable file
·103 lines (84 loc) · 2.83 KB
/
per_worker_smem
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
###
# Processes smem(1) output, converts to CSV for analysis.
###
###
# Source Data File Format:
#
# NAME, PID, PSS, RSS, USS, VSS, SWAP
#
# Which is the output format of the get_smem data collection tool. Typically
# we run get_smem on a system to capture the smem(1) data for later
# analysis, typically via per_worker_pss.
###
if [ $# -eq 1 ]
then
VERSION=$1
else
VERSION=`cat ../VERSION`
if [ "${VERSION}" == "master" ]
then
echo -e "Version: \c"
read VERSION
fi
fi
TMP_SMEM_CSV="../tmp_smem.csv"
SMEM_CSV="../smem.csv"
PROCESS_NAME_PIDS="../process_names_pids.txt"
WORKERS_ROOT="../../workers"
if [ ! -d ${WORKERS_ROOT} ]
then
mkdir -p ${WORKERS_ROOT}
fi
rm -f ${TMP_SMEM_CSV} ${SMEM_CSV} ${PROCESS_NAME_PIDS}
cat smem.201* | grep -v "NAME, PID" | cut -d',' -f1,2 | sort -k2 -t"," | uniq | sort -f | sed 's/,//' > ${PROCESS_NAME_PIDS}
echo -e "Date, Time, Elapsed, \c" >${SMEM_CSV}
cat ${PROCESS_NAME_PIDS} | while read N P
do
ShortName=`echo ${N} | sed -e 's/InfraManager:://' -e 's/Openstack::NetworkManager/OSNM/' -e 's/Openstack::CloudManager/OSCM/' -e 's/StorageManager::CinderManager/SMCM/' -e 's/StorageManager::SwiftManager/SMSM/'`
echo -e "${ShortName}-${P},\c" >>${SMEM_CSV}
echo "${VERSION}" >${WORKERS_ROOT}/${N}-${P}-pss-${VERSION}.csv
echo "${VERSION}" >${WORKERS_ROOT}/${N}-${P}-rss-${VERSION}.csv
echo "${VERSION}" >${WORKERS_ROOT}/${N}-${P}-uss-${VERSION}.csv
echo "${VERSION}" >${WORKERS_ROOT}/${N}-${P}-vss-${VERSION}.csv
done
echo "" >>${SMEM_CSV}
Elapsed=0
ls smem* | cut -d'.' -f2 | cut -d' ' -f1 | sort | while read T
do
echo "${T}"
TIME=`echo ${T} | cut -d'_' -f2`
HOUR=`echo ${TIME} | cut -c1-2`
MINUTE=`echo ${TIME} | cut -c3-4`
SECOND=`echo ${TIME} | cut -c5-6`
DATE=`echo ${T} | cut -d'_' -f1`
YEAR=`echo ${DATE} | cut -c1-4`
MONTH=`echo ${DATE} | cut -c5-6`
DAY=`echo ${DATE} | cut -c7-8`
echo -e "${YEAR}/${MONTH}/${DAY},${HOUR}:${MINUTE}:${SECOND},${Elapsed},\c" >>${TMP_SMEM_CSV}
cat ${PROCESS_NAME_PIDS} | while read N P
do
PSS=`grep " ${P}," smem.${T} | sed -e 's/ //g' | cut -d',' -f3`
if [ $? -eq 0 ]
then
RSS=`grep " ${P}," smem.${T} | sed -e 's/ //g' | cut -d',' -f4`
USS=`grep " ${P}," smem.${T} | sed -e 's/ //g' | cut -d',' -f5`
VSS=`grep " ${P}," smem.${T} | sed -e 's/ //g' | cut -d',' -f6`
else
PSS="0"
RSS="0"
USS="0"
VSS="0"
fi
echo -e "${PSS},\c" >>${TMP_SMEM_CSV}
echo "${PSS}" >>${WORKERS_ROOT}/${N}-${P}-pss-${VERSION}.csv
echo "${RSS}" >>${WORKERS_ROOT}/${N}-${P}-rss-${VERSION}.csv
echo "${USS}" >>${WORKERS_ROOT}/${N}-${P}-uss-${VERSION}.csv
echo "${VSS}" >>${WORKERS_ROOT}/${N}-${P}-vss-${VERSION}.csv
done
echo "" >>${TMP_SMEM_CSV}
Elapsed=$((Elapsed + 1))
done
cat ${TMP_SMEM_CSV} | sed -e 's/,,/,0,/g' -e 's/,,/,0,/g' >>${SMEM_CSV}
rm ${TMP_SMEM_CSV}
exit 0