|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author stev leibelt <[email protected]> |
|
4
|
|
|
* @since 2017-04-04 |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace Net\Bazzline\Component\ApacheServerStatusParser\DomainModel; |
|
8
|
|
|
|
|
9
|
|
|
class Statistic implements ReduceDataAbleToArrayInterface |
|
10
|
|
|
{ |
|
11
|
|
|
const REDUCED_DATA_TO_ARRAY_KEY_B_PER_SECOND = 'b_per_request'; |
|
12
|
|
|
const REDUCED_DATA_TO_ARRAY_KEY_CPU_LOAD = 'cpu_load'; |
|
13
|
|
|
const REDUCED_DATA_TO_ARRAY_KEY_CPU_USAGE = 'cpu_usage'; |
|
14
|
|
|
const REDUCED_DATA_TO_ARRAY_KEY_CURRENT_TIMESTAMP = 'current_timestamp'; |
|
15
|
|
|
const REDUCED_DATA_TO_ARRAY_KEY_IDLE_WORKERS = 'idle_workers'; |
|
16
|
|
|
const REDUCED_DATA_TO_ARRAY_KEY_KB_PER_REQUEST = 'kb_per_request'; |
|
17
|
|
|
const REDUCED_DATA_TO_ARRAY_KEY_PARENT_SERVER_CONFIGURATION_GENERATION = 'parent_server_configuration_generation'; |
|
18
|
|
|
const REDUCED_DATA_TO_ARRAY_KEY_PARENT_SERVER_MPM_GENERATION = 'parent_server_mpm_generation'; |
|
19
|
|
|
const REDUCED_DATA_TO_ARRAY_KEY_REQUESTS_CURRENTLY_BEING_PROCESSED = 'requests_currently_being_processed'; |
|
20
|
|
|
const REDUCED_DATA_TO_ARRAY_KEY_REQUESTS_PER_SECOND = 'requests_per_second'; |
|
21
|
|
|
const REDUCED_DATA_TO_ARRAY_KEY_RESTART_TIMESTAMP = 'restart_timestamp'; |
|
22
|
|
|
const REDUCED_DATA_TO_ARRAY_KEY_SERVER_LOAD = 'server_load'; |
|
23
|
|
|
const REDUCED_DATA_TO_ARRAY_KEY_SERVER_UP_TIME = 'server_up_time'; |
|
24
|
|
|
const REDUCED_DATA_TO_ARRAY_KEY_TOTAL_ACCESSES = 'total_accesses'; |
|
25
|
|
|
const REDUCED_DATA_TO_ARRAY_KEY_TOTAL_TRAFFIC = 'total_traffic'; |
|
26
|
|
|
|
|
27
|
|
|
/** @var int */ |
|
28
|
|
|
private $bPerSecond; |
|
29
|
|
|
|
|
30
|
|
|
/** @var float */ |
|
31
|
|
|
private $cpuLoad; |
|
32
|
|
|
|
|
33
|
|
|
/** @var string */ |
|
34
|
|
|
private $cpuUsage; |
|
35
|
|
|
|
|
36
|
|
|
/** @var int */ |
|
37
|
|
|
private $currentTimestamp; |
|
38
|
|
|
|
|
39
|
|
|
/** @var int */ |
|
40
|
|
|
private $idleWorkers; |
|
41
|
|
|
|
|
42
|
|
|
/** @var float */ |
|
43
|
|
|
private $kbPerRequest; |
|
44
|
|
|
|
|
45
|
|
|
/** @var int */ |
|
46
|
|
|
private $parentServerConfigurationGeneration; |
|
47
|
|
|
|
|
48
|
|
|
/** @var int */ |
|
49
|
|
|
private $parentServerMpmGeneration; |
|
50
|
|
|
|
|
51
|
|
|
/** @var int */ |
|
52
|
|
|
private $requestCurrentlyBeingProcessed; |
|
53
|
|
|
|
|
54
|
|
|
/** @var int */ |
|
55
|
|
|
private $requestPerSecond; |
|
56
|
|
|
|
|
57
|
|
|
/** @var int */ |
|
58
|
|
|
private $restartTimestamp; |
|
59
|
|
|
|
|
60
|
|
|
/** @var string */ |
|
61
|
|
|
private $serverLoad; |
|
62
|
|
|
|
|
63
|
|
|
/** @var string */ |
|
64
|
|
|
private $serverUpTime; |
|
65
|
|
|
|
|
66
|
|
|
/** @var int */ |
|
67
|
|
|
private $totalAccess; |
|
68
|
|
|
|
|
69
|
|
|
/** @var string */ |
|
70
|
|
|
private $totalTraffic; |
|
71
|
|
|
|
|
72
|
|
|
public function __construct( |
|
73
|
|
|
$bPerSecond, |
|
74
|
|
|
$cpuLoad, |
|
75
|
|
|
$cpuUsage, |
|
76
|
|
|
$currentTimestamp, |
|
77
|
|
|
$idleWorkers, |
|
78
|
|
|
$kbPerRequest, |
|
79
|
|
|
$parentServerConfigurationGeneration, |
|
80
|
|
|
$parentServerMpmGeneration, |
|
81
|
|
|
$requestCurrentlyBeingProcessed, |
|
82
|
|
|
$requestPerSecond, |
|
83
|
|
|
$restartTimestamp, |
|
84
|
|
|
$serverLoad, |
|
85
|
|
|
$serverUpTime, |
|
86
|
|
|
$totalAccess, |
|
87
|
|
|
$totalTraffic |
|
88
|
|
|
) { |
|
89
|
|
|
$this->bPerSecond = $bPerSecond; |
|
90
|
|
|
$this->cpuLoad = $cpuLoad; |
|
91
|
|
|
$this->cpuUsage = $cpuUsage; |
|
92
|
|
|
$this->currentTimestamp = $currentTimestamp; |
|
93
|
|
|
$this->idleWorkers = $idleWorkers; |
|
94
|
|
|
$this->kbPerRequest = $kbPerRequest; |
|
95
|
|
|
$this->parentServerConfigurationGeneration = $parentServerConfigurationGeneration; |
|
96
|
|
|
$this->parentServerMpmGeneration = $parentServerMpmGeneration; |
|
97
|
|
|
$this->requestCurrentlyBeingProcessed = $requestCurrentlyBeingProcessed; |
|
98
|
|
|
$this->requestPerSecond = $requestPerSecond; |
|
99
|
|
|
$this->restartTimestamp = $restartTimestamp; |
|
100
|
|
|
$this->serverLoad = $serverLoad; |
|
101
|
|
|
$this->serverUpTime = $serverUpTime; |
|
102
|
|
|
$this->totalAccess = $totalAccess; |
|
103
|
|
|
$this->totalTraffic = $totalTraffic; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @return int |
|
108
|
|
|
*/ |
|
109
|
|
|
public function bPerSecond() |
|
110
|
|
|
{ |
|
111
|
|
|
return $this->bPerSecond; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @return float |
|
116
|
|
|
*/ |
|
117
|
|
|
public function cpuLoad() |
|
118
|
|
|
{ |
|
119
|
|
|
return $this->cpuLoad; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @return string |
|
124
|
|
|
*/ |
|
125
|
|
|
public function cpuUsage() |
|
126
|
|
|
{ |
|
127
|
|
|
return $this->cpuUsage; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @return int |
|
132
|
|
|
*/ |
|
133
|
|
|
public function currentTimestamp() |
|
134
|
|
|
{ |
|
135
|
|
|
return $this->currentTimestamp; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* @return int |
|
140
|
|
|
*/ |
|
141
|
|
|
public function idleWorkers() |
|
142
|
|
|
{ |
|
143
|
|
|
return $this->idleWorkers; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* @return float |
|
148
|
|
|
*/ |
|
149
|
|
|
public function kbPerRequest() |
|
150
|
|
|
{ |
|
151
|
|
|
return $this->kbPerRequest; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* @return int |
|
156
|
|
|
*/ |
|
157
|
|
|
public function parentServerConfigurationGeneration() |
|
158
|
|
|
{ |
|
159
|
|
|
return $this->parentServerConfigurationGeneration; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* @return int |
|
164
|
|
|
*/ |
|
165
|
|
|
public function parentServerMpmGeneration() |
|
166
|
|
|
{ |
|
167
|
|
|
return $this->parentServerMpmGeneration; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* @return int |
|
172
|
|
|
*/ |
|
173
|
|
|
public function requestCurrentlyBeingProcessed() |
|
174
|
|
|
{ |
|
175
|
|
|
return $this->requestCurrentlyBeingProcessed; |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* @return int |
|
180
|
|
|
*/ |
|
181
|
|
|
public function requestPerSecond() |
|
182
|
|
|
{ |
|
183
|
|
|
return $this->requestPerSecond; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* @return int |
|
188
|
|
|
*/ |
|
189
|
|
|
public function restartTimestamp() |
|
190
|
|
|
{ |
|
191
|
|
|
return $this->restartTimestamp; |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
/** |
|
195
|
|
|
* @return string |
|
196
|
|
|
*/ |
|
197
|
|
|
public function serverLoad() |
|
198
|
|
|
{ |
|
199
|
|
|
return $this->serverLoad; |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
/** |
|
203
|
|
|
* @return string |
|
204
|
|
|
*/ |
|
205
|
|
|
public function serverUpTime() |
|
206
|
|
|
{ |
|
207
|
|
|
return $this->serverUpTime; |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* @return int |
|
212
|
|
|
*/ |
|
213
|
|
|
public function totalAccess() |
|
214
|
|
|
{ |
|
215
|
|
|
return $this->totalAccess; |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
/** |
|
219
|
|
|
* @return string |
|
220
|
|
|
*/ |
|
221
|
|
|
public function totalTraffic() |
|
222
|
|
|
{ |
|
223
|
|
|
return $this->totalTraffic; |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
/** |
|
227
|
|
|
* @return array |
|
228
|
|
|
*/ |
|
229
|
|
|
public function reduceDataToArray() |
|
230
|
|
|
{ |
|
231
|
|
|
return [ |
|
232
|
|
|
self::REDUCED_DATA_TO_ARRAY_KEY_B_PER_SECOND => $this->bPerSecond, |
|
233
|
|
|
self::REDUCED_DATA_TO_ARRAY_KEY_CPU_LOAD => $this->cpuLoad, |
|
234
|
|
|
self::REDUCED_DATA_TO_ARRAY_KEY_CPU_USAGE => $this->cpuUsage, |
|
235
|
|
|
self::REDUCED_DATA_TO_ARRAY_KEY_CURRENT_TIMESTAMP => $this->currentTimestamp, |
|
236
|
|
|
self::REDUCED_DATA_TO_ARRAY_KEY_IDLE_WORKERS => $this->idleWorkers, |
|
237
|
|
|
self::REDUCED_DATA_TO_ARRAY_KEY_KB_PER_REQUEST => $this->kbPerRequest, |
|
238
|
|
|
self::REDUCED_DATA_TO_ARRAY_KEY_PARENT_SERVER_CONFIGURATION_GENERATION => $this->parentServerConfigurationGeneration, |
|
239
|
|
|
self::REDUCED_DATA_TO_ARRAY_KEY_PARENT_SERVER_MPM_GENERATION => $this->parentServerMpmGeneration, |
|
240
|
|
|
self::REDUCED_DATA_TO_ARRAY_KEY_REQUESTS_CURRENTLY_BEING_PROCESSED => $this->requestCurrentlyBeingProcessed, |
|
241
|
|
|
self::REDUCED_DATA_TO_ARRAY_KEY_REQUESTS_PER_SECOND => $this->requestPerSecond, |
|
242
|
|
|
self::REDUCED_DATA_TO_ARRAY_KEY_RESTART_TIMESTAMP => $this->restartTimestamp, |
|
243
|
|
|
self::REDUCED_DATA_TO_ARRAY_KEY_SERVER_LOAD => $this->serverLoad, |
|
244
|
|
|
self::REDUCED_DATA_TO_ARRAY_KEY_SERVER_UP_TIME => $this->serverUpTime, |
|
245
|
|
|
self::REDUCED_DATA_TO_ARRAY_KEY_TOTAL_ACCESSES => $this->totalAccess, |
|
246
|
|
|
self::REDUCED_DATA_TO_ARRAY_KEY_TOTAL_TRAFFIC => $this->totalTraffic |
|
247
|
|
|
]; |
|
248
|
|
|
} |
|
249
|
|
|
} |
|
250
|
|
|
|