-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
418 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<?php | ||
|
||
namespace Icinga\Module\Icingadb\Model; | ||
|
||
use ipl\Orm\Relations; | ||
use ipl\Orm\UnionModel; | ||
use ipl\Sql\Expression; | ||
|
||
class HostSlaHistorySummary extends UnionModel | ||
{ | ||
public function getTableName() | ||
{ | ||
return 'host'; | ||
} | ||
|
||
public function getKeyName() | ||
{ | ||
return 'host_id'; | ||
} | ||
|
||
public function getColumns() | ||
{ | ||
return [ | ||
'host_id', | ||
'display_name', | ||
'event_time', | ||
'event_type', | ||
'event_priority', | ||
'hard_state', | ||
'previous_hard_state' | ||
]; | ||
} | ||
|
||
public function getUnions() | ||
{ | ||
return [ | ||
[ | ||
Host::class, | ||
[ | ||
'sla_history_downtime' | ||
], | ||
[ | ||
'display_name' => 'host.display_name', | ||
'event_priority' => new Expression('1'), | ||
'event_time' => 'sla_history_downtime.downtime_start', | ||
'event_type' => new Expression('\'downtime_start\''), | ||
'hard_state' => new Expression('NULL'), | ||
'host_id' => 'id', | ||
'previous_hard_state' => new Expression('NULL'), | ||
] | ||
], | ||
[ | ||
Host::class, | ||
[ | ||
'sla_history_downtime' | ||
], | ||
[ | ||
'display_name' => 'host.display_name', | ||
'event_priority' => new Expression('2'), | ||
'event_time' => 'sla_history_downtime.downtime_end', | ||
'event_type' => new Expression('\'downtime_end\''), | ||
'hard_state' => new Expression('NULL'), | ||
'host_id' => 'id', | ||
'previous_hard_state' => new Expression('NULL'), | ||
] | ||
], | ||
[ | ||
Host::class, | ||
[ | ||
'sla_history_state' | ||
], | ||
[ | ||
'display_name' => 'display_name', | ||
'event_priority' => new Expression('0'), | ||
'event_time' => 'sla_history_state.event_time', | ||
'event_type' => new Expression('\'state_change\''), | ||
'hard_state' => 'sla_history_state.hard_state', | ||
'host_id' => 'id', | ||
'previous_hard_state' => 'sla_history_state.previous_hard_state', | ||
] | ||
], | ||
// Fake result!! | ||
[ | ||
Host::class, | ||
[], | ||
[ | ||
'display_name' => 'host.display_name', | ||
'event_priority' => new Expression('3'), | ||
'event_time' => new Expression('NULL'), | ||
'event_type' => new Expression('\'end\''), | ||
'hard_state' => new Expression('NULL'), | ||
'host_id' => 'id', | ||
'previous_hard_state' => new Expression('NULL'), | ||
] | ||
] | ||
]; | ||
} | ||
|
||
public function getDefaultSort() | ||
{ | ||
return ['display_name', 'event_time', 'event_priority']; | ||
} | ||
|
||
public function createRelations(Relations $relations) | ||
{ | ||
(new Host())->createRelations($relations); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace Icinga\Module\Icingadb\Model; | ||
|
||
use Icinga\Module\Icingadb\Model\Behavior\Timestamp; | ||
use ipl\Orm\Behavior\Binary; | ||
use ipl\Orm\Behaviors; | ||
use ipl\Orm\Model; | ||
use ipl\Orm\Relations; | ||
|
||
class SlaHistoryDowntime extends Model | ||
{ | ||
public function getTableName() | ||
{ | ||
return 'sla_history_downtime'; | ||
} | ||
|
||
public function getKeyName() | ||
{ | ||
return 'id'; | ||
} | ||
|
||
public function getColumns() | ||
{ | ||
return [ | ||
'environment_id', | ||
'endpoint_id', | ||
'host_id', | ||
'service_id', | ||
'downtime_id', | ||
'object_type', | ||
'downtime_start', | ||
'downtime_end' | ||
]; | ||
} | ||
|
||
public function createBehaviors(Behaviors $behaviors) | ||
{ | ||
$behaviors->add(new Binary([ | ||
'id', | ||
'environment_id', | ||
'endpoint_id', | ||
'host_id', | ||
'service_id', | ||
'downtime_id' | ||
])); | ||
|
||
$behaviors->add(new Timestamp([ | ||
'downtime_start', | ||
'downtime_end' | ||
])); | ||
} | ||
|
||
public function createRelations(Relations $relations) | ||
{ | ||
$relations->belongsTo('host', Host::class); | ||
$relations->belongsTo('service', Service::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace Icinga\Module\Icingadb\Model; | ||
|
||
use Icinga\Module\Icingadb\Model\Behavior\Timestamp; | ||
use ipl\Orm\Behavior\Binary; | ||
use ipl\Orm\Behaviors; | ||
use ipl\Orm\Model; | ||
use ipl\Orm\Relations; | ||
|
||
class SlaHistoryState extends Model | ||
{ | ||
public function getTableName() | ||
{ | ||
return 'sla_history_state'; | ||
} | ||
|
||
public function getKeyName() | ||
{ | ||
return 'id'; | ||
} | ||
|
||
public function getColumns() | ||
{ | ||
return [ | ||
'environment_id', | ||
'endpoint_id', | ||
'host_id', | ||
'service_id', | ||
'object_type', | ||
'event_time', | ||
'hard_state', | ||
'previous_hard_state' | ||
]; | ||
} | ||
|
||
public function createBehaviors(Behaviors $behaviors) | ||
{ | ||
$behaviors->add(new Binary([ | ||
'id', | ||
'environment_id', | ||
'endpoint_id', | ||
'host_id', | ||
'service_id' | ||
])); | ||
|
||
$behaviors->add(new Timestamp(['event_time'])); | ||
} | ||
|
||
public function createRelations(Relations $relations) | ||
{ | ||
$relations->belongsTo('host', Host::class); | ||
$relations->belongsTo('service', Service::class); | ||
} | ||
|
||
public function getDefaultSort() | ||
{ | ||
return ['event_time']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.