Permalink
Browse files

Show stat log in NEMS Server Overview

  • Loading branch information...
NEMS Linux
NEMS Linux committed Nov 30, 2018
1 parent ecfec4e commit 5ad8c6a1ead98564eb44c1022f03aa368efcf9e4
Showing with 27 additions and 0 deletions.
  1. +27 −0 info/index.php
@@ -7,9 +7,31 @@
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');
?>

<div class="container" style="margin-top: 100px; padding-bottom: 100px;">
@@ -26,6 +48,11 @@
<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 cloud') == 1) echo 'Yes'; else echo 'No'; ?></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

0 comments on commit 5ad8c6a

Please sign in to comment.