Skip to content
Permalink
Browse files

Compile sysbench if not exist, improve compatibility

  • Loading branch information...
NEMS Linux
NEMS Linux committed Apr 29, 2019
1 parent c3a279f commit be4af6dcda7810d8282d4bc1bcb75183370ec487
Showing with 234 additions and 12 deletions.
  1. +1 −1 benchmark-parse.sh
  2. +65 −11 benchmark.sh
  3. +168 −0 benchmark.sh.save
  4. BIN test_file.0
  5. BIN test_file.1
  6. 0 test_file.10
  7. 0 test_file.100
  8. 0 test_file.101
  9. 0 test_file.102
  10. 0 test_file.103
  11. 0 test_file.104
  12. 0 test_file.105
  13. 0 test_file.106
  14. 0 test_file.107
  15. 0 test_file.108
  16. 0 test_file.109
  17. 0 test_file.11
  18. 0 test_file.110
  19. 0 test_file.111
  20. 0 test_file.112
  21. 0 test_file.113
  22. 0 test_file.114
  23. 0 test_file.115
  24. 0 test_file.116
  25. 0 test_file.117
  26. 0 test_file.118
  27. 0 test_file.119
  28. 0 test_file.12
  29. 0 test_file.120
  30. 0 test_file.121
  31. 0 test_file.122
  32. 0 test_file.123
  33. 0 test_file.124
  34. 0 test_file.125
  35. 0 test_file.126
  36. 0 test_file.127
  37. 0 test_file.13
  38. 0 test_file.14
  39. 0 test_file.15
  40. 0 test_file.16
  41. 0 test_file.17
  42. 0 test_file.18
  43. 0 test_file.19
  44. BIN test_file.2
  45. 0 test_file.20
  46. 0 test_file.21
  47. 0 test_file.22
  48. 0 test_file.23
  49. 0 test_file.24
  50. 0 test_file.25
  51. 0 test_file.26
  52. 0 test_file.27
  53. 0 test_file.28
  54. 0 test_file.29
  55. BIN test_file.3
  56. 0 test_file.30
  57. 0 test_file.31
  58. 0 test_file.32
  59. 0 test_file.33
  60. 0 test_file.34
  61. 0 test_file.35
  62. 0 test_file.36
  63. 0 test_file.37
  64. 0 test_file.38
  65. 0 test_file.39
  66. 0 test_file.4
  67. 0 test_file.40
  68. 0 test_file.41
  69. 0 test_file.42
  70. 0 test_file.43
  71. 0 test_file.44
  72. 0 test_file.45
  73. 0 test_file.46
  74. 0 test_file.47
  75. 0 test_file.48
  76. 0 test_file.49
  77. 0 test_file.5
  78. 0 test_file.50
  79. 0 test_file.51
  80. 0 test_file.52
  81. 0 test_file.53
  82. 0 test_file.54
  83. 0 test_file.55
  84. 0 test_file.56
  85. 0 test_file.57
  86. 0 test_file.58
  87. 0 test_file.59
  88. 0 test_file.6
  89. 0 test_file.60
  90. 0 test_file.61
  91. 0 test_file.62
  92. 0 test_file.63
  93. 0 test_file.64
  94. 0 test_file.65
  95. 0 test_file.66
  96. 0 test_file.67
  97. 0 test_file.68
  98. 0 test_file.69
  99. 0 test_file.7
  100. 0 test_file.70
  101. 0 test_file.71
  102. 0 test_file.72
  103. 0 test_file.73
  104. 0 test_file.74
  105. 0 test_file.75
  106. 0 test_file.76
  107. 0 test_file.77
  108. 0 test_file.78
  109. 0 test_file.79
  110. 0 test_file.8
  111. 0 test_file.80
  112. 0 test_file.81
  113. 0 test_file.82
  114. 0 test_file.83
  115. 0 test_file.84
  116. 0 test_file.85
  117. 0 test_file.86
  118. 0 test_file.87
  119. 0 test_file.88
  120. 0 test_file.89
  121. 0 test_file.9
  122. 0 test_file.90
  123. 0 test_file.91
  124. 0 test_file.92
  125. 0 test_file.93
  126. 0 test_file.94
  127. 0 test_file.95
  128. 0 test_file.96
  129. 0 test_file.97
  130. 0 test_file.98
  131. 0 test_file.99
@@ -19,7 +19,7 @@
case 'io':
foreach ($data as $line) {
// The time it took to run the test
if (substr($line,0,11) == 'total time:') {
if ( (substr($line,0,11) == 'total time:') || (substr($line,0,13) == 'time elapsed:') ) {
$tmp = explode(':',$line);
$time = floatval($tmp[1]);
}
@@ -10,31 +10,68 @@ fi
# Install sysbench if it is not found

# First attempt: install from included repos
if [[ ! -f /usr/bin/sysbench ]]; then
if [[ ! -f /usr/bin/sysbench ]] && [[ ! -f /usr/local/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
if [[ ! -f /usr/bin/sysbench ]] && [[ ! -f /usr/local/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, so abort
if [[ ! -f /usr/bin/sysbench ]]; then
# Still no success, compile from source
if [[ ! -f /usr/bin/sysbench ]] && [[ ! -f /usr/local/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
# Now, report the issue to screen and exit
echo "sysbench is not yet available on this build."
exit

# 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 libmariadb-dev-compat
apt -y install libmariadb-dev
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 ]] && [[ ! -f /usr/local/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

# Determine the location of sysbench
if [[ -f /usr/local/bin/sysbench ]]; then
sysbench=/usr/local/bin/sysbench
elif [[ -f /usr/bin/sysbench ]]; then
sysbench=/usr/bin/sysbench
fi

# Set a runtime
if [[ -f /var/log/nems/benchmarks/runtime ]]; then
lastruntime=`cat /var/log/nems/benchmarks/runtime`
@@ -85,23 +122,40 @@ echo "Number of threads: $cores" >> /tmp/nems-benchmark.log

cd /tmp

# Determine if we're on an old version of SysBench requiring --test=
help=`$sysbench --help`
if [[ $help == *"--test="* ]]; then
# Old version
command="$sysbench --test="
else
# Modern version
command="$sysbench "
fi
if [[ $help == *"--num-threads="* ]]; then
# Old version
threadsswitch="--num-threads"
else
# Modern version
threadsswitch="--threads"
fi

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`
cpu=`${command}cpu --cpu-max-prime=20000 $threadsswitch=$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`
ram=`${command}memory $threadsswitch=$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`
mutex=`${command}mutex $threadsswitch=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`
io=`${command}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

@@ -0,0 +1,168 @@
#!/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

BIN +16 MB test_file.0
Binary file not shown.
BIN +16 MB test_file.1
Binary file not shown.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
BIN +16 MB test_file.2
Binary file not shown.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
BIN +8.25 MB test_file.3
Binary file not shown.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.

0 comments on commit be4af6d

Please sign in to comment.
You can’t perform that action at this time.