1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
monitoring_result.php
См. документацию.
1<?php
2
3interface CBitrixCloudMonitoring_Access extends Iterator, ArrayAccess
4{
5 // new stuff
6}
7
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 {
93 $node->getAttribute('id'),
95 strtotime($node->getAttribute('time')),
96 $node->getAttribute('uptime'),
97 $node->textContent()
98 );
99 }
100}
101
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 {
133 }
134 }
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
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
301{
302 const GREEN_LAMP = 'green';
303 const RED_LAMP = 'red';
304
305 private $domains = /*.(array[string]CBitrixCloudMonitoringDomainResult).*/
306 [];
307
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 {
343 }
344 }
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 {
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}
static loadFromOptions($name, CBitrixCloudOption $option)
Определения monitoring_result.php:209
static fromXMLNode(CDataXMLNode $node)
Определения monitoring_result.php:236
offsetSet($offset, $value)
Определения monitoring_result.php:272
__construct($name, array $tests)
Определения monitoring_result.php:145
saveToOptions(CBitrixCloudOption $option)
Определения monitoring_result.php:193
offsetExists($offset)
Определения monitoring_result.php:447
getResultByDomainName($domainName)
Определения monitoring_result.php:326
static getExpirationTime()
Определения monitoring_result.php:354
addDomainResult(CBitrixCloudMonitoringDomainResult $domainResult)
Определения monitoring_result.php:314
static fromXMLNode(CDataXMLNode $node)
Определения monitoring_result.php:397
static loadFromOptions()
Определения monitoring_result.php:366
static setExpirationTime($time)
Определения monitoring_result.php:359
offsetSet($offset, $value)
Определения monitoring_result.php:435
static fromXMLNode(CDataXMLNode $node)
Определения monitoring_result.php:90
__construct($name, $status, $time, $uptime, $result)
Определения monitoring_result.php:25
Определения option.php:3
static getOption($name)
Определения option.php:25
Определения xml.php:12
textContent()
Определения xml.php:31
children()
Определения xml.php:26
getAttribute($attribute)
Определения xml.php:36
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$status
Определения session.php:10
$name
Определения menu_edit.php:35
$time
Определения payment.php:61
$i
Определения factura.php:643
$option
Определения options.php:1711