summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules-available/statistics_reporting/hooks/cron.inc.php30
-rw-r--r--modules-available/statistics_reporting/inc/remotereport.inc.php52
2 files changed, 41 insertions, 41 deletions
diff --git a/modules-available/statistics_reporting/hooks/cron.inc.php b/modules-available/statistics_reporting/hooks/cron.inc.php
index 14597f7d..7336b7d1 100644
--- a/modules-available/statistics_reporting/hooks/cron.inc.php
+++ b/modules-available/statistics_reporting/hooks/cron.inc.php
@@ -1,25 +1,23 @@
<?php
-if (RemoteReport::isReportingEnabled()) {
- $nextReporting = RemoteReport::getReportingTimestamp();
+$nextReporting = RemoteReport::getReportingTimestamp();
- // It's time to generate a new report
- while ($nextReporting <= time()) {
- RemoteReport::writeNextReportingTimestamp();
+// It's time to generate a new report
+while ($nextReporting <= time()) {
+ RemoteReport::writeNextReportingTimestamp();
- $to = $nextReporting;
+ $to = $nextReporting;
- $statisticsReport = json_encode(RemoteReport::generateReport($to));
+ $statisticsReport = json_encode(RemoteReport::generateReport($to));
- $params = array("action" => "statistics", "data" => $statisticsReport);
+ $params = array("action" => "statistics", "data" => $statisticsReport);
- $result = Download::asStringPost(CONFIG_REPORTING_URL, $params, 30, $code);
+ $result = Download::asStringPost(CONFIG_REPORTING_URL, $params, 30, $code);
- if ($code != 200) {
- EventLog::warning("Statistics Reporting failed: " . $code, $result);
- } else {
- EventLog::info('Statistics report sent to ' . CONFIG_REPORTING_URL);
- }
- $nextReporting = strtotime("+7 days", $nextReporting);
+ if ($code != 200) {
+ EventLog::warning("Statistics Reporting failed: " . $code, $result);
+ } else {
+ EventLog::info('Statistics report sent to ' . CONFIG_REPORTING_URL);
}
-} \ No newline at end of file
+ $nextReporting = strtotime("+7 days", $nextReporting);
+}
diff --git a/modules-available/statistics_reporting/inc/remotereport.inc.php b/modules-available/statistics_reporting/inc/remotereport.inc.php
index 376691dd..98f366b6 100644
--- a/modules-available/statistics_reporting/inc/remotereport.inc.php
+++ b/modules-available/statistics_reporting/inc/remotereport.inc.php
@@ -69,32 +69,34 @@ class RemoteReport
* @return array wrapped up statistics, ready for reporting
*/
public static function generateReport(int $to, $days = false) {
- if ($days === false) {
- $days = [7, 30, 90];
- }
- GetData::$salt = bin2hex(Util::randomBytes(20, false));
- GetData::$lowerTimeBound = 7;
- GetData::$upperTimeBound = 20;
$result = array();
- foreach ($days as $day) {
- if (isset($result['days' . $day]))
- continue;
- $from = strtotime("-{$day} days", $to);
- GetData::$from = $from;
- GetData::$to = $to;
- $data = array('total' => GetData::total(GETDATA_ANONYMOUS));
- $data['perLocation'] = array_values(GetData::perLocation(GETDATA_ANONYMOUS));
- $data['perVM'] = GetData::perVM(GETDATA_ANONYMOUS);
- $data['tsFrom'] = $from;
- $data['tsTo'] = $to;
- $data['dozmod'] = Queries::getDozmodStats($from, $to);
- $data['machines'] = Queries::getAggregatedMachineStats($from);
- $data['exams'] = Queries::getExamStats($from, $to);
- $data['baseSystem'] = Queries::getBaseSystemStats($from, $to);
- $data['runmode'] = Queries::getRunmodeStats($from, $to);
- $result['days' . $day] = $data;
+ if (RemoteReport::isReportingEnabled()) {
+ if ($days === false) {
+ $days = [7, 30, 90];
+ }
+ GetData::$salt = bin2hex(Util::randomBytes(20, false));
+ GetData::$lowerTimeBound = 7;
+ GetData::$upperTimeBound = 20;
+ foreach ($days as $day) {
+ if (isset($result['days' . $day]))
+ continue;
+ $from = strtotime("-{$day} days", $to);
+ GetData::$from = $from;
+ GetData::$to = $to;
+ $data = array('total' => GetData::total(GETDATA_ANONYMOUS));
+ $data['perLocation'] = array_values(GetData::perLocation(GETDATA_ANONYMOUS));
+ $data['perVM'] = GetData::perVM(GETDATA_ANONYMOUS);
+ $data['tsFrom'] = $from;
+ $data['tsTo'] = $to;
+ $data['dozmod'] = Queries::getDozmodStats($from, $to);
+ $data['machines'] = Queries::getAggregatedMachineStats($from);
+ $data['exams'] = Queries::getExamStats($from, $to);
+ $data['baseSystem'] = Queries::getBaseSystemStats($from, $to);
+ $data['runmode'] = Queries::getRunmodeStats($from, $to);
+ $result['days' . $day] = $data;
+ }
+ $result['server'] = self::getLocalHardware();
}
- $result['server'] = self::getLocalHardware();
$result['version'] = CONFIG_FOOTER;
return $result;
}
@@ -127,4 +129,4 @@ class RemoteReport
return $data;
}
-} \ No newline at end of file
+}