mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -04:00
Keep compatibility with Icinga DB v5
This commit is contained in:
parent
945eb5f9ae
commit
ffd51260d7
8 changed files with 83 additions and 24 deletions
|
|
@ -8,6 +8,7 @@ use ArrayIterator;
|
|||
use Icinga\Exception\NotFoundError;
|
||||
use Icinga\Module\Icingadb\Command\Object\GetObjectCommand;
|
||||
use Icinga\Module\Icingadb\Command\Transport\CommandTransport;
|
||||
use Icinga\Module\Icingadb\Common\Backend;
|
||||
use Icinga\Module\Icingadb\Common\CommandActions;
|
||||
use Icinga\Module\Icingadb\Common\Links;
|
||||
use Icinga\Module\Icingadb\Common\ServiceLinks;
|
||||
|
|
@ -39,7 +40,6 @@ class ServiceController extends Controller
|
|||
$hostName = $this->params->getRequired('host.name');
|
||||
|
||||
$query = Service::on($this->getDb())
|
||||
->withColumns(['has_problematic_parent'])
|
||||
->with([
|
||||
'state',
|
||||
'icon_image',
|
||||
|
|
@ -54,6 +54,10 @@ class ServiceController extends Controller
|
|||
Filter::equal('host.name', $hostName)
|
||||
));
|
||||
|
||||
if (Backend::getDbSchemaVersion() >= 6) {
|
||||
$query->withColumns(['has_problematic_parent']);
|
||||
}
|
||||
|
||||
$this->applyRestrictions($query);
|
||||
|
||||
/** @var Service $service */
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
namespace Icinga\Module\Icingadb\Model;
|
||||
|
||||
use Icinga\Module\Icingadb\Common\Auth;
|
||||
use Icinga\Module\Icingadb\Common\Backend;
|
||||
use Icinga\Module\Icingadb\Model\Behavior\BoolCast;
|
||||
use Icinga\Module\Icingadb\Model\Behavior\ReRoute;
|
||||
use ipl\Orm\Behavior\Binary;
|
||||
|
|
@ -74,7 +75,7 @@ class Host extends Model
|
|||
|
||||
public function getColumns()
|
||||
{
|
||||
return [
|
||||
$columns = [
|
||||
'environment_id',
|
||||
'name_checksum',
|
||||
'properties_checksum',
|
||||
|
|
@ -112,14 +113,19 @@ class Host extends Model
|
|||
'zone_name',
|
||||
'zone_id',
|
||||
'command_endpoint_name',
|
||||
'command_endpoint_id',
|
||||
'affected_children'
|
||||
'command_endpoint_id'
|
||||
];
|
||||
|
||||
if (Backend::getDbSchemaVersion() >= 6) {
|
||||
$columns[] = 'affected_children';
|
||||
}
|
||||
|
||||
return $columns;
|
||||
}
|
||||
|
||||
public function getColumnDefinitions()
|
||||
{
|
||||
return [
|
||||
$columns = [
|
||||
'environment_id' => t('Environment Id'),
|
||||
'name_checksum' => t('Host Name Checksum'),
|
||||
'properties_checksum' => t('Host Properties Checksum'),
|
||||
|
|
@ -157,9 +163,14 @@ class Host extends Model
|
|||
'zone_name' => t('Zone Name'),
|
||||
'zone_id' => t('Zone Id'),
|
||||
'command_endpoint_name' => t('Endpoint Name'),
|
||||
'command_endpoint_id' => t('Endpoint Id'),
|
||||
'affected_children' => t('Affected Children'),
|
||||
'command_endpoint_id' => t('Endpoint Id')
|
||||
];
|
||||
|
||||
if (Backend::getDbSchemaVersion() >= 6) {
|
||||
$columns['affected_children'] = t('Affected Children');
|
||||
}
|
||||
|
||||
return $columns;
|
||||
}
|
||||
|
||||
public function getSearchColumns()
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
namespace Icinga\Module\Icingadb\Model;
|
||||
|
||||
use Icinga\Module\Icingadb\Common\Backend;
|
||||
use Icinga\Module\Icingadb\Common\HostStates;
|
||||
use ipl\Orm\Relations;
|
||||
|
||||
|
|
@ -24,7 +25,7 @@ class HostState extends State
|
|||
|
||||
public function getColumnDefinitions()
|
||||
{
|
||||
return [
|
||||
$columns = [
|
||||
'environment_id' => t('Environment Id'),
|
||||
'state_type' => t('Host State Type'),
|
||||
'soft_state' => t('Host Soft State'),
|
||||
|
|
@ -53,9 +54,14 @@ class HostState extends State
|
|||
'last_update' => t('Host Last Update'),
|
||||
'last_state_change' => t('Host Last State Change'),
|
||||
'next_check' => t('Host Next Check'),
|
||||
'next_update' => t('Host Next Update'),
|
||||
'affects_children' => t('Host Affects Children'),
|
||||
'next_update' => t('Host Next Update')
|
||||
];
|
||||
|
||||
if (Backend::getDbSchemaVersion() >= 6) {
|
||||
$columns['affects_children'] = t('Host Affects Children');
|
||||
}
|
||||
|
||||
return $columns;
|
||||
}
|
||||
|
||||
public function createRelations(Relations $relations)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
namespace Icinga\Module\Icingadb\Model;
|
||||
|
||||
use Icinga\Module\Icingadb\Common\Auth;
|
||||
use Icinga\Module\Icingadb\Common\Backend;
|
||||
use Icinga\Module\Icingadb\Model\Behavior\BoolCast;
|
||||
use Icinga\Module\Icingadb\Model\Behavior\HasProblematicParent;
|
||||
use Icinga\Module\Icingadb\Model\Behavior\ReRoute;
|
||||
|
|
@ -70,7 +71,7 @@ class Service extends Model
|
|||
|
||||
public function getColumns()
|
||||
{
|
||||
return [
|
||||
$columns = [
|
||||
'environment_id',
|
||||
'name_checksum',
|
||||
'properties_checksum',
|
||||
|
|
@ -105,14 +106,19 @@ class Service extends Model
|
|||
'zone_name',
|
||||
'zone_id',
|
||||
'command_endpoint_name',
|
||||
'command_endpoint_id',
|
||||
'affected_children'
|
||||
'command_endpoint_id'
|
||||
];
|
||||
|
||||
if (Backend::getDbSchemaVersion() >= 6) {
|
||||
$columns[] = 'affected_children';
|
||||
}
|
||||
|
||||
return $columns;
|
||||
}
|
||||
|
||||
public function getColumnDefinitions()
|
||||
{
|
||||
return [
|
||||
$columns = [
|
||||
'environment_id' => t('Environment Id'),
|
||||
'name_checksum' => t('Service Name Checksum'),
|
||||
'properties_checksum' => t('Service Properties Checksum'),
|
||||
|
|
@ -148,8 +154,13 @@ class Service extends Model
|
|||
'zone_id' => t('Zone Id'),
|
||||
'command_endpoint_name' => t('Endpoint Name'),
|
||||
'command_endpoint_id' => t('Endpoint Id'),
|
||||
'affected_children' => t('Affected Children')
|
||||
];
|
||||
|
||||
if (Backend::getDbSchemaVersion() >= 6) {
|
||||
$columns['affected_children'] = t('Affected Children');
|
||||
}
|
||||
|
||||
return $columns;
|
||||
}
|
||||
|
||||
public function getSearchColumns()
|
||||
|
|
@ -196,7 +207,9 @@ class Service extends Model
|
|||
'command_endpoint_id'
|
||||
]));
|
||||
|
||||
$behaviors->add(new HasProblematicParent());
|
||||
if (Backend::getDbSchemaVersion() >= 6) {
|
||||
$behaviors->add(new HasProblematicParent());
|
||||
}
|
||||
}
|
||||
|
||||
public function createDefaults(Defaults $defaults)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
namespace Icinga\Module\Icingadb\Model;
|
||||
|
||||
use Icinga\Module\Icingadb\Common\Backend;
|
||||
use Icinga\Module\Icingadb\Common\ServiceStates;
|
||||
use ipl\Orm\Relations;
|
||||
|
||||
|
|
@ -26,7 +27,7 @@ class ServiceState extends State
|
|||
|
||||
public function getColumnDefinitions()
|
||||
{
|
||||
return [
|
||||
$columns = [
|
||||
'environment_id' => t('Environment Id'),
|
||||
'state_type' => t('Service State Type'),
|
||||
'soft_state' => t('Service Soft State'),
|
||||
|
|
@ -55,9 +56,14 @@ class ServiceState extends State
|
|||
'last_update' => t('Service Last Update'),
|
||||
'last_state_change' => t('Service Last State Change'),
|
||||
'next_check' => t('Service Next Check'),
|
||||
'next_update' => t('Service Next Update'),
|
||||
'affects_children' => t('Service Affects Children'),
|
||||
'next_update' => t('Service Next Update')
|
||||
];
|
||||
|
||||
if (Backend::getDbSchemaVersion() >= 6) {
|
||||
$columns['affects_children'] = t('Service Affects Children');
|
||||
}
|
||||
|
||||
return $columns;
|
||||
}
|
||||
|
||||
public function createRelations(Relations $relations)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
namespace Icinga\Module\Icingadb\Model;
|
||||
|
||||
use DateTime;
|
||||
use Icinga\Module\Icingadb\Common\Backend;
|
||||
use Icinga\Module\Icingadb\Common\Icons;
|
||||
use Icinga\Module\Icingadb\Model\Behavior\BoolCast;
|
||||
use ipl\Orm\Behavior\Binary;
|
||||
|
|
@ -68,7 +69,7 @@ abstract class State extends Model
|
|||
|
||||
public function getColumns()
|
||||
{
|
||||
return [
|
||||
$columns = [
|
||||
'environment_id',
|
||||
'state_type',
|
||||
'soft_state',
|
||||
|
|
@ -99,9 +100,14 @@ abstract class State extends Model
|
|||
'last_update',
|
||||
'last_state_change',
|
||||
'next_check',
|
||||
'next_update',
|
||||
'affects_children'
|
||||
'next_update'
|
||||
];
|
||||
|
||||
if (Backend::getDbSchemaVersion() >= 6) {
|
||||
$columns[] = 'affects_children';
|
||||
}
|
||||
|
||||
return $columns;
|
||||
}
|
||||
|
||||
public function createBehaviors(Behaviors $behaviors)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use Icinga\Application\Web;
|
|||
use Icinga\Date\DateFormatter;
|
||||
use Icinga\Exception\IcingaException;
|
||||
use Icinga\Module\Icingadb\Common\Auth;
|
||||
use Icinga\Module\Icingadb\Common\Backend;
|
||||
use Icinga\Module\Icingadb\Common\Database;
|
||||
use Icinga\Module\Icingadb\Common\HostLinks;
|
||||
use Icinga\Module\Icingadb\Common\Icons;
|
||||
|
|
@ -43,6 +44,7 @@ use ipl\Sql\Expression;
|
|||
use ipl\Sql\Filter\Exists;
|
||||
use ipl\Web\Widget\CopyToClipboard;
|
||||
use ipl\Web\Widget\EmptyState;
|
||||
use ipl\Web\Widget\EmptyStateBar;
|
||||
use ipl\Web\Widget\HorizontalKeyValue;
|
||||
use Icinga\Module\Icingadb\Widget\ItemList\CommentList;
|
||||
use Icinga\Module\Icingadb\Widget\PluginOutputContainer;
|
||||
|
|
@ -617,6 +619,17 @@ class ObjectDetail extends BaseHtmlElement
|
|||
*/
|
||||
protected function createRootProblems(): ?array
|
||||
{
|
||||
if (Backend::getDbSchemaVersion() < 6) {
|
||||
if ($this->object->state->is_reachable) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
HtmlElement::create('h2', null, Text::create(t('Root Problems'))),
|
||||
new EmptyStateBar(t("You're missing out! Upgrade Icinga DB and see the actual root cause here!"))
|
||||
];
|
||||
}
|
||||
|
||||
// If a dependency has failed, then the children are not reachable. Hence, the root problems should not be shown
|
||||
// if the object is reachable. And in case of a service, since, it may be also be unreachable because of its
|
||||
// host being down, only show its root problems if it's really caused by a dependency failure.
|
||||
|
|
@ -669,7 +682,7 @@ class ObjectDetail extends BaseHtmlElement
|
|||
*/
|
||||
protected function createAffectedObjects(): ?array
|
||||
{
|
||||
if (! $this->object->state->affects_children) {
|
||||
if (! isset($this->object->state->affects_children) || ! $this->object->state->affects_children) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ abstract class StateListItem extends BaseListItem
|
|||
Html::tag('span', ['class' => 'state-text'], $this->state->getStateTextTranslated())
|
||||
));
|
||||
|
||||
if ($this->state->affects_children) {
|
||||
if (isset($this->state->affects_children) && $this->state->affects_children) {
|
||||
$total = (int) $this->item->affected_children;
|
||||
|
||||
if ($total > 1000) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue