diff options
author | Simon Rettberg | 2017-03-02 14:27:00 +0100 |
---|---|---|
committer | Simon Rettberg | 2017-03-02 14:27:00 +0100 |
commit | 7b198f93c1848589501ff8e41809412aa7ff72f9 (patch) | |
tree | 8e53c4a42d02b629835b2c597921bdbcf45d66ce /modules-available/statistics_reporting/hooks/cron.inc.php | |
parent | [systemstatus] Add lighttpd error log (diff) | |
parent | [statistics_reporting] fixed column selector order (diff) | |
download | slx-admin-7b198f93c1848589501ff8e41809412aa7ff72f9.tar.gz slx-admin-7b198f93c1848589501ff8e41809412aa7ff72f9.tar.xz slx-admin-7b198f93c1848589501ff8e41809412aa7ff72f9.zip |
Merge branch 'statistics_reporting'
Diffstat (limited to 'modules-available/statistics_reporting/hooks/cron.inc.php')
-rw-r--r-- | modules-available/statistics_reporting/hooks/cron.inc.php | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/modules-available/statistics_reporting/hooks/cron.inc.php b/modules-available/statistics_reporting/hooks/cron.inc.php new file mode 100644 index 00000000..a48f74c2 --- /dev/null +++ b/modules-available/statistics_reporting/hooks/cron.inc.php @@ -0,0 +1,23 @@ +<?php + +if (RemoteReport::isReportingEnabled()) { + $nextReporting = RemoteReport::getReportingTimestamp(); + + // It's time to generate a new report + if ($nextReporting <= time()) { + RemoteReport::writeNextReportingTimestamp(); + + $from = strtotime("-7 days", $nextReporting); + $to = $nextReporting; + + $statisticsReport = json_encode(RemoteReport::generateReport($from, $to)); + + $params = array("action" => "statistics", "data" => $statisticsReport); + + $result = Download::asStringPost(CONFIG_REPORTING_URL, $params, 30, $code); + + if ($code != 200) { + EventLog::warning("Statistics Reporting failed: " . $code, $result); + } + } +}
\ No newline at end of file |