Add notification queries and display notification details

The notification queries to fetch all required details are now implemented
and are used to display data in the overview. Still missing is the host/service
detail popup and some quicklinks. (Contact, Notification command)

refs #4187
This commit is contained in:
Johannes Meyer 2013-08-09 15:47:34 +02:00 committed by Eric Lippmann
parent 3c2122515a
commit f89d641b06
4 changed files with 127 additions and 22 deletions

View File

@ -224,16 +224,17 @@ class Monitoring_ListController extends ModuleActionController
'host_name',
'service_description',
'notification_type',
'notification_reason',
'notification_start_time',
'notification_contact',
'notification_information',
//'notification_timeperiod',
//'notification_command'
'notification_command'
));
if (!$this->_getParam('sort')) {
// TODO: Remove this once MonitoringView::applyRequestSorting
// applies NotificationView::sortDefaults
$query->order('time', -1); // Descending
$this->_request->setParam('sort', 'notification_start_time');
$this->_request->setParam('dir', -1); // Query is still using ASC!?
}
$this->view->notifications = $query->applyRequest($this->_request);
$this->inheritCurrentSortColumn();

View File

@ -12,7 +12,7 @@
'class' => 'autosubmit'
),
array(
'time' => 'Time'
'notification_start_time' => 'Time'
)
);
?>
@ -20,6 +20,11 @@
<button class="btn btn-small"><i class="icon-refresh"></i></button>
</form>
<?php
$notifications = $this->notifications->paginate();
echo $this->paginationControl($notifications, null, null, array('preserve' => $this->preserve));
?>
<table class="statustable action hosts">
<thead>
<tr>
@ -27,13 +32,75 @@
<th>Service</th>
<th>Type</th>
<th>Time</th>
<th>Time period</th>
<th>Contact</th>
<th>Notification command</th>
<th>Information</th>
</tr>
</thead>
<tbody>
<?php foreach ($notifications as $notification): ?>
<tr>
<td>
<?= $notification->host_name ?>
</td>
<td>
<?= empty($notification->service_description) ? 'N/A' : $notification->service_description ?>
</td>
<td><?php
switch ($notification->notification_reason)
{
case 0:
echo 'NORMAL';
break;
case 1:
echo 'ACKNOWLEDGEMENT';
break;
case 2:
echo 'FLAPPINGSTART';
break;
case 3:
echo 'FLAPPINGSTOP';
break;
case 4:
echo 'FLAPPINGDISABLED';
break;
case 5:
echo 'DOWNTIMESTART';
break;
case 6:
echo 'DOWNTIMEEND';
break;
case 7:
echo 'DOWNTIMECANCELLED';
break;
case 8:
if (intval($notification->notification_type) === 0) {
echo 'CUSTOM(UP)';
} else {
echo 'CUSTOM(OK)';
}
break;
case 9:
echo 'STALKING';
break;
default:
echo 'UNKNOWN';
}
?>
</td>
<td>
<?= $notification->notification_start_time ?>
</td>
<td>
<?= $notification->notification_contact ?>
</td>
<td>
<?= $notification->notification_command ?>
</td>
<td>
<?= $this->escape(substr(strip_tags($notification->notification_information), 0, 10000)); ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>

View File

@ -27,7 +27,7 @@ namespace Monitoring\Backend\Ido\Query;
/**
* Handling notification queries
* NotificationQuery
*/
class NotificationQuery extends AbstractQuery
{
@ -38,19 +38,20 @@ class NotificationQuery extends AbstractQuery
*/
protected $columnMap = array(
'notification' => array(
'notification_type' => '',
'notification_start_time' => '',
'notification_information' => ''
'notification_type' => 'n.notification_type',
'notification_reason' => 'n.notification_reason',
'notification_start_time' => 'n.start_time',
'notification_information' => 'n.output'
),
'objects' => array(
'host_name' => '',
'service_description' => ''
'host_name' => 'o.name1',
'service_description' => 'o.name2'
),
'contact' => array(
'notification_contact' => ''
'notification_contact' => 'c_o.name1'
),
'timeperiod' => array(
'notification_timeperiod' => ''
'command' => array(
'notification_command' => 'cmd_o.name1'
)
);
@ -59,7 +60,10 @@ class NotificationQuery extends AbstractQuery
*/
protected function joinBaseTables()
{
$this->baseQuery = $this->db->select()->from(array(
'n' => $this->prefix . 'notifications'
));
$this->joinedVirtualTables = array('notification' => true);
}
/**
@ -67,7 +71,12 @@ class NotificationQuery extends AbstractQuery
*/
protected function joinObjects()
{
$this->baseQuery->joinInner(
array(
'o' => $this->prefix . 'objects'
),
'n.object_id = o.object_id AND o.is_active = 1 AND o.objecttype_id IN (1, 2)'
);
}
/**
@ -75,14 +84,42 @@ class NotificationQuery extends AbstractQuery
*/
protected function joinContact()
{
$this->baseQuery->joinInner(
array(
'c' => $this->prefix . 'contactnotifications'
),
'n.notification_id = c.notification_id'
);
$this->baseQuery->joinInner(
array(
'c_o' => $this->prefix . 'objects'
),
'c.contact_object_id = c_o.object_id'
);
}
/**
* Fetch assigned time period for each notification
* Fetch name of the command which was used to send out a notification
*/
protected function joinTimeperiod()
protected function joinCommand()
{
$this->baseQuery->joinInner(
array(
'cmd_c' => $this->prefix . 'contactnotifications'
),
'n.notification_id = cmd_c.notification_id'
);
$this->baseQuery->joinInner(
array(
'cmd_m' => $this->prefix . 'contactnotificationmethods'
),
'cmd_c.notification_id = cmd_m.contactnotification_id'
);
$this->baseQuery->joinInner(
array(
'cmd_o' => $this->prefix . 'objects'
),
'cmd_m.command_object_id = cmd_o.object_id'
);
}
}

View File

@ -38,10 +38,10 @@ class NotificationView extends MonitoringView
'host_name',
'service_description',
'notification_type',
'notification_reason',
'notification_start_time',
'notification_contact',
'notification_information',
'notification_timeperiod',
'notification_command'
);