-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtos-analyze-performance.sh
executable file
·105 lines (99 loc) · 2.32 KB
/
tos-analyze-performance.sh
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
104
105
#!/bin/bash
# ===================================================
# Copyright (c) [2022] [Tencent]
# [OpenCloudOS Tools] is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
# http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# ===================================================
# tos -a : analyze system performance
ana_uptime()
{
echo "========== Uptime ==============="
echo "# uptime"
uptime
echo "================================="
}
ana_vmstat()
{
echo "========== VMSTAT ==============="
echo "# vmstat 1 3"
vmstat 1 3
echo "================================="
}
ana_cpu()
{
echo "========== CPU =================="
echo "# mpstat 1 3"
mpstat 1 3
echo "================================="
}
ana_mem()
{
echo "========== Memory ==============="
echo "# free -m"
free -m
echo "================================="
}
ana_net()
{
echo "========= Network ==============="
echo "# sar -n DEV 1 3"
sar -n DEV 1 3
echo "================================="
}
ana_io()
{
echo "========= I/O ==================="
echo "# iostat -dx 1 3"
iostat -dx 1 3
echo "================================="
}
ana_pidstat()
{
echo "========= pidstat ==================="
echo "# pidstat 1 3"
pidstat 1 3
echo "================================="
}
ana_dmesg()
{
echo "========= dmesg ==================="
echo "# dmesg | tail"
dmesg | tail
echo "================================="
}
ana_performance()
{
ana_uptime
ana_vmstat
ana_cpu
ana_mem
ana_net
ana_io
ana_pidstat
ana_dmesg
}
tos_analyze()
{
if [ -n "$1" ]; then
ana_op=$1
if [ "$ana_op"x == "cpu"x ];then
ana_cpu
elif [ "$ana_op"x == "io"x ];then
ana_io
elif [ "$ana_op"x == "mem"x ];then
ana_mem
elif [ "$ana_op"x == "net"x ];then
ana_net
else
ana_performance
fi
else
ana_performance
fi
}
#tos_analyze $1