From c124192e63bd8a48ed1e7caf9542dc52505dfd22 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 24 Jan 2019 12:17:07 +0100 Subject: [statistics] Handling of standby state in statistics, log crashes Or rather, not really crashes, but log whenever a client reports a poweron event without reporting a proper shutdown first. This isn't neccessarily a crash but could also be due to power loss, hard poweroff, or network failures. --- modules-available/statistics/inc/statistics.inc.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'modules-available/statistics/inc/statistics.inc.php') diff --git a/modules-available/statistics/inc/statistics.inc.php b/modules-available/statistics/inc/statistics.inc.php index 2500f16f..1f8a081a 100644 --- a/modules-available/statistics/inc/statistics.inc.php +++ b/modules-available/statistics/inc/statistics.inc.php @@ -70,4 +70,21 @@ class Statistics return $list; } + const SESSION_LENGTH = '~session-length'; + const OFFLINE_LENGTH = '~offline-length'; + const SUSPEND_LENGTH = '~suspend-length'; + + public static function logMachineState($uuid, $ip, $type, $start, $length, $username = '') + { + return Database::exec('INSERT INTO statistic (dateline, typeid, machineuuid, clientip, username, data)' + . " VALUES (:start, :type, :uuid, :clientip, :username, :length)", array( + 'start' => $start, + 'type' => $type, + 'uuid' => $uuid, + 'clientip' => $ip, + 'username' => $username, + 'length' => $length, + )); + } + } -- cgit v1.2.3-55-g7522