Permalink
Browse files

Move from Phoronix to sysbench

  • Loading branch information...
NEMS Linux
NEMS Linux committed Nov 12, 2018
1 parent 924281e commit 048cb3e516272080d8068948cb19f28907b6a79e
Showing with 95 additions and 231 deletions.
  1. +42 −0 benchmark-parse.sh
  2. +34 −86 benchmark.sh
  3. +15 −3 info.sh
  4. +0 −141 info2.sh
  5. +4 −1 stats.sh
@@ -0,0 +1,42 @@
#!/usr/bin/env php
<?php
if (isset($argv[1])) $test=$argv[1]; else die('This script is not made to be run manually.' . PHP_EOL);
$data = explode(PHP_EOL,stream_get_contents(STDIN));
if (is_array($data)) {
foreach ($data as $key=>$line) {
$data[$key] = trim($line);
if ($data[$key] == '') unset($data[$key]);
}
} else {
die('No data.' . PHP_EOL);
}
switch ($test) {
case 'cpu':
case 'ram':
case 'mutex':
case 'io':
foreach ($data as $line) {
// The time it took to run the test
if (substr($line,0,11) == 'total time:') {
$tmp = explode(':',$line);
$time = floatval($tmp[1]);
}
// The number of events during that time
if (substr($line,0,23) == 'total number of events:') {
$tmp = explode(':',$line);
$events = floatval($tmp[1]);
}
}
if ( ($events > 0) && ($time > 0) ) {
$result = ($events / $time);
echo $result;
} else {
echo 0;
}
break;
}
?>
@@ -1,7 +1,6 @@
#!/bin/bash
start=`date +%s`
plannedend=$(($start + 18000))
exit
nemsinit=`/usr/local/bin/nems-info init`
if [[ $nemsinit == 0 ]]; then
@@ -14,6 +13,10 @@ fi
echo "NEMS System Benchmark... Please Wait (may take a while)."
if [[ ! -f /usr/bin/sysbench ]]; then
apt install sysbench
fi
echo "NEMS System Benchmark" > /tmp/nems-benchmark.log
date >> /tmp/nems-benchmark.log
printf "NEMS Version: " >> /tmp/nems-benchmark.log
@@ -33,91 +36,35 @@ printf "LAN IP: " >> /tmp/nems-benchmark.log
echo "---------------------------------" >> /tmp/nems-benchmark.log
if (( $(awk 'BEGIN {print ("'$ver'" >= "'1.4.1'")}') )); then
# Phoronix Test Suite in NEMS 1.4.1+
# printf "Running Phoronix 'iozone' test..." >> /tmp/nems-benchmark.log
# /usr/bin/phoronix-test-suite batch-benchmark iozone
# echo " Done." >> /tmp/nems-benchmark.log
# printf "Running Phoronix 'smallpt' test..." >> /tmp/nems-benchmark.log
# /usr/bin/phoronix-test-suite batch-benchmark smallpt
# echo " Done." >> /tmp/nems-benchmark.log
# printf "Running Phoronix 'himeno' test..." >> /tmp/nems-benchmark.log
# /usr/bin/phoronix-test-suite batch-benchmark himeno
# echo " Done." >> /tmp/nems-benchmark.log
# printf "Running Phoronix 'ramspeed' test..." >> /tmp/nems-benchmark.log
# /usr/bin/phoronix-test-suite batch-benchmark ramspeed
# echo " Done." >> /tmp/nems-benchmark.log
# printf "Running Phoronix 'netperf' test..." >> /tmp/nems-benchmark.log
# /usr/bin/phoronix-test-suite batch-benchmark netperf
# echo " Done." >> /tmp/nems-benchmark.log
# printf "Running Phoronix 'apache' test..." >> /tmp/nems-benchmark.log
# /usr/bin/phoronix-test-suite batch-benchmark apache
# echo " Done." >> /tmp/nems-benchmark.log
# printf "Running Phoronix 'cachebench' test..." >> /tmp/nems-benchmark.log
# /usr/bin/phoronix-test-suite batch-benchmark cachebench
# echo " Done." >> /tmp/nems-benchmark.log
# printf "Running Phoronix 'scimark2' test..." >> /tmp/nems-benchmark.log
# /usr/bin/phoronix-test-suite batch-benchmark scimark2
# echo " Done." >> /tmp/nems-benchmark.log
# printf "Running Phoronix 'graphics-magick' test..." >> /tmp/nems-benchmark.log
# /usr/bin/phoronix-test-suite batch-benchmark graphics-magick
# echo " Done." >> /tmp/nems-benchmark.log
# printf "Running Phoronix 'ebizzy' test..." >> /tmp/nems-benchmark.log
# /usr/bin/phoronix-test-suite batch-benchmark ebizzy
# echo " Done." >> /tmp/nems-benchmark.log
# printf "Running Phoronix 'c-ray' test..." >> /tmp/nems-benchmark.log
# /usr/bin/phoronix-test-suite batch-benchmark c-ray
# echo " Done." >> /tmp/nems-benchmark.log
# printf "Running Phoronix 'stockfish' test..." >> /tmp/nems-benchmark.log
# /usr/bin/phoronix-test-suite batch-benchmark stockfish
# echo " Done." >> /tmp/nems-benchmark.log
# printf "Running Phoronix 'aobench' test..." >> /tmp/nems-benchmark.log
# /usr/bin/phoronix-test-suite batch-benchmark aobench
# echo " Done." >> /tmp/nems-benchmark.log
# printf "Running Phoronix 'timed-audio-encode' test..." >> /tmp/nems-benchmark.log
# /usr/bin/phoronix-test-suite batch-benchmark timed-audio-encode
# echo " Done." >> /tmp/nems-benchmark.log
# printf "Running Phoronix 'encode-mp3' test..." >> /tmp/nems-benchmark.log
# /usr/bin/phoronix-test-suite batch-benchmark encode-mp3
# echo " Done." >> /tmp/nems-benchmark.log
# printf "Running Phoronix 'perl-benchmark' test..." >> /tmp/nems-benchmark.log
# /usr/bin/phoronix-test-suite batch-benchmark perl-benchmark
# echo " Done." >> /tmp/nems-benchmark.log
# printf "Running Phoronix 'openssl' test..." >> /tmp/nems-benchmark.log
# /usr/bin/phoronix-test-suite batch-benchmark openssl
# echo " Done." >> /tmp/nems-benchmark.log
# printf "Running Phoronix 'redis' test..." >> /tmp/nems-benchmark.log
# /usr/bin/phoronix-test-suite batch-benchmark redis
# echo " Done." >> /tmp/nems-benchmark.log
# printf "Running Phoronix 'pybench' test..." >> /tmp/nems-benchmark.log
# /usr/bin/phoronix-test-suite batch-benchmark pybench
# echo " Done." >> /tmp/nems-benchmark.log
# printf "Running Phoronix 'phpbench' test..." >> /tmp/nems-benchmark.log
# /usr/bin/phoronix-test-suite batch-benchmark phpbench
# echo " Done." >> /tmp/nems-benchmark.log
# printf "Running Phoronix 'git' test..." >> /tmp/nems-benchmark.log
# /usr/bin/phoronix-test-suite batch-benchmark git
# echo " Done." >> /tmp/nems-benchmark.log
printf "Running Phoronix benchmarks..." >> /tmp/nems-benchmark.log
/usr/bin/phoronix-test-suite batch-benchmark smallpt himeno apache cachebench scimark2 graphics-magick ebizzy c-ray stockfish aobench timed-audio-encode encode-mp3perl-benchmark openssl redis pybench phpbench git
echo " Done." >> /tmp/nems-benchmark.log
else
printf "SD Card READ:" >> /tmp/nems-benchmark.log
/sbin/hdparm -t /dev/mmcblk0p2 >> /tmp/nems-benchmark.log
echo "SD Card WRITE:" >> /tmp/nems-benchmark.log
/bin/dd count=100 bs=1M if=/dev/zero of=/root/nems-benchmark.img 2>> /tmp/nems-benchmark.log
rm /root/nems-benchmark.img
echo "---------------------------------" >> /tmp/nems-benchmark.log
echo "Memory WRITE:" >> /tmp/nems-benchmark.log
/bin/dd count=100 bs=1M if=/dev/zero of=/tmp/nems-benchmark.img 2>> /tmp/nems-benchmark.log
rm /tmp/nems-benchmark.img
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
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
echo "---------------------------------" >> /tmp/nems-benchmark.log
echo "Filesystem:" >> /tmp/nems-benchmark.log
@@ -139,8 +86,9 @@ end=`date +%s`
runtime=$((end-start))
echo "Benchmark of this benchmark: "$runtime" seconds" >> /tmp/nems-benchmark.log
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
cat /tmp/nems-benchmark.log
rm /tmp/nems-benchmark.log
18 info.sh
@@ -187,12 +187,24 @@ elif [[ $COMMAND == "services" ]]; then
socket=$(/usr/local/bin/nems-info socket)
/usr/local/share/nems/nems-scripts/stats-livestatus.py $socket services
elif [[ $COMMAND == "phoronix" ]]; then
/usr/local/share/nems/nems-scripts/info2.sh 5 $VARIABLE
elif [[ $COMMAND == "downtimes" ]]; then
/usr/local/share/nems/nems-scripts/info2.sh 6
elif [[ $COMMAND == "benchmark" ]]; then
if [[ $VARIABLE == 'cpu' ]]; then
cat /var/log/nems/benchmarks/cpu
fi
if [[ $VARIABLE == 'mutex' ]]; then
cat /var/log/nems/benchmarks/mutex
fi
if [[ $VARIABLE == 'io' ]]; then
cat /var/log/nems/benchmarks/io
fi
if [[ $VARIABLE == 'ram' ]]; then
cat /var/log/nems/benchmarks/ram
fi
elif [[ $COMMAND == "alias" ]]; then
# From nems.conf
if [[ -f /usr/local/share/nems/nems.conf ]]; then
141 info2.sh
@@ -58,147 +58,6 @@ switch($argv[1]) {
}
break;
case 5:
$ver = floatval(shell_exec('/usr/local/bin/nems-info nemsver'));
if ($ver >= 1.4) { // EVERYTHING 1.4+
$logdir = '/var/log/nems/phoronix/';
$logfile = 'composite.xml';
$loglist = array_filter(explode(PHP_EOL,shell_exec('find ' . $logdir . ' -iname ' . $logfile)));
// list of supported tests
// key is the command-line name, value is how it appears in Result->Identifier in the xml ($dataobj)
$tests['netperf'] = 'netperf';
$tests['cachebench'] = 'cachebench';
$tests['scimark2'] = 'scimark';
$tests['graphics-magick'] = 'graphicsmagick';
$tests['ebizzy'] = 'ebizzy';
$tests['c-ray'] = 'c-ray';
$tests['stockfish'] = 'stockfish';
$tests['aobench'] = 'aobench';
$tests['timed-audio-encode'] = 'timed-audio-encode';
$tests['encode-mp3'] = 'encode-mp3';
$tests['perl-benchmark'] = 'perl-benchmark';
$tests['openssl'] = 'openssl';
$tests['redis'] = 'redis';
$tests['pybench'] = 'pybench';
$tests['phpbench'] = 'phpbench';
$tests['git'] = 'git';
$tests['smallpt'] = 'smallpt';
$tests['himeno'] = 'himeno';
$tests['all'] = 'all';
ksort($tests);
$usage = '';
foreach($tests as $test) {
$usage .= $test . '|';
}
$usage = substr($usage,0,-1);
if (!isset($argv[2]) || !array_key_exists($argv[2],$tests)) {
echo "Usage: nems-info phoronix [$usage]" . PHP_EOL;
exit();
}
// Some tests have multiple tests within
// choose the one we want via the description field
// If you leave it blank, it'll just be the last result of the test (ie., the only one if only one)
$descfield['netperf'] = '';
$descfield['cachebench'] = 'Test: Read / Modify / Write';
$descfield['scimark2'] = 'Computational Test: Jacobi Successive Over-Relaxation';
$descfield['graphics-magick'] = 'Operation: Resizing';
$descfield['ebizzy'] = ''; // actually does not have a description
$descfield['c-ray'] = '';
$descfield['stockfish'] = '';
$descfield['aobench'] = '';
$descfield['timed-audio-encode'] = '';
$descfield['encode-mp3'] = '';
$descfield['perl-benchmark'] = '';
$descfield['openssl'] = '';
$descfield['redis'] = 'Test: SET';
$descfield['pybench'] = '';
$descfield['phpbench'] = '';
$descfield['git'] = '';
$descfield['apache'] = 'Static Web Page Serving';
$descfield['smallpt'] = '';
$descfield['himeno'] = '';
if (isset($loglist) && is_array($loglist)) {
foreach ($loglist as $file) {
$tmp = explode($logdir,$file);
$tmp = array_filter(explode($logfile,$tmp[1]));
$date = strtotime(str_replace('/','',$tmp[0]));
$logs[$date] = $file;
}
if (isset($logs) && is_array($logs)) {
ksort($logs); // sort to ensure oldest is first (so value overwrites)
function check_test($title,$tests) {
if (is_array($tests)) { // checking array (list of tests)
foreach($tests as $key=>$test) {
// First, check the test name (key) as per array above
if (strpos(strtolower($title), $key) !== false) {
return $key;
}
// Try searching the xml Result->Identifier name (test)
if (strpos(strtolower($title), $test) !== false) {
return $key;
}
}
} else { // checking string (one specific test)
if (strpos(strtolower($title), $tests) !== false) {
return $tests;
}
}
return false;
}
foreach ($logs as $date => $log) {
$dataobj = new SimpleXMLElement(file_get_contents($log));
foreach ($dataobj as $data) {
if ($approvedtest = check_test(strtolower($data->Identifier),$tests)) {
if ($argv[2] == 'all') {
// we already know the test's title matches, so let's see if the desc does
if ($approvedtest != 'all' && ($descfield[$approvedtest] == '' || $data->Description == $descfield[$approvedtest])) {
$resulttmp[$approvedtest] = floatval($data->Data->Entry->Value);
// Append any missing tests with 0 value
foreach ($tests as $test => $internalname) {
if ($test != 'all' && !isset($resulttmp[strtolower($test)])) $resulttmp[strtolower($test)] = 0;
}
ksort($resulttmp);
$result = json_encode($resulttmp);
}
} else {
if (check_test(strtolower($data->Identifier),$argv[2])) {
$count=0; foreach ($data as $dataresult) { $count++; } // YES, I am being lazy.
foreach ($data as $dataresult) {
if ($count > 1) { // use the one labeled "average"
if (check_test(strtolower($dataresult->Description),'average')) {
$result = floatval($dataresult->Data->Entry->Value);
break;
}
} else {
$result = floatval($dataresult->Data->Entry->Value);
break;
}
}
}
}
}
}
}
if (isset($result)) {
echo $result;
} else {
echo 0;
}
}
} else {
return false;
}
} else {
echo 0;
}
break;
case 6: // list scheduled downtime
$ch = curl_init();
$timeout = 5;
@@ -44,7 +44,10 @@ if (file_exists('/var/log/nems/hw_model')) { // Don't run this until system is r
$days = $num;
// Get system benchmarks
$benchmarks = (array)json_decode(shell_exec('/usr/local/bin/nems-info phoronix all'));
$benchmarks['cpu'] = shell_exec('/usr/local/bin/nems-info benchmark cpu');
$benchmarks['ram'] = shell_exec('/usr/local/bin/nems-info benchmark ram');
$benchmarks['io'] = shell_exec('/usr/local/bin/nems-info benchmark io');
$benchmarks['mutex'] = shell_exec('/usr/local/bin/nems-info benchmark mutex');
// Put it together to send to the server
$data = array(

0 comments on commit 048cb3e

Please sign in to comment.