IcingaConfig: count apply rules and show them

This commit is contained in:
Thomas Gelf 2016-11-03 13:35:44 +01:00
parent 92bb24b414
commit 4a82bd5b90
4 changed files with 32 additions and 3 deletions

View File

@ -15,6 +15,8 @@ class GeneratedConfigFileTable extends QuickTable
'size' => 'LENGTH(f.content)',
'cnt_object' => 'f.cnt_object',
'cnt_template' => 'f.cnt_template',
'cnt_apply' => 'f.cnt_apply',
'cnt_all' => "f.cnt_object || ' / ' || f.cnt_template || ' / ' || f.cnt_apply",
'checksum' => 'LOWER(HEX(f.checksum))',
'config_checksum' => 'LOWER(HEX(cf.config_checksum))',
);
@ -52,8 +54,12 @@ class GeneratedConfigFileTable extends QuickTable
$view = $this->view();
return array(
'file_path' => $view->translate('File'),
'cnt_all' => $view->translate('Object/Tpl/Apply'),
/*
'cnt_object' => $view->translate('Objects'),
'cnt_template' => $view->translate('Templates'),
'cnt_apply' => $view->translate('Apply rules'),
*/
'size' => $view->translate('Size'),
);
}

View File

@ -85,9 +85,10 @@ function colorize($log, $logLink) {
'deployment_id' => $deployment->id
)
) ?>, <?= sprintf(
$this->translate('%d objects, %d templates'),
$this->translate('%d objects, %d templates, %d apply rules'),
$config->getObjectCount(),
$config->getTemplateCount()
$config->getTemplateCount(),
$config->getApplyCount()
)?>, <?= Format::bytes($config->getSize()) ?></td>
</tr>
<tr>

View File

@ -111,6 +111,15 @@ class IcingaConfig
return $cnt;
}
public function getApplyCount()
{
$cnt = 0;
foreach ($this->getFiles() as $file) {
$cnt += $file->getApplyCount();
}
return $cnt;
}
public function getChecksum()
{
return $this->checksum;
@ -614,6 +623,7 @@ apply Service for (title => params in host.vars["%s"]) {
'content' => 'f.content',
'cnt_object' => 'f.cnt_object',
'cnt_template' => 'f.cnt_template',
'cnt_apply' => 'f.cnt_apply',
)
)->join(
array('f' => 'director_generated_file'),
@ -626,7 +636,8 @@ apply Service for (title => params in host.vars["%s"]) {
$this->files[$row->file_path] = $file
->setContent($row->content)
->setObjectCount($row->cnt_object)
->setTemplateCount($row->cnt_template);
->setTemplateCount($row->cnt_template)
->setApplyCount($row->cnt_apply);
}
return $this;

View File

@ -55,6 +55,11 @@ class IcingaConfigFile
return $this->cntTemplate;
}
public function getApplyCount()
{
return $this->cntApply;
}
public function getSize()
{
return strlen($this->content);
@ -72,6 +77,12 @@ class IcingaConfigFile
return $this;
}
public function setApplyCount($cnt)
{
$this->cntApply = $cnt;
return $this;
}
public function getHexChecksum()
{
return Util::binary2hex($this->getChecksum());