mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-25 23:04:53 +02:00
IcingaConfig: provide helper method for activity...
...related configs, use in deployment job
This commit is contained in:
parent
f288ddaf95
commit
172bdd6f6b
@ -7,6 +7,7 @@ use Icinga\Application\Hook;
|
|||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Exception\IcingaException;
|
use Icinga\Exception\IcingaException;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
|
use Icinga\Module\Director\Db\Cache\PrefetchCache;
|
||||||
use Icinga\Module\Director\Db;
|
use Icinga\Module\Director\Db;
|
||||||
use Icinga\Module\Director\Util;
|
use Icinga\Module\Director\Util;
|
||||||
use Icinga\Module\Director\Objects\IcingaHost;
|
use Icinga\Module\Director\Objects\IcingaHost;
|
||||||
@ -164,6 +165,24 @@ class IcingaConfig
|
|||||||
return self::load($db->fetchOne($query), $connection);
|
return self::load($db->fetchOne($query), $connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function existsForActivityChecksum($checksum, Db $connection)
|
||||||
|
{
|
||||||
|
$db = $connection->getDbAdapter();
|
||||||
|
$query = $db->select()->from(
|
||||||
|
array('c' => self::$table),
|
||||||
|
array('checksum' => $connection->dbHexFunc('c.checksum'))
|
||||||
|
)->join(
|
||||||
|
array('l' => 'director_activity_log'),
|
||||||
|
'l.checksum = c.last_activity_checksum',
|
||||||
|
array()
|
||||||
|
)->where(
|
||||||
|
'last_activity_checksum = ?',
|
||||||
|
$connection->quoteBinary(Util::hex2binary($checksum))
|
||||||
|
)->order('l.id DESC')->limit(1);
|
||||||
|
|
||||||
|
return $db->fetchOne($query) === $checksum;
|
||||||
|
}
|
||||||
|
|
||||||
public static function generate(Db $connection)
|
public static function generate(Db $connection)
|
||||||
{
|
{
|
||||||
$config = new static($connection);
|
$config = new static($connection);
|
||||||
@ -348,6 +367,8 @@ class IcingaConfig
|
|||||||
|
|
||||||
protected function generateFromDb()
|
protected function generateFromDb()
|
||||||
{
|
{
|
||||||
|
PrefetchCache::initialize($this->connection);
|
||||||
|
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
|
|
||||||
// Raise limits. TODO: do this in a failsafe way, and only if necessary
|
// Raise limits. TODO: do this in a failsafe way, and only if necessary
|
||||||
@ -380,6 +401,7 @@ class IcingaConfig
|
|||||||
$this->configFile('zones.d/director-global/commands')
|
$this->configFile('zones.d/director-global/commands')
|
||||||
->prepend("library \"methods\"\n\n");
|
->prepend("library \"methods\"\n\n");
|
||||||
|
|
||||||
|
PrefetchCache::forget();
|
||||||
$this->generationTime = (int) ((microtime(true) - $start) * 1000);
|
$this->generationTime = (int) ((microtime(true) - $start) * 1000);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -65,7 +65,7 @@ class ConfigJob extends JobHook
|
|||||||
{
|
{
|
||||||
$db = $this->db();
|
$db = $this->db();
|
||||||
|
|
||||||
return IcingaConfig::exists(
|
return IcingaConfig::existsForActivityChecksum(
|
||||||
Util::binary2hex(DirectorActivityLog::loadLatest($db)->checksum),
|
Util::binary2hex(DirectorActivityLog::loadLatest($db)->checksum),
|
||||||
$db
|
$db
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user