commit
e342035464
|
@ -108,19 +108,22 @@ class Monitoring_ShowController extends Controller
|
||||||
|
|
||||||
public function contactAction()
|
public function contactAction()
|
||||||
{
|
{
|
||||||
$contact = $this->getParam('contact');
|
$contactName = $this->getParam('contact');
|
||||||
if (! $contact) {
|
|
||||||
|
if (! $contactName) {
|
||||||
throw new Zend_Controller_Action_Exception(
|
throw new Zend_Controller_Action_Exception(
|
||||||
$this->translate('The parameter `contact\' is required'),
|
$this->translate('The parameter `contact\' is required'),
|
||||||
404
|
404
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = $this->backend->select()->from('contact', array(
|
$query = $this->backend->select()->from('contact', array(
|
||||||
'contact_name',
|
'contact_name',
|
||||||
'contact_id',
|
'contact_id',
|
||||||
'contact_alias',
|
'contact_alias',
|
||||||
'contact_email',
|
'contact_email',
|
||||||
'contact_pager',
|
'contact_pager',
|
||||||
|
'contact_object_id',
|
||||||
'contact_notify_service_timeperiod',
|
'contact_notify_service_timeperiod',
|
||||||
'contact_notify_service_recovery',
|
'contact_notify_service_recovery',
|
||||||
'contact_notify_service_warning',
|
'contact_notify_service_warning',
|
||||||
|
@ -135,9 +138,36 @@ class Monitoring_ShowController extends Controller
|
||||||
'contact_notify_host_flapping',
|
'contact_notify_host_flapping',
|
||||||
'contact_notify_host_downtime',
|
'contact_notify_host_downtime',
|
||||||
));
|
));
|
||||||
$query->where('contact_name', $contact);
|
|
||||||
$this->view->contacts = $query->paginate();
|
$query->where('contact_name', $contactName);
|
||||||
$this->view->contact_name = $contact;
|
|
||||||
|
$contact = $query->getQuery()->fetchRow();
|
||||||
|
|
||||||
|
if ($contact) {
|
||||||
|
$commands = $this->backend->select()->from('command', array(
|
||||||
|
'command_line',
|
||||||
|
'command_name'
|
||||||
|
))->where('contact_id', $contact->contact_id);
|
||||||
|
|
||||||
|
$this->view->commands = $commands->paginate();
|
||||||
|
|
||||||
|
$notifications = $this->backend->select()->from('notification', array(
|
||||||
|
'host',
|
||||||
|
'service',
|
||||||
|
'notification_output',
|
||||||
|
'notification_contact',
|
||||||
|
'notification_start_time',
|
||||||
|
'notification_state'
|
||||||
|
));
|
||||||
|
|
||||||
|
$notifications->where('contact_object_id', $contact->contact_object_id);
|
||||||
|
|
||||||
|
$this->view->compact = true;
|
||||||
|
$this->view->notifications = $notifications->paginate();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->view->contact = $contact;
|
||||||
|
$this->view->contactName = $contactName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
$contactHelper = $this->getHelper('ContactFlags');
|
$contactHelper = $this->getHelper('ContactFlags');
|
||||||
?>
|
?>
|
||||||
<div style="margin-top: 0.5em;">
|
<div style="margin-top: 0.5em;">
|
||||||
<?php foreach ($contacts as $contact): ?>
|
<?php if ($contact): ?>
|
||||||
<table style="border-spacing: 0.25em; border-collapse: separate;">
|
<table style="border-spacing: 0.25em; border-collapse: separate;">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -45,12 +45,18 @@ $contactHelper = $this->getHelper('ContactFlags');
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<?php
|
|
||||||
return;
|
<h4><?= $this->translate('Commands'); ?>:</h4>
|
||||||
endforeach;
|
<ul>
|
||||||
printf(
|
<?php foreach ($commands as $command): ?>
|
||||||
'%s: `%s\'',
|
<li><?= $command->command_name; ?></li>
|
||||||
t('No such contact'), $contact_name
|
<?php endforeach; ?>
|
||||||
);
|
</ul>
|
||||||
?>
|
|
||||||
|
<h4><?= $this->translate('Notifications'); ?>:</h4>
|
||||||
|
<?= $this->render('list/notifications.phtml') ?>
|
||||||
|
|
||||||
|
<?php else: ?>
|
||||||
|
<?= $this->translate('No such contact'); ?>: <?= $contactName; ?>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query for commands
|
||||||
|
*/
|
||||||
|
class CommandQuery extends IdoQuery
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $columnMap = array(
|
||||||
|
'commands' => array(
|
||||||
|
'command_id' => 'c.command_id',
|
||||||
|
'command_instance_id' => 'c.instance_id',
|
||||||
|
'command_config_type' => 'c.config_type',
|
||||||
|
'command_line' => 'c.command_line',
|
||||||
|
'command_name' => 'co.name1'
|
||||||
|
),
|
||||||
|
|
||||||
|
'contacts' => array(
|
||||||
|
'contact_id' => 'con.contact_id',
|
||||||
|
'contact_alias' => 'con.contact_alias'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch basic information about commands
|
||||||
|
*/
|
||||||
|
protected function joinBaseTables()
|
||||||
|
{
|
||||||
|
$this->select->from(
|
||||||
|
array('c' => $this->prefix . 'commands'),
|
||||||
|
array()
|
||||||
|
)->join(
|
||||||
|
array('co' => $this->prefix . 'objects'),
|
||||||
|
'co.object_id = c.object_id',
|
||||||
|
array()
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->joinedVirtualTables = array('commands' => true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Join contacts
|
||||||
|
*/
|
||||||
|
protected function joinContacts()
|
||||||
|
{
|
||||||
|
$this->select->join(
|
||||||
|
array('cnc' => $this->prefix . 'contact_notificationcommands'),
|
||||||
|
'cnc.command_object_id = co.object_id'
|
||||||
|
)->join(
|
||||||
|
array('con' => $this->prefix . 'contacts'),
|
||||||
|
'con.contact_id = cnc.contact_id'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,7 @@ class ContactQuery extends IdoQuery
|
||||||
'contact_alias' => 'c.alias COLLATE latin1_general_ci',
|
'contact_alias' => 'c.alias COLLATE latin1_general_ci',
|
||||||
'contact_email' => 'c.email_address COLLATE latin1_general_ci',
|
'contact_email' => 'c.email_address COLLATE latin1_general_ci',
|
||||||
'contact_pager' => 'c.pager_address',
|
'contact_pager' => 'c.pager_address',
|
||||||
|
'contact_object_id' => 'c.contact_object_id',
|
||||||
'contact_has_host_notfications' => 'c.host_notifications_enabled',
|
'contact_has_host_notfications' => 'c.host_notifications_enabled',
|
||||||
'contact_has_service_notfications' => 'c.service_notifications_enabled',
|
'contact_has_service_notfications' => 'c.service_notifications_enabled',
|
||||||
'contact_can_submit_commands' => 'c.can_submit_commands',
|
'contact_can_submit_commands' => 'c.can_submit_commands',
|
||||||
|
|
|
@ -25,7 +25,8 @@ class NotificationQuery extends IdoQuery
|
||||||
'service' => 'o.name2'
|
'service' => 'o.name2'
|
||||||
),
|
),
|
||||||
'contact' => array(
|
'contact' => array(
|
||||||
'notification_contact' => 'c_o.name1'
|
'notification_contact' => 'c_o.name1',
|
||||||
|
'contact_object_id' => 'c_o.object_id'
|
||||||
),
|
),
|
||||||
'command' => array(
|
'command' => array(
|
||||||
'notification_command' => 'cmd_o.name1'
|
'notification_command' => 'cmd_o.name1'
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Icinga\Module\Monitoring\DataView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* View representation for commands
|
||||||
|
*/
|
||||||
|
class Command extends DataView
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Retrieve columns provided by this view
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getColumns()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'command_id',
|
||||||
|
'command_instance_id',
|
||||||
|
'command_config_type',
|
||||||
|
'command_line',
|
||||||
|
'command_name'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -38,6 +38,7 @@ class Contact extends DataView
|
||||||
'contact_notify_host_unreachable',
|
'contact_notify_host_unreachable',
|
||||||
'contact_notify_host_flapping',
|
'contact_notify_host_flapping',
|
||||||
'contact_notify_host_downtime',
|
'contact_notify_host_downtime',
|
||||||
|
'contact_object_id',
|
||||||
'host_object_id',
|
'host_object_id',
|
||||||
'host_name',
|
'host_name',
|
||||||
'service_object_id',
|
'service_object_id',
|
||||||
|
|
Loading…
Reference in New Issue