Show/Contact: Add commands to view
Create a new command query and join contact information into. refs #4804
This commit is contained in:
parent
70fdd58fe4
commit
9465c3ffb6
|
@ -108,13 +108,15 @@ class Monitoring_ShowController extends Controller
|
|||
|
||||
public function contactAction()
|
||||
{
|
||||
$contact = $this->getParam('contact');
|
||||
if (! $contact) {
|
||||
$contactName = $this->getParam('contact');
|
||||
|
||||
if (! $contactName) {
|
||||
throw new Zend_Controller_Action_Exception(
|
||||
$this->translate('The parameter `contact\' is required'),
|
||||
404
|
||||
);
|
||||
}
|
||||
|
||||
$query = $this->backend->select()->from('contact', array(
|
||||
'contact_name',
|
||||
'contact_id',
|
||||
|
@ -135,9 +137,22 @@ class Monitoring_ShowController extends Controller
|
|||
'contact_notify_host_flapping',
|
||||
'contact_notify_host_downtime',
|
||||
));
|
||||
$query->where('contact_name', $contact);
|
||||
$this->view->contacts = $query->paginate();
|
||||
$this->view->contact_name = $contact;
|
||||
|
||||
$query->where('contact_name', $contactName);
|
||||
|
||||
$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();
|
||||
}
|
||||
|
||||
$this->view->contact = $contact;
|
||||
$this->view->contactName = $contactName;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
$contactHelper = $this->getHelper('ContactFlags');
|
||||
?>
|
||||
<div style="margin-top: 0.5em;">
|
||||
<?php foreach ($contacts as $contact): ?>
|
||||
<?php if ($contact): ?>
|
||||
<table style="border-spacing: 0.25em; border-collapse: separate;">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -45,12 +45,15 @@ $contactHelper = $this->getHelper('ContactFlags');
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
return;
|
||||
endforeach;
|
||||
printf(
|
||||
'%s: `%s\'',
|
||||
t('No such contact'), $contact_name
|
||||
);
|
||||
?>
|
||||
|
||||
<h4><?= $this->translate('Commands'); ?>:</h4>
|
||||
<ul>
|
||||
<?php foreach ($commands as $command): ?>
|
||||
<li><?= $command->command_name; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
<?php else: ?>
|
||||
<?= $this->translate('No such contact'); ?>: <?= $contactName; ?>
|
||||
<?php endif; ?>
|
||||
</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'
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue