Fix downtime query and schedule downtime

This commit is contained in:
Jannis Moßhammer 2013-10-20 15:57:56 +02:00
parent 33ecaaa52b
commit 278f975c48
6 changed files with 25 additions and 14 deletions

View File

@ -66,9 +66,10 @@ class ObjectContainer extends \stdClass
foreach ($exploded as $elem) {
if (isset($result->$elem)) {
$result = $result->$elem;
} else {
return null;
}
}
return $result;
}
}

View File

@ -93,4 +93,5 @@ class RuntimeStateContainer extends \stdClass
return $this->$attr;
}
}

View File

@ -92,9 +92,9 @@ class ScheduleDowntimeForm extends WithChildrenCommandForm
->from(
'downtime',
array(
'host_name',
'service_description',
'downtime_scheduled_start_time',
'host',
'service',
'downtime_start',
'downtime_internal_downtime_id'
)
)->fetchAll();
@ -107,7 +107,7 @@ class ScheduleDowntimeForm extends WithChildrenCommandForm
$label = sprintf(
'ID %s: %s%s Starting @ %s',
$downtime->downtime_internal_downtime_id,
$downtime->host_name,
$downtime->host,
!empty($downtime->service_description) ? ' (' . $downtime->service_description . ')' : '',
$dateFormat->formatDateTime($downtime->downtime_scheduled_start_time)
);

View File

@ -23,19 +23,20 @@ $commandHelper = $this->getHelper('CommandForm');
<td>
<?php if (isset($downtime->service)): ?>
<a href="<?= $this->href('monitoring/show/service', array(
'host' => $downtime->host_name,
'service' => $downtime->service_description
'host' => (string) $downtime->host,
'service' => (string) $downtime->service
)); ?>"><?= $downtime->service ?></a>
<small>on <?= $downtime->host ?></small>
<?php else: ?>
<a href="<?= $this->href('monitoring/show/host', array(
'host' => $downtime->host_name
'host' => (string) $downtime->host
)); ?>"><?= $downtime->host ?> </a>
<?php endif; ?>
<br />
<?= $downtime->downtime_author ?>: <?= $downtime->downtime_comment ?>
<br />
<small>Entry Time: <?= $downtime->downtime_entry_time ?></small>
<small>Entry Time: <?= ($downtime->downtime_entry_time) ? $this->dateFormat()->formatDateTime((int) $downtime->downtime_entry_time) : ''; ?>
</small>
<td>
<?php
$data = array(

View File

@ -38,7 +38,7 @@ class DowntimeQuery extends IdoQuery
'downtime' => array(
'downtime_author' => 'sd.author_name',
'downtime_comment' => 'sd.comment_data',
'downtime_entry_time' => 'sd.entry_time',
'downtime_entry_time' => 'UNIX_TIMESTAMP(sd.entry_time)',
'downtime_is_fixed' => 'sd.is_fixed',
'downtime_is_flexible' => 'CASE WHEN sd.is_fixed = 0 THEN 1 ELSE 0 END',
'downtime_start' => "UNIX_TIMESTAMP(CASE WHEN sd.trigger_time != '0000-00-00 00:00:00' then sd.trigger_time ELSE sd.scheduled_start_time END)",

View File

@ -44,17 +44,17 @@ class DowntimeQuery extends StatusdatQuery
'downtime_is_in_effect' => 'is_in_effect',
'downtime_trigger_time' => 'trigger_time',
'downtime_triggered_by_id' => 'triggered_by_id',
'downtime_internal_downtime_id' => 'internal_downtime_id',
'downtime_internal_downtime_id' => 'downtime_id',
'host' => 'host_name',
'host_name' => 'host_name',
'service_host_name' => 'host_name',
'service_description' => 'service_description',
'service_host_name' => 'host_name'
);
public static $handlerParameters = array(
'object_type' => 'getObjectType',
'downtime_start' => 'getDowntimeStart',
'downtime_is_flexible' => 'getFlexibleFlag'
'downtime_is_flexible' => 'getFlexibleFlag',
'service_description' => 'getServiceDescription'
);
public static $fieldTypes = array(
@ -63,6 +63,14 @@ class DowntimeQuery extends StatusdatQuery
'downtime_start' => self::TIMESTAMP
);
public function getServiceDescription(&$obj)
{
if (isset ($obj->service_description)) {
return $obj->service_description;
}
return '';
}
public function getDowntimeStart(&$obj)
{