2021-02-04 09:02:19 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/* Icinga DB Web | (c) 2021 Icinga GmbH | GPLv2 */
|
|
|
|
|
|
|
|
|
|
namespace Icinga\Module\Icingadb\Command\Object;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Submit a passive check result for a host or service
|
|
|
|
|
*/
|
2023-03-01 05:28:18 -05:00
|
|
|
class ProcessCheckResultCommand extends ObjectsCommand
|
2021-02-04 09:02:19 -05:00
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Host up
|
|
|
|
|
*/
|
2025-10-12 16:45:40 -04:00
|
|
|
public const HOST_UP = 0;
|
2021-02-04 09:02:19 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Host down
|
|
|
|
|
*/
|
2025-10-12 16:45:40 -04:00
|
|
|
public const HOST_DOWN = 1;
|
2021-02-04 09:02:19 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Service ok
|
|
|
|
|
*/
|
2025-10-12 16:45:40 -04:00
|
|
|
public const SERVICE_OK = 0;
|
2021-02-04 09:02:19 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Service warning
|
|
|
|
|
*/
|
2025-10-12 16:45:40 -04:00
|
|
|
public const SERVICE_WARNING = 1;
|
2021-02-04 09:02:19 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Service critical
|
|
|
|
|
*/
|
2025-10-12 16:45:40 -04:00
|
|
|
public const SERVICE_CRITICAL = 2;
|
2021-02-04 09:02:19 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Service unknown
|
|
|
|
|
*/
|
2025-10-12 16:45:40 -04:00
|
|
|
public const SERVICE_UNKNOWN = 3;
|
2021-02-04 09:02:19 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Status code of the host or service check result
|
|
|
|
|
*
|
|
|
|
|
* @var int
|
|
|
|
|
*/
|
|
|
|
|
protected $status;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Text output of the host or service check result
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $output;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Optional performance data of the host or service check result
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $performanceData;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the status code of the host or service check result
|
|
|
|
|
*
|
|
|
|
|
* @param int $status
|
|
|
|
|
*
|
|
|
|
|
* @return $this
|
|
|
|
|
*/
|
2021-09-22 04:21:15 -04:00
|
|
|
public function setStatus(int $status): self
|
2021-02-04 09:02:19 -05:00
|
|
|
{
|
2021-09-22 04:21:15 -04:00
|
|
|
$this->status = $status;
|
2021-02-04 09:02:19 -05:00
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the status code of the host or service check result
|
|
|
|
|
*
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
2021-09-22 04:21:15 -04:00
|
|
|
public function getStatus(): int
|
2021-02-04 09:02:19 -05:00
|
|
|
{
|
2021-09-22 04:21:15 -04:00
|
|
|
if ($this->status === null) {
|
|
|
|
|
throw new \LogicException(
|
|
|
|
|
'You are accessing an unset property. Please make sure to set it beforehand.'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-04 09:02:19 -05:00
|
|
|
return $this->status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the text output of the host or service check result
|
|
|
|
|
*
|
|
|
|
|
* @param string $output
|
|
|
|
|
*
|
|
|
|
|
* @return $this
|
|
|
|
|
*/
|
2021-09-22 04:21:15 -04:00
|
|
|
public function setOutput(string $output): self
|
2021-02-04 09:02:19 -05:00
|
|
|
{
|
2021-09-22 04:21:15 -04:00
|
|
|
$this->output = $output;
|
2021-02-04 09:02:19 -05:00
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the text output of the host or service check result
|
|
|
|
|
*
|
2021-09-22 04:21:15 -04:00
|
|
|
* @return ?string
|
2021-02-04 09:02:19 -05:00
|
|
|
*/
|
|
|
|
|
public function getOutput()
|
|
|
|
|
{
|
|
|
|
|
return $this->output;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the performance data of the host or service check result
|
|
|
|
|
*
|
2021-11-04 11:37:58 -04:00
|
|
|
* @param string|null $performanceData
|
2021-02-04 09:02:19 -05:00
|
|
|
*
|
|
|
|
|
* @return $this
|
|
|
|
|
*/
|
2021-11-04 11:37:58 -04:00
|
|
|
public function setPerformanceData(string $performanceData = null): self
|
2021-02-04 09:02:19 -05:00
|
|
|
{
|
2021-09-22 04:21:15 -04:00
|
|
|
$this->performanceData = $performanceData;
|
2021-02-04 09:02:19 -05:00
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the performance data of the host or service check result
|
|
|
|
|
*
|
2021-09-22 04:21:15 -04:00
|
|
|
* @return ?string
|
2021-02-04 09:02:19 -05:00
|
|
|
*/
|
|
|
|
|
public function getPerformanceData()
|
|
|
|
|
{
|
|
|
|
|
return $this->performanceData;
|
|
|
|
|
}
|
|
|
|
|
}
|