Skip to content

Commit

Permalink
Include piWatcher on NEMS Server Overview
Browse files Browse the repository at this point in the history
  • Loading branch information
NEMS Linux committed Feb 23, 2019
1 parent d9d977c commit b01e602
Showing 1 changed file with 76 additions and 75 deletions.
151 changes: 76 additions & 75 deletions info/index.php
Original file line number Diff line number Diff line change
@@ -1,75 +1,76 @@
<?php
include('/var/www/html/inc/functions.php');
if (!initialized()) {
include('../init.php');
exit();
}
if (ver('nems') < 1.3) {
exit('Requires NEMS 1.3+');
}

if (file_exists('/var/log/nems/stats.log')) {
$tmp=file('/var/log/nems/stats.log');
if (is_array($tmp)) {
$tmp = array_reverse($tmp);
foreach ($tmp as $line) {
if (substr($line,0,2) == 'a:') {
$statlog = unserialize($line);
if (isset($statlog['benchmarks']) && substr($statlog['benchmarks'],0,2) == '{"') {
$tmp2=json_decode($statlog['benchmarks']);
unset($statlog['benchmarks']);
$statlog['benchmarks'] = $tmp2;
unset($tmp2);
}
unset($tmp);
break;
}
}
}
}

include('/var/www/html/inc/header.php');

$platform = ver('platform');

exec('/usr/local/share/nems/nems-scripts/speedtest --list',$servernum_tmp);
if (is_array($servernum_tmp)) {
foreach ($servernum_tmp as $line) {
$tmp = explode(')',$line);
if (intval($tmp[0]) > 0) {
$speedtestservers[] = array(
'num'=>intval($tmp[0]),
);
break; // we only need one
}
}
}

?>

<div class="container" style="margin-top: 100px; padding-bottom: 100px;">
<h2><b>NEMS</b> Server Overview</h2>
<p style="padding:4px 6px; color: #aaa !important;"><b>Your NEMS Hardware ID:</b> <span class="nems-green"><?= shell_exec('/usr/local/bin/nems-info hwid'); ?></span><br />Your NEMS HWID is a unique, but anonymous identifier for your NEMS Linux server.</p>
<p style="padding:4px 6px; color: #aaa !important;"><b>NEMS Server IP Address:</b> <span class="nems-green"><?= shell_exec('/usr/local/bin/nems-info ip'); ?></span><br />If nems.local is not resolving, you may use the IP address to connect to your NEMS server.</p>
<p style="padding:4px 6px; color: #aaa !important;"><b>NEMS Server Alias:</b> <span class="nems-green"><?= shell_exec('/usr/local/bin/nems-info alias'); ?></span></p>
<p style="padding:4px 6px; color: #aaa !important;"><b>Running As:</b> <span class="nems-green"><?= shell_exec('/usr/local/bin/nems-info username'); ?></span></p>
<p style="padding:4px 6px; color: #aaa !important;"><b>NEMS Version Running:</b> <span class="nems-green"><?= shell_exec('/usr/local/bin/nems-info nemsver'); ?></span></p>
<p style="padding:4px 6px; color: #aaa !important;"><b>NEMS Version Available:</b> <span class="nems-green"><?= shell_exec('/usr/local/bin/nems-info nemsveravail'); ?></span></p>
<p style="padding:4px 6px; color: #aaa !important;"><b>NEMS Platform:</b> <span class="nems-green"><?= shell_exec('/usr/local/bin/nems-info platform-name'); ?></span></p>
<p style="padding:4px 6px; color: #aaa !important;"><b>NEMS Network Interface:</b> <span class="nems-green"><?= shell_exec('/usr/local/bin/nems-info nic'); ?></span></p>
<p style="padding:4px 6px; color: #aaa !important;"><b>Number of Hosts:</b> <span class="nems-green"><?= shell_exec('/usr/local/bin/nems-info hosts'); ?></span></p>
<p style="padding:4px 6px; color: #aaa !important;"><b>Number of Services:</b> <span class="nems-green"><?= shell_exec('/usr/local/bin/nems-info services'); ?></span></p>
<p style="padding:4px 6px; color: #aaa !important;"><b>Authorized for Cloud:</b> <span class="nems-green"><?php if (shell_exec('/usr/local/bin/nems-info cloudauth') == 1) echo 'Yes'; else echo 'No'; ?></span></p>

<p style="padding:4px 6px; color: #aaa !important;"><b>Local Speedtest Server Number:</b> <span class="nems-green"><?= $speedtestservers[0]['num'] ?></span></p>

<?php
if (isset($statlog) && is_array($statlog)) {
echo '<p style="padding:4px 6px; color: #aaa !important;"><b>NEMS Anonymous Stats:</b><br />This anonymous data helps me understand how NEMS servers are performing. In the interest of transparency and so you know exactly what is being sent, here is a log of the most recent data your server shared (the dataset is always the same, though the numbers may change):<br /><pre>' . print_r($statlog,true) . '</pre><span style="color:#aaa">This data is sent to the NEMS API via an encrypted connection and stored anonymously. You may read more about this <a href="https://docs.nemslinux.com/anonymous_stats" target="_blank">in the NEMS Documentation</a>.<br />You can see the full log at /var/log/nems/stats.log</span></p>';
}
?>

</div>
<?php
include('/var/www/html/inc/footer.php');
?>
<?php
include('/var/www/html/inc/functions.php');
if (!initialized()) {
include('../init.php');
exit();
}
if (ver('nems') < 1.3) {
exit('Requires NEMS 1.3+');
}

if (file_exists('/var/log/nems/stats.log')) {
$tmp=file('/var/log/nems/stats.log');
if (is_array($tmp)) {
$tmp = array_reverse($tmp);
foreach ($tmp as $line) {
if (substr($line,0,2) == 'a:') {
$statlog = unserialize($line);
if (isset($statlog['benchmarks']) && substr($statlog['benchmarks'],0,2) == '{"') {
$tmp2=json_decode($statlog['benchmarks']);
unset($statlog['benchmarks']);
$statlog['benchmarks'] = $tmp2;
unset($tmp2);
}
unset($tmp);
break;
}
}
}
}

include('/var/www/html/inc/header.php');

$platform = ver('platform');

exec('/usr/local/share/nems/nems-scripts/speedtest --list',$servernum_tmp);
if (is_array($servernum_tmp)) {
foreach ($servernum_tmp as $line) {
$tmp = explode(')',$line);
if (intval($tmp[0]) > 0) {
$speedtestservers[] = array(
'num'=>intval($tmp[0]),
);
break; // we only need one
}
}
}

?>

<div class="container" style="margin-top: 100px; padding-bottom: 100px;">
<h2><b>NEMS</b> Server Overview</h2>
<p style="padding:4px 6px; color: #aaa !important;"><b>Your NEMS Hardware ID:</b> <span class="nems-green"><?= shell_exec('/usr/local/bin/nems-info hwid'); ?></span><br />Your NEMS HWID is a unique, but anonymous identifier for your NEMS Linux server.</p>
<p style="padding:4px 6px; color: #aaa !important;"><b>NEMS Server IP Address:</b> <span class="nems-green"><?= shell_exec('/usr/local/bin/nems-info ip'); ?></span><br />If nems.local is not resolving, you may use the IP address to connect to your NEMS server.</p>
<p style="padding:4px 6px; color: #aaa !important;"><b>NEMS Server Alias:</b> <span class="nems-green"><?= shell_exec('/usr/local/bin/nems-info alias'); ?></span></p>
<p style="padding:4px 6px; color: #aaa !important;"><b>Running As:</b> <span class="nems-green"><?= shell_exec('/usr/local/bin/nems-info username'); ?></span></p>
<p style="padding:4px 6px; color: #aaa !important;"><b>NEMS Version Running:</b> <span class="nems-green"><?= shell_exec('/usr/local/bin/nems-info nemsver'); ?></span></p>
<p style="padding:4px 6px; color: #aaa !important;"><b>NEMS Version Available:</b> <span class="nems-green"><?= shell_exec('/usr/local/bin/nems-info nemsveravail'); ?></span></p>
<p style="padding:4px 6px; color: #aaa !important;"><b>NEMS Platform:</b> <span class="nems-green"><?= shell_exec('/usr/local/bin/nems-info platform-name'); ?></span></p>
<?php if ($platform->num < 10) { ?><p style="padding:4px 6px; color: #aaa !important;"><b>piWatcher Present:</b> <span class="nems-green"><?php $piwatcher=shell_exec('/usr/local/bin/nems-info piwatcher'); if ($piwatcher == 1) { echo 'Yes'; } else { echo 'No <a class="btn btn-xs rounded btn-default" href="https://cat5.tv/piwatcher" target="_blank">Order</a>'; } } ?></span></p>
<p style="padding:4px 6px; color: #aaa !important;"><b>NEMS Network Interface:</b> <span class="nems-green"><?= shell_exec('/usr/local/bin/nems-info nic'); ?></span></p>
<p style="padding:4px 6px; color: #aaa !important;"><b>Number of Hosts:</b> <span class="nems-green"><?= shell_exec('/usr/local/bin/nems-info hosts'); ?></span></p>
<p style="padding:4px 6px; color: #aaa !important;"><b>Number of Services:</b> <span class="nems-green"><?= shell_exec('/usr/local/bin/nems-info services'); ?></span></p>
<p style="padding:4px 6px; color: #aaa !important;"><b>Authorized for Cloud:</b> <span class="nems-green"><?php if (shell_exec('/usr/local/bin/nems-info cloudauth') == 1) echo 'Yes'; else echo 'No'; ?></span></p>

<p style="padding:4px 6px; color: #aaa !important;"><b>Local Speedtest Server Number:</b> <span class="nems-green"><?= $speedtestservers[0]['num'] ?></span></p>

<?php
if (isset($statlog) && is_array($statlog)) {
echo '<p style="padding:4px 6px; color: #aaa !important;"><b>NEMS Anonymous Stats:</b><br />This anonymous data helps me understand how NEMS servers are performing. In the interest of transparency and so you know exactly what is being sent, here is a log of the most recent data your server shared (the dataset is always the same, though the numbers may change):<br /><pre>' . print_r($statlog,true) . '</pre><span style="color:#aaa">This data is sent to the NEMS API via an encrypted connection and stored anonymously. You may read more about this <a href="https://docs.nemslinux.com/anonymous_stats" target="_blank">in the NEMS Documentation</a>.<br />You can see the full log at /var/log/nems/stats.log</span></p>';
}
?>

</div>
<?php
include('/var/www/html/inc/footer.php');
?>

0 comments on commit b01e602

Please sign in to comment.