File tree 8 files changed +205
-0
lines changed
8 files changed +205
-0
lines changed Original file line number Diff line number Diff line change @@ -11,9 +11,33 @@ class Statistics extends \PleskX\Api\Struct
11
11
/** @var Statistics\Version */
12
12
public $ version ;
13
13
14
+ /** @var Statistics\Other */
15
+ public $ other ;
16
+
17
+ /** @var Statistics\LoadAverage */
18
+ public $ loadAverage ;
19
+
20
+ /** @var Statistics\Memory */
21
+ public $ memory ;
22
+
23
+ /** @var Statistics\Swap */
24
+ public $ swap ;
25
+
26
+ /** @var Statistics\DiskSpace[] */
27
+ public $ diskSpace ;
28
+
14
29
public function __construct ($ apiResponse )
15
30
{
16
31
$ this ->objects = new Statistics \Objects ($ apiResponse ->objects );
17
32
$ this ->version = new Statistics \Version ($ apiResponse ->version );
33
+ $ this ->other = new Statistics \Other ($ apiResponse ->other );
34
+ $ this ->loadAverage = new Statistics \LoadAverage ($ apiResponse ->load_avg );
35
+ $ this ->memory = new Statistics \Memory ($ apiResponse ->mem );
36
+ $ this ->swap = new Statistics \Swap ($ apiResponse ->swap );
37
+
38
+ $ this ->diskSpace = [];
39
+ foreach ($ apiResponse ->diskspace as $ disk ) {
40
+ $ this ->diskSpace [(string ) $ disk ->device ->name ] = new Statistics \DiskSpace ($ disk ->device );
41
+ }
18
42
}
19
43
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+ // Copyright 1999-2021. Plesk International GmbH.
3
+
4
+ namespace PleskX \Api \Struct \Server \Statistics ;
5
+
6
+ class DiskSpace extends \PleskX \Api \Struct
7
+ {
8
+ /** @var int */
9
+ public $ total ;
10
+
11
+ /** @var int */
12
+ public $ used ;
13
+
14
+ /** @var int */
15
+ public $ free ;
16
+
17
+ public function __construct ($ apiResponse )
18
+ {
19
+ $ this ->_initScalarProperties ($ apiResponse , [
20
+ 'total ' ,
21
+ 'used ' ,
22
+ 'free ' ,
23
+ ]);
24
+ }
25
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ // Copyright 1999-2021. Plesk International GmbH.
3
+
4
+ namespace PleskX \Api \Struct \Server \Statistics ;
5
+
6
+ class LoadAverage extends \PleskX \Api \Struct
7
+ {
8
+ /** @var float */
9
+ public $ load1min ;
10
+
11
+ /** @var float */
12
+ public $ load5min ;
13
+
14
+ /** @var float */
15
+ public $ load15min ;
16
+
17
+ public function __construct ($ apiResponse )
18
+ {
19
+ $ this ->load1min = $ apiResponse ->l1 / 100.0 ;
20
+ $ this ->load5min = $ apiResponse ->l5 / 100.0 ;
21
+ $ this ->load15min = $ apiResponse ->l15 / 100.0 ;
22
+ }
23
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ // Copyright 1999-2021. Plesk International GmbH.
3
+
4
+ namespace PleskX \Api \Struct \Server \Statistics ;
5
+
6
+ class Memory extends \PleskX \Api \Struct
7
+ {
8
+ /** @var int */
9
+ public $ total ;
10
+
11
+ /** @var int */
12
+ public $ used ;
13
+
14
+ /** @var int */
15
+ public $ free ;
16
+
17
+ /** @var int */
18
+ public $ shared ;
19
+
20
+ /** @var int */
21
+ public $ buffer ;
22
+
23
+ /** @var int */
24
+ public $ cached ;
25
+
26
+ public function __construct ($ apiResponse )
27
+ {
28
+ $ this ->_initScalarProperties ($ apiResponse , [
29
+ 'total ' ,
30
+ 'used ' ,
31
+ 'free ' ,
32
+ 'shared ' ,
33
+ 'buffer ' ,
34
+ 'cached ' ,
35
+ ]);
36
+ }
37
+ }
Original file line number Diff line number Diff line change @@ -11,11 +11,47 @@ class Objects extends \PleskX\Api\Struct
11
11
/** @var int */
12
12
public $ domains ;
13
13
14
+ /** @var int */
15
+ public $ databases ;
16
+
17
+ /** @var int */
18
+ public $ activeDomains ;
19
+
20
+ /** @var int */
21
+ public $ mailBoxes ;
22
+
23
+ /** @var int */
24
+ public $ mailRedirects ;
25
+
26
+ /** @var int */
27
+ public $ mailGroups ;
28
+
29
+ /** @var int */
30
+ public $ mailResponders ;
31
+
32
+ /** @var int */
33
+ public $ databaseUsers ;
34
+
35
+ /** @var int */
36
+ public $ problemClients ;
37
+
38
+ /** @var int */
39
+ public $ problemDomains ;
40
+
14
41
public function __construct ($ apiResponse )
15
42
{
16
43
$ this ->_initScalarProperties ($ apiResponse , [
17
44
'clients ' ,
18
45
'domains ' ,
46
+ 'databases ' ,
47
+ ['active_domains ' => 'activeDomains ' ],
48
+ ['mail_boxes ' => 'mailBoxes ' ],
49
+ ['mail_redirects ' => 'mailRedirects ' ],
50
+ ['mail_groups ' => 'mailGroups ' ],
51
+ ['mail_responders ' => 'mailResponders ' ],
52
+ ['database_users ' => 'databaseUsers ' ],
53
+ ['problem_clients ' => 'problemClients ' ],
54
+ ['problem_domains ' => 'problemDomains ' ],
19
55
]);
20
56
}
21
57
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+ // Copyright 1999-2021. Plesk International GmbH.
3
+
4
+ namespace PleskX \Api \Struct \Server \Statistics ;
5
+
6
+ class Other extends \PleskX \Api \Struct
7
+ {
8
+ /** @var string */
9
+ public $ cpu ;
10
+
11
+ /** @var int */
12
+ public $ uptime ;
13
+
14
+ /** @var bool */
15
+ public $ insideVz ;
16
+
17
+ public function __construct ($ apiResponse )
18
+ {
19
+ $ this ->_initScalarProperties ($ apiResponse , [
20
+ 'cpu ' ,
21
+ 'uptime ' ,
22
+ ['inside_vz ' => 'insideVz ' ],
23
+ ]);
24
+ }
25
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ // Copyright 1999-2021. Plesk International GmbH.
3
+
4
+ namespace PleskX \Api \Struct \Server \Statistics ;
5
+
6
+ class Swap extends \PleskX \Api \Struct
7
+ {
8
+ /** @var int */
9
+ public $ total ;
10
+
11
+ /** @var int */
12
+ public $ used ;
13
+
14
+ /** @var int */
15
+ public $ free ;
16
+
17
+ public function __construct ($ apiResponse )
18
+ {
19
+ $ this ->_initScalarProperties ($ apiResponse , [
20
+ 'total ' ,
21
+ 'used ' ,
22
+ 'free ' ,
23
+ ]);
24
+ }
25
+ }
Original file line number Diff line number Diff line change @@ -92,9 +92,19 @@ public function testGetStatistics()
92
92
{
93
93
$ stats = static ::$ _client ->server ()->getStatistics ();
94
94
$ this ->assertIsNumeric ($ stats ->objects ->clients );
95
+ $ this ->assertIsNumeric ($ stats ->objects ->domains );
96
+ $ this ->assertIsNumeric ($ stats ->objects ->databases );
95
97
$ this ->assertEquals ('psa ' , $ stats ->version ->internalName );
96
98
$ this ->assertNotEmpty ($ stats ->version ->osName );
97
99
$ this ->assertNotEmpty ($ stats ->version ->osVersion );
100
+ $ this ->assertGreaterThan (0 , $ stats ->other ->uptime );
101
+ $ this ->assertGreaterThan (0 , strlen ($ stats ->other ->cpu ));
102
+ $ this ->assertIsFloat ($ stats ->loadAverage ->load1min );
103
+ $ this ->assertGreaterThan (0 , $ stats ->memory ->total );
104
+ $ this ->assertGreaterThan ($ stats ->memory ->free , $ stats ->memory ->total );
105
+ $ this ->assertIsNumeric ($ stats ->swap ->total );
106
+ $ this ->assertIsArray ($ stats ->diskSpace );
107
+ $ this ->assertGreaterThan (0 , array_pop ($ stats ->diskSpace )->total );
98
108
}
99
109
100
110
public function testGetSiteIsolationConfig ()
You can’t perform that action at this time.
0 commit comments