Add MonitoringBackend::isIcinga2()

This function is for the many places where we have to distinguish between Icinga 1.x and Icinga 2.x.

refs #11100
This commit is contained in:
Eric Lippmann 2016-02-25 17:45:51 +01:00
parent 1bbb7a3118
commit 47b3019940
1 changed files with 18 additions and 0 deletions

View File

@ -341,4 +341,22 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface
{
return $this->select()->from('programstatus', array('program_version'))->fetchOne();
}
/**
* Get whether the backend is Icinga 2
*
* @param string $programVersion
*
* @return bool
*/
public function isIcinga2($programVersion = null)
{
if ($programVersion === null) {
$programVersion = $this->select()->from('programstatus', array('program_version'))->fetchOne();
}
return (bool) preg_match(
'/^[vr]2\.\d+\.\d+.*$/',
$programVersion
);
}
}