mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-09-26 03:09:11 +02:00
CoreApi: add checkServiceAndWaitForResult()
Will be moved to icingadb soon, committing this to clean up my stash
This commit is contained in:
parent
b5cdd9de4d
commit
cde328eeed
@ -180,6 +180,40 @@ class CoreApi implements DeploymentApiInterface
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function checkServiceAndWaitForResult($host, $service, $timeout = 10)
|
||||||
|
{
|
||||||
|
$now = microtime(true);
|
||||||
|
$this->checkServiceNow($host, $service);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
$object = $this->getObject("$host!$service", 'services');
|
||||||
|
if (isset($object->attrs->last_check_result)) {
|
||||||
|
$res = $object->attrs->last_check_result;
|
||||||
|
if ($res->execution_start > $now) {
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// no check result available
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// Unable to fetch the requested object
|
||||||
|
throw new IcingaException(
|
||||||
|
'Unable to fetch the requested service "%s" on "%s"',
|
||||||
|
$service,
|
||||||
|
$host
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (microtime(true) > ($now + $timeout)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
usleep(150000);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public function getServiceOutput($host, $service)
|
public function getServiceOutput($host, $service)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user