1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
monitoring_result.php
См. документацию.
1
<?php
2
3
interface
CBitrixCloudMonitoring_Access
extends
Iterator, ArrayAccess
4
{
5
// new stuff
6
}
7
8
class
CBitrixCloudMonitoringTest
9
{
10
private
$name =
''
;
11
private
$status =
''
;
12
private
$time = 0;
13
private
$uptime =
''
;
14
private
$result =
''
;
15
25
public
function
__construct
($name, $status, $time, $uptime, $result)
26
{
27
$this->name = $name;
28
$this->status = $status;
29
$this->time = $time;
30
$this->uptime = $uptime;
31
$this->result = $result;
32
}
33
39
public
function
getName
()
40
{
41
return
$this->name
;
42
}
43
49
public
function
getStatus
()
50
{
51
return
$this->status
;
52
}
53
59
public
function
getResult
()
60
{
61
return
$this->result
;
62
}
63
69
public
function
getUptime
()
70
{
71
return
$this->uptime;
72
}
73
79
public
function
getTime
()
80
{
81
return
$this->time
;
82
}
83
90
public
static
function
fromXMLNode
(
CDataXMLNode
$node)
91
{
92
return
new
CBitrixCloudMonitoringTest
(
93
$node->
getAttribute
(
'id'
),
94
$node->
getAttribute
(
'status'
) == 2 ?
CBitrixCloudMonitoringResult::RED_LAMP
:
CBitrixCloudMonitoringResult::GREEN_LAMP
,
95
strtotime($node->
getAttribute
(
'time'
)),
96
$node->
getAttribute
(
'uptime'
),
97
$node->
textContent
()
98
);
99
}
100
}
101
102
class
CBitrixCloudMonitoringDomainResult
implements
CBitrixCloudMonitoring_Access
103
{
105
private
$name =
''
;
107
private
$tests =
/*.(array[int]CBitrixCloudMonitoringTest.*/
108
[];
109
115
public
function
getName
()
116
{
117
return
$this->name
;
118
}
119
125
public
function
getStatus
()
126
{
127
/* @var CBitrixCloudMonitoringTest $testResult */
128
foreach
($this->tests as $testResult)
129
{
130
if
($testResult->getStatus() ===
CBitrixCloudMonitoringResult::RED_LAMP
)
131
{
132
return
CBitrixCloudMonitoringResult::RED_LAMP
;
133
}
134
}
135
return
CBitrixCloudMonitoringResult::GREEN_LAMP
;
136
}
137
145
public
function
__construct
($name,
array
$tests)
146
{
147
$this->name = $name;
148
$this->
setTests
($tests);
149
}
150
157
public
function
getTestByName
($testName)
158
{
159
return
$this->tests[$testName];
160
}
161
167
public
function
getTests
()
168
{
169
return
$this->tests;
170
}
171
178
public
function
setTests
(
array
$tests)
179
{
180
foreach
($tests as $test)
181
{
182
if
(
183
is_object($test)
184
&& $test instanceof
CBitrixCloudMonitoringTest
185
)
186
{
187
$this->tests[$test->getName()] = $test;
188
}
189
}
190
return
$this;
191
}
192
193
public
function
saveToOptions
(
CBitrixCloudOption
$option
)
194
{
195
$tests = [];
196
/* @var CBitrixCloudMonitoringTest $testResult */
197
foreach
($this->tests as $testName => $testResult)
198
{
199
$tests[$testName] = serialize([
200
'status'
=> $testResult->getStatus(),
201
'time'
=> $testResult->getTime(),
202
'uptime'
=> $testResult->getUptime(),
203
'result'
=> $testResult->getResult(),
204
]);
205
}
206
$option
->setArrayValue($tests);
207
}
208
209
public
static
function
loadFromOptions
($name,
CBitrixCloudOption
$option
)
210
{
211
$tests = [];
212
foreach
(
$option
->getArrayValue() as $testName => $testResult)
213
{
214
$testResult = unserialize($testResult, [
'allowed_classes'
=>
false
]);
215
if
(is_array($testResult))
216
{
217
$test =
new
CBitrixCloudMonitoringTest
(
218
$testName,
219
$testResult[
'status'
],
220
$testResult[
'time'
],
221
$testResult[
'uptime'
],
222
$testResult[
'result'
]
223
);
224
$tests[$test->getName()] = $test;
225
}
226
}
227
return
new
CBitrixCloudMonitoringDomainResult
($name, $tests);
228
}
229
236
public
static
function
fromXMLNode
(
CDataXMLNode
$node)
237
{
238
$name = $node->
getAttribute
(
'name'
);
239
$tests = [];
240
foreach
($node->
children
() as $nodeTest)
241
{
242
$tests[] =
CBitrixCloudMonitoringTest::fromXMLNode
($nodeTest);
243
}
244
return
new
CBitrixCloudMonitoringDomainResult
($name, $tests);
245
}
246
247
public
function
rewind
()
248
{
249
reset($this->tests);
250
}
251
252
public
function
current
()
253
{
254
return
current
($this->tests);
255
}
256
257
public
function
key
()
258
{
259
return
key
($this->tests);
260
}
261
262
public
function
next
()
263
{
264
next
($this->tests);
265
}
266
267
public
function
valid
()
268
{
269
return
key
($this->tests) !==
null
;
270
}
271
272
public
function
offsetSet
($offset, $value)
273
{
274
if
(is_null($offset))
275
{
276
$this->tests[] = $value;
277
}
278
else
279
{
280
$this->tests[$offset] = $value;
281
}
282
}
283
284
public
function
offsetExists
($offset)
285
{
286
return
isset($this->tests[$offset]);
287
}
288
289
public
function
offsetUnset
($offset)
290
{
291
unset($this->tests[$offset]);
292
}
293
294
public
function
offsetGet
($offset)
295
{
296
return
$this->tests[$offset] ??
null
;
297
}
298
}
299
300
class
CBitrixCloudMonitoringResult
implements
CBitrixCloudMonitoring_Access
301
{
302
const
GREEN_LAMP
=
'green'
;
303
const
RED_LAMP
=
'red'
;
304
305
private
$domains =
/*.(array[string]CBitrixCloudMonitoringDomainResult).*/
306
[];
307
314
public
function
addDomainResult
(
CBitrixCloudMonitoringDomainResult
$domainResult)
315
{
316
$this->domains[$domainResult->
getName
()] = $domainResult;
317
return
$this;
318
}
319
326
public
function
getResultByDomainName
($domainName)
327
{
328
return
$this->domains[$domainName];
329
}
330
336
public
function
getStatus
()
337
{
338
foreach
($this->domains as $domainResult)
339
{
340
if
($domainResult->getStatus() ===
CBitrixCloudMonitoringResult::RED_LAMP
)
341
{
342
return
CBitrixCloudMonitoringResult::RED_LAMP
;
343
}
344
}
345
return
CBitrixCloudMonitoringResult::GREEN_LAMP
;
346
}
347
348
public
static
function
isExpired
()
349
{
350
$time
=
CBitrixCloudOption::getOption
(
'monitoring_expire_time'
)->getIntegerValue();
351
return
(
$time
< time());
352
}
353
354
public
static
function
getExpirationTime
()
355
{
356
return
CBitrixCloudOption::getOption
(
'monitoring_expire_time'
)->getIntegerValue();
357
}
358
359
public
static
function
setExpirationTime
(
$time
)
360
{
361
$time
= intval(
$time
);
362
CBitrixCloudOption::getOption
(
'monitoring_expire_time'
)->setStringValue(
$time
);
363
return
$time
;
364
}
365
366
public
static
function
loadFromOptions
()
367
{
368
$domains =
new
CBitrixCloudMonitoringResult
;
369
foreach
(
CBitrixCloudOption::getOption
(
'monitoring_result'
)->getArrayValue() as
$i
=> $domainName)
370
{
371
$domains->addDomainResult(
CBitrixCloudMonitoringDomainResult::loadFromOptions
(
372
$domainName,
373
CBitrixCloudOption::getOption
(
"monitoring_result_"
.
$i
)
374
));
375
}
376
return
$domains;
377
}
378
379
public
function
saveToOptions
()
380
{
381
$domainNames = array_keys($this->domains);
382
CBitrixCloudOption::getOption
(
'monitoring_result'
)->setArrayValue($domainNames);
383
foreach
($domainNames as
$i
=> $domainName)
384
{
385
$this->domains[$domainName]->saveToOptions(
386
CBitrixCloudOption::getOption
(
"monitoring_result_"
.
$i
)
387
);
388
}
389
}
390
397
public
static
function
fromXMLNode
(
CDataXMLNode
$node)
398
{
399
$domains =
new
CBitrixCloudMonitoringResult
;
400
if
(is_array($node->
children
()))
401
{
402
foreach
($node->
children
() as $sub_node)
403
{
404
$domains->addDomainResult(
CBitrixCloudMonitoringDomainResult::fromXMLNode
($sub_node));
405
}
406
}
407
return
$domains;
408
}
409
410
public
function
rewind
()
411
{
412
reset($this->domains);
413
}
414
415
public
function
current
()
416
{
417
return
current
($this->domains);
418
}
419
420
public
function
key
()
421
{
422
return
key
($this->domains);
423
}
424
425
public
function
next
()
426
{
427
next
($this->domains);
428
}
429
430
public
function
valid
()
431
{
432
return
key
($this->domains) !==
null
;
433
}
434
435
public
function
offsetSet
($offset, $value)
436
{
437
if
(is_null($offset))
438
{
439
$this->domains[] = $value;
440
}
441
else
442
{
443
$this->domains[$offset] = $value;
444
}
445
}
446
447
public
function
offsetExists
($offset)
448
{
449
return
isset($this->domains[$offset]);
450
}
451
452
public
function
offsetUnset
($offset)
453
{
454
unset($this->domains[$offset]);
455
}
456
457
public
function
offsetGet
($offset)
458
{
459
return
$this->domains[$offset] ??
null
;
460
}
461
}
CBitrixCloudMonitoringDomainResult
Определения
monitoring_result.php:103
CBitrixCloudMonitoringDomainResult\setTests
setTests(array $tests)
Определения
monitoring_result.php:178
CBitrixCloudMonitoringDomainResult\offsetUnset
offsetUnset($offset)
Определения
monitoring_result.php:289
CBitrixCloudMonitoringDomainResult\offsetExists
offsetExists($offset)
Определения
monitoring_result.php:284
CBitrixCloudMonitoringDomainResult\getName
getName()
Определения
monitoring_result.php:115
CBitrixCloudMonitoringDomainResult\offsetGet
offsetGet($offset)
Определения
monitoring_result.php:294
CBitrixCloudMonitoringDomainResult\key
key()
Определения
monitoring_result.php:257
CBitrixCloudMonitoringDomainResult\getTests
getTests()
Определения
monitoring_result.php:167
CBitrixCloudMonitoringDomainResult\loadFromOptions
static loadFromOptions($name, CBitrixCloudOption $option)
Определения
monitoring_result.php:209
CBitrixCloudMonitoringDomainResult\fromXMLNode
static fromXMLNode(CDataXMLNode $node)
Определения
monitoring_result.php:236
CBitrixCloudMonitoringDomainResult\getStatus
getStatus()
Определения
monitoring_result.php:125
CBitrixCloudMonitoringDomainResult\valid
valid()
Определения
monitoring_result.php:267
CBitrixCloudMonitoringDomainResult\offsetSet
offsetSet($offset, $value)
Определения
monitoring_result.php:272
CBitrixCloudMonitoringDomainResult\next
next()
Определения
monitoring_result.php:262
CBitrixCloudMonitoringDomainResult\rewind
rewind()
Определения
monitoring_result.php:247
CBitrixCloudMonitoringDomainResult\getTestByName
getTestByName($testName)
Определения
monitoring_result.php:157
CBitrixCloudMonitoringDomainResult\current
current()
Определения
monitoring_result.php:252
CBitrixCloudMonitoringDomainResult\__construct
__construct($name, array $tests)
Определения
monitoring_result.php:145
CBitrixCloudMonitoringDomainResult\saveToOptions
saveToOptions(CBitrixCloudOption $option)
Определения
monitoring_result.php:193
CBitrixCloudMonitoringResult
Определения
monitoring_result.php:301
CBitrixCloudMonitoringResult\offsetUnset
offsetUnset($offset)
Определения
monitoring_result.php:452
CBitrixCloudMonitoringResult\offsetExists
offsetExists($offset)
Определения
monitoring_result.php:447
CBitrixCloudMonitoringResult\isExpired
static isExpired()
Определения
monitoring_result.php:348
CBitrixCloudMonitoringResult\getResultByDomainName
getResultByDomainName($domainName)
Определения
monitoring_result.php:326
CBitrixCloudMonitoringResult\getExpirationTime
static getExpirationTime()
Определения
monitoring_result.php:354
CBitrixCloudMonitoringResult\RED_LAMP
const RED_LAMP
Определения
monitoring_result.php:303
CBitrixCloudMonitoringResult\offsetGet
offsetGet($offset)
Определения
monitoring_result.php:457
CBitrixCloudMonitoringResult\addDomainResult
addDomainResult(CBitrixCloudMonitoringDomainResult $domainResult)
Определения
monitoring_result.php:314
CBitrixCloudMonitoringResult\key
key()
Определения
monitoring_result.php:420
CBitrixCloudMonitoringResult\fromXMLNode
static fromXMLNode(CDataXMLNode $node)
Определения
monitoring_result.php:397
CBitrixCloudMonitoringResult\getStatus
getStatus()
Определения
monitoring_result.php:336
CBitrixCloudMonitoringResult\loadFromOptions
static loadFromOptions()
Определения
monitoring_result.php:366
CBitrixCloudMonitoringResult\GREEN_LAMP
const GREEN_LAMP
Определения
monitoring_result.php:302
CBitrixCloudMonitoringResult\valid
valid()
Определения
monitoring_result.php:430
CBitrixCloudMonitoringResult\setExpirationTime
static setExpirationTime($time)
Определения
monitoring_result.php:359
CBitrixCloudMonitoringResult\offsetSet
offsetSet($offset, $value)
Определения
monitoring_result.php:435
CBitrixCloudMonitoringResult\next
next()
Определения
monitoring_result.php:425
CBitrixCloudMonitoringResult\saveToOptions
saveToOptions()
Определения
monitoring_result.php:379
CBitrixCloudMonitoringResult\rewind
rewind()
Определения
monitoring_result.php:410
CBitrixCloudMonitoringResult\current
current()
Определения
monitoring_result.php:415
CBitrixCloudMonitoringTest
Определения
monitoring_result.php:9
CBitrixCloudMonitoringTest\getName
getName()
Определения
monitoring_result.php:39
CBitrixCloudMonitoringTest\getTime
getTime()
Определения
monitoring_result.php:79
CBitrixCloudMonitoringTest\getUptime
getUptime()
Определения
monitoring_result.php:69
CBitrixCloudMonitoringTest\fromXMLNode
static fromXMLNode(CDataXMLNode $node)
Определения
monitoring_result.php:90
CBitrixCloudMonitoringTest\__construct
__construct($name, $status, $time, $uptime, $result)
Определения
monitoring_result.php:25
CBitrixCloudMonitoringTest\getStatus
getStatus()
Определения
monitoring_result.php:49
CBitrixCloudMonitoringTest\getResult
getResult()
Определения
monitoring_result.php:59
CBitrixCloudOption
Определения
option.php:3
CBitrixCloudOption\getOption
static getOption($name)
Определения
option.php:25
CDataXMLNode
Определения
xml.php:12
CDataXMLNode\textContent
textContent()
Определения
xml.php:31
CDataXMLNode\children
children()
Определения
xml.php:26
CDataXMLNode\getAttribute
getAttribute($attribute)
Определения
xml.php:36
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
CBitrixCloudMonitoring_Access
Определения
monitoring_result.php:4
$status
$status
Определения
session.php:10
$name
$name
Определения
menu_edit.php:35
$time
$time
Определения
payment.php:61
$i
$i
Определения
factura.php:643
$option
$option
Определения
options.php:1711
bitrix
modules
bitrixcloud
classes
general
monitoring_result.php
Создано системой
1.14.0