Introduce model StateHistory

This commit is contained in:
Eric Lippmann 2019-11-03 22:04:10 +01:00
parent c1ff9f3587
commit 23f2ec65ae

View file

@ -0,0 +1,58 @@
<?php
namespace Icinga\Module\Eagle\Model;
use Icinga\Module\Eagle\Model\Behavior\Timestamp;
use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
class StateHistory extends Model
{
public function getTableName()
{
return 'state_history';
}
public function getKeyName()
{
return 'id';
}
public function getColumns()
{
return [
'environment_id',
'endpoint_id',
'object_type',
'host_id',
'service_id',
'event_time',
'state_type',
'soft_state',
'hard_state',
'attempt',
'previous_soft_state',
'previous_hard_state',
'output',
'long_output',
'max_check_attempts',
'check_source'
];
}
public function createBehaviors(Behaviors $behaviors)
{
$behaviors->add(new Timestamp([
'event_time'
]));
}
public function createRelations(Relations $relations)
{
$relations->belongsTo('endpoint', Endpoint::class);
$relations->belongsTo('environment', Environment::class);
$relations->belongsTo('host', Host::class)->setJoinType('LEFT');
$relations->belongsTo('service', Service::class)->setJoinType('LEFT');
}
}