forked from NEMSLinux/legacy-nems-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark.sh.save
More file actions
executable file
·168 lines (129 loc) · 5.62 KB
/
benchmark.sh.save
File metadata and controls
executable file
·168 lines (129 loc) · 5.62 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/bin/bash
start=`date +%s`
nemsinit=`/usr/local/bin/nems-info init`
if [[ $nemsinit == 0 ]]; then
echo "NEMS hasn't been initialized."
exit
fi
# Install sysbench if it is not found
# First attempt: install from included repos
if [[ ! -f /usr/bin/sysbench ]]; then
apt -y install sysbench
# Didn't install from default repos
# Second attempt: install from developer repo
if [[ ! -f /usr/bin/sysbench ]]; then
curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.deb.sh | sudo bash
apt -y install sysbench
fi
# Still no success, compile from source
if [[ ! -f /usr/bin/sysbench ]]; then
# First, clean things up from our attempt
if [[ -f /etc/apt/sources.list.d/akopytov_sysbench.list ]]; then
rm /etc/apt/sources.list.d/akopytov_sysbench.list
apt update
fi
# Install dependencies to compile from source
apt -y install make
apt -y install automake
apt -y install libtool
apt -y install pkg-config
apt -y install libaio-dev
# MySQL Compatibility
apt -y install lib
apt -y install libssl-dev
# Download and compile from source
cd /tmp
mkdir sysbench-working
cd sysbench-working
git clone https://github.com/akopytov/sysbench
cd sysbench
./autogen.sh
./configure
make -j
make install
# Clean up
cd /tmp
rm -rf sysbench-working
if [[ ! -f /usr/bin/sysbench ]]; then
# I tried every possible means of installing, but failed.
# Now, report the issue to screen and exit
echo "sysbench is not yet available on this build."
exit
fi
fi
fi
# Good to proceed, begin benchmark
# Set a runtime
if [[ -f /var/log/nems/benchmarks/runtime ]]; then
lastruntime=`cat /var/log/nems/benchmarks/runtime`
if [ "$lastruntime" -gt "18000" ]; then
# Don't run weekly benchmark on boards that take longer than 10 minutes to do so
echo "Benchmarks take too long on this board. Aborting."
echo "Stats for this board will be based on first run."
exit 1
fi
thisruntime=$(($lastruntime+120)) # +2 minutes from the last runtime
else
thisruntime=18000 # 10 minutes
fi
plannedend=$(($start + $thisruntime))
# Schedule downtime on CPU Load notifications for 5 hours during benchmarks
/usr/bin/printf "[%lu] SCHEDULE_SVC_DOWNTIME;NEMS;Current Load;$start;$plannedend;0;0;$thisruntime;NEMS Linux;Weekly Benchmarks Running\n" $start > /usr/local/nagios/var/rw/nagios.cmd
echo "NEMS System Benchmark... Please Wait (may take a while)."
echo "NEMS System Benchmark" > /tmp/nems-benchmark.log
date >> /tmp/nems-benchmark.log
printf "NEMS Version: " >> /tmp/nems-benchmark.log
ver=$(/usr/local/bin/nems-info nemsver)
echo $ver >> /tmp/nems-benchmark.log
printf "\nHardware Revision: " >> /tmp/nems-benchmark.log
/usr/local/bin/nems-info hwver >> /tmp/nems-benchmark.log
printf "NEMS ID: " >> /tmp/nems-benchmark.log
/usr/local/bin/nems-info hwid >> /tmp/nems-benchmark.log
printf "System Uptime: " >> /tmp/nems-benchmark.log
/usr/bin/uptime >> /tmp/nems-benchmark.log
printf "LAN IP: " >> /tmp/nems-benchmark.log
/usr/local/bin/nems-info ip >> /tmp/nems-benchmark.log
echo "---------------------------------" >> /tmp/nems-benchmark.log
if [[ ! -d /var/log/nems/benchmarks ]]; then
mkdir -p /var/log/nems/benchmarks
fi
# Run the tests
cores=$(nproc --all)
echo "Number of threads: $cores" >> /tmp/nems-benchmark.log
cd /tmp
printf "Performing CPU Benchmark: " >> /tmp/nems-benchmark.log
cpu=`/usr/bin/sysbench --test=cpu --cpu-max-prime=20000 --num-threads=$cores run | /usr/local/share/nems/nems-scripts/benchmark-parse.sh cpu`
echo $cpu > /var/log/nems/benchmarks/cpu
echo "CPU Score $cpu" >> /tmp/nems-benchmark.log
printf "Performing RAM Benchmark: " >> /tmp/nems-benchmark.log
ram=`/usr/bin/sysbench --test=memory --num-threads=$cores --memory-total-size=10G run | /usr/local/share/nems/nems-scripts/benchmark-parse.sh ram`
echo $ram > /var/log/nems/benchmarks/ram
echo "RAM Score $ram" >> /tmp/nems-benchmark.log
printf "Performing Mutex Benchmark: " >> /tmp/nems-benchmark.log
mutex=`/usr/bin/sysbench --test=mutex --num-threads=64 run | /usr/local/share/nems/nems-scripts/benchmark-parse.sh mutex`
echo $mutex > /var/log/nems/benchmarks/mutex
echo "Mutex Score $mutex" >> /tmp/nems-benchmark.log
printf "Performing I/O Benchmark: " >> /tmp/nems-benchmark.log
io=`/usr/bin/sysbench --test=fileio --file-test-mode=seqwr run | /usr/local/share/nems/nems-scripts/benchmark-parse.sh io`
echo $io > /var/log/nems/benchmarks/io
echo "I/O Score $io" >> /tmp/nems-benchmark.log
# Clear the test files
rm -f /tmp/test_file.*
echo "---------------------------------" >> /tmp/nems-benchmark.log
echo "Filesystem:" >> /tmp/nems-benchmark.log
/bin/df -h >> /tmp/nems-benchmark.log
echo "---------------------------------" >> /tmp/nems-benchmark.log
echo "Memory:" >> /tmp/nems-benchmark.log
/usr/bin/free -h >> /tmp/nems-benchmark.log
echo "---------------------------------" >> /tmp/nems-benchmark.log
echo "Internet Speed:" >> /tmp/nems-benchmark.log
/usr/local/share/nems/nems-scripts/speedtest --simple >> /tmp/nems-benchmark.log
echo "---------------------------------" >> /tmp/nems-benchmark.log
end=`date +%s`
runtime=$((end-start))
echo "Benchmark of this benchmark: "$runtime" seconds" >> /tmp/nems-benchmark.log
echo $runtime > /var/log/nems/benchmarks/runtime
cat /tmp/nems-benchmark.log
rm /tmp/nems-benchmark.log
# sometime in future, get the downtime ID from livestatus and output it in place of the '1'
#/usr/bin/printf "[%lu] DEL_SVC_DOWNTIME;1\n" $end > /usr/local/nagios/var/rw/nagios.cmd