blob: f6d18801408958a90bf95da82d0037f44bc7d10b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
<?php
class SystemStatus
{
/**
* Collect status about the disk and vmstore.
* The *Usage vars are filled with arrays with keys mountPoint, fileSystem,
* usedPercent, sizeKb, freeKb.
* @param array|false $systemUsage
* @param array|false $storeUsage
* @param string|false $currentSource What's currently mounted as vmstore
* @param string|false $wantedSource What should be mounted as vmstore (false if nothing configured)
* @return bool false if querying fs data from taskmanager failed
*/
public static function diskStat(&$systemUsage, &$storeUsage, &$currentSource = false, &$wantedSource = false)
{
$task = Taskmanager::submit('DiskStat');
if ($task === false)
return false;
$task = Taskmanager::waitComplete($task, 3000);
if (!isset($task['data']['list']) || empty($task['data']['list']))
return false;
$wantedSource = Property::getVmStoreUrl();
$storeUsage = false;
$systemUsage = false;
if ($wantedSource === '<local>') {
$storePoint = '/';
$currentSource = $wantedSource;
} else {
$storePoint = CONFIG_VMSTORE_DIR;
$currentSource = false;
}
// Collect free space information
foreach ($task['data']['list'] as $entry) {
// StorePoint is either the actual directory of the vmstore, or / if we use internal storage
if ($entry['mountPoint'] === $storePoint) {
$storeUsage = $entry;
}
// Always report free space on system disk
if ($entry['mountPoint'] === '/') {
$systemUsage = $entry;
}
// Record what's mounted at destination, regardless of config, to indicate something is wrong
if ($entry['mountPoint'] === CONFIG_VMSTORE_DIR) {
$currentSource = $entry['fileSystem'];
}
}
return true;
}
}
|