diff options
Diffstat (limited to 'modules-available/statistics')
-rw-r--r-- | modules-available/statistics/api.inc.php | 1 | ||||
-rw-r--r-- | modules-available/statistics/hooks/cron.inc.php | 11 |
2 files changed, 8 insertions, 4 deletions
diff --git a/modules-available/statistics/api.inc.php b/modules-available/statistics/api.inc.php index 7b5678de..a614658a 100644 --- a/modules-available/statistics/api.inc.php +++ b/modules-available/statistics/api.inc.php @@ -79,7 +79,6 @@ if ($type{0} === '~') { 'id44mb' => $id44mb, 'badsectors' => $badsectors, 'data' => $data, - 'hostname' => $hostname, 'state' => 'IDLE', ); // Create/update machine entry diff --git a/modules-available/statistics/hooks/cron.inc.php b/modules-available/statistics/hooks/cron.inc.php index eb88173d..4df7b0d4 100644 --- a/modules-available/statistics/hooks/cron.inc.php +++ b/modules-available/statistics/hooks/cron.inc.php @@ -4,9 +4,14 @@ function logstats() { $NOW = time(); $cutoff = $NOW - 86400 * 30; - $known = Database::queryFirst("SELECT Count(*) AS val FROM machine WHERE lastseen > $cutoff"); - $on = Database::queryFirst("SELECT Count(*) AS val FROM machine WHERE state IN ('IDLE', 'OCCUPIED')"); - $used = Database::queryFirst("SELECT Count(*) AS val FROM machine WHERE state = 'OCCUPIED'"); + $join = $where = ''; + if (Module::get('runmode') !== false) { + $join = 'LEFT JOIN runmode r USING (machineuuid)'; + $where = 'AND (r.isclient IS NULL OR r.isclient <> 0)'; + } + $known = Database::queryFirst("SELECT Count(*) AS val FROM machine m $join WHERE m.lastseen > $cutoff $where"); + $on = Database::queryFirst("SELECT Count(*) AS val FROM machine m $join WHERE m.state IN ('IDLE', 'OCCUPIED') $where"); + $used = Database::queryFirst("SELECT Count(*) AS val FROM machine m $join WHERE m.state = 'OCCUPIED' $where"); Database::exec("INSERT INTO statistic (dateline, typeid, clientip, username, data) VALUES (:now, '~stats', '', '', :vals)", array( 'now' => $NOW, 'vals' => $known['val'] . '#' . $on['val'] . '#' . $used['val'], |