summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Ritter2021-11-05 12:41:39 +0100
committerSteffen Ritter2021-11-05 12:41:39 +0100
commitd4b533ffeeed3ce0a4310c3079993e88a42193c7 (patch)
tree3eecd8ffe4af3f9d0ae0c8028b0788fd3fcbd209
parent[dozmod] new resource to request image details (diff)
downloadslx-admin-d4b533ffeeed3ce0a4310c3079993e88a42193c7.tar.gz
slx-admin-d4b533ffeeed3ce0a4310c3079993e88a42193c7.tar.xz
slx-admin-d4b533ffeeed3ce0a4310c3079993e88a42193c7.zip
[statistics_reporting] Always send a minimal report
Even if reporting is disabled send an absolute minimal report which includes at least the satellite version but nothing more. This is just for tracking how many servers are in use.
-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
+}