summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics/api.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/statistics/api.inc.php')
-rw-r--r--modules-available/statistics/api.inc.php17
1 files changed, 12 insertions, 5 deletions
diff --git a/modules-available/statistics/api.inc.php b/modules-available/statistics/api.inc.php
index b8ef2eb1..3e8ed917 100644
--- a/modules-available/statistics/api.inc.php
+++ b/modules-available/statistics/api.inc.php
@@ -112,7 +112,7 @@ if ($type{0} === '~') {
. ' cpumodel = :cpumodel,'
. ' systemmodel = :systemmodel,'
. ' id44mb = :id44mb,'
- . ' live_tmpsize = 0, live_swapsize = 0, live_memsize = 0,'
+ . ' live_tmpsize = 0, live_swapsize = 0, live_memsize = 0, cpuload = 255',
. ' badsectors = :badsectors,'
. ' data = :data,'
. ' state = :state '
@@ -215,11 +215,16 @@ if ($type{0} === '~') {
}
}
}
- foreach (['memsize', 'tmpsize', 'swapsize', 'memfree', 'tmpfree', 'swapfree'] as $item) {
+ foreach (['memsize', 'tmpsize', 'swapsize', 'memfree', 'tmpfree', 'swapfree', 'cpuload'] as $item) {
$liveVal = Request::post($item, false, 'int');
if ($liveVal !== false) {
$strUpdateBoottime .= ' live_' . $item . ' = :_' . $item . ', ';
- $params['_' . $item] = ceil($liveVal / 1024);
+ if ($item === 'cpuload') {
+ $liveVal = round($liveVal);
+ } else {
+ $liveVal = ceil($liveVal / 1024);
+ }
+ $params['_' . $item] = $liveVal;
}
}
// Figure out what's happening - state changes
@@ -358,7 +363,8 @@ if ($type{0} === '~') {
updateIp('suspend', $uuid, $old, $ip);
}
if ($NOW - $old['lastseen'] < 610 && $old['state'] !== 'OFFLINE') {
- Database::exec("UPDATE machine SET lastseen = UNIX_TIMESTAMP(), state = 'STANDBY'
+ Database::exec("UPDATE machine SET lastseen = UNIX_TIMESTAMP(), state = 'STANDBY',
+ standbysem = If(standbysem < 6, standbysem + 1, 6)
WHERE machineuuid = :uuid AND state = :oldstate AND lastseen = :oldlastseen",
array('uuid' => $uuid, 'oldlastseen' => $old['lastseen'], 'oldstate' => $old['state']));
} else {
@@ -371,7 +377,8 @@ if ($type{0} === '~') {
updateIp('resume', $uuid, $old, $ip);
}
if ($old['state'] === 'STANDBY') {
- $res = Database::exec("UPDATE machine SET state = 'IDLE', clientip = :ip, lastseen = UNIX_TIMESTAMP()
+ $res = Database::exec("UPDATE machine SET state = 'IDLE', clientip = :ip, lastseen = UNIX_TIMESTAMP(),
+ standbysem = If(standbysem > 1, standbysem - 2, 0)
WHERE machineuuid = :uuid AND state = :oldstate AND lastseen = :oldlastseen",
array('uuid' => $uuid, 'ip' => $ip, 'oldlastseen' => $old['lastseen'], 'oldstate' => $old['state']));
// Write standby period length to statistic table