Merge branch 'master' into feature/user-and-group-management-8826

Conflicts:
	library/Icinga/Authentication/Backend/LdapUserBackend.php
	library/Icinga/Protocol/Ldap/Query.php
This commit is contained in:
Johannes Meyer 2015-05-19 14:14:03 +02:00
commit fb07f0b94c
46 changed files with 1855 additions and 749 deletions

View File

@ -12,7 +12,6 @@ class FilterExpression extends Filter
public function __construct($column, $sign, $expression) public function __construct($column, $sign, $expression)
{ {
$column = trim($column); $column = trim($column);
$expression = is_array($expression) ? array_map('trim', $expression) : trim($expression);
$this->column = $column; $this->column = $column;
$this->sign = $sign; $this->sign = $sign;
$this->expression = $expression; $this->expression = $expression;

View File

@ -9,7 +9,8 @@ namespace Icinga\Protocol\Ldap;
* Provides information about the available encryption mechanisms (StartTLS), the supported * Provides information about the available encryption mechanisms (StartTLS), the supported
* LDAP protocol (v2/v3), vendor-specific extensions or protocols controls and extensions. * LDAP protocol (v2/v3), vendor-specific extensions or protocols controls and extensions.
*/ */
class Capability { class Capability
{
const LDAP_SERVER_START_TLS_OID = '1.3.6.1.4.1.1466.20037'; const LDAP_SERVER_START_TLS_OID = '1.3.6.1.4.1.1466.20037';

View File

@ -6,7 +6,8 @@ namespace Icinga\Util;
/** /**
* Provide functions to change and convert colors. * Provide functions to change and convert colors.
*/ */
class Color { class Color
{
/** /**
* Convert a given color string to an rgb-array containing * Convert a given color string to an rgb-array containing
* each color as a decimal value. * each color as a decimal value.

View File

@ -79,4 +79,59 @@ class String
return $matches; return $matches;
} }
/**
* Check if a string ends with a different string
*
* @param $haystack The string to search for matches
* @param $needle The string to match at the start of the haystack
*
* @return bool Whether or not needle is at the beginning of haystack
*/
public static function endsWith($haystack, $needle)
{
return $needle === '' ||
(($temp = strlen($haystack) - strlen($needle)) >= 0 && false !== strpos($haystack, $needle, $temp));
}
/**
* Generates an array of strings that constitutes the cartesian product of all passed sets, with all
* string combinations concatenated using the passed join-operator.
*
* <pre>
* cartesianProduct(
* array(array('foo', 'bar'), array('mumble', 'grumble', null)),
* '_'
* );
* => array('foo_mumble', 'foo_grumble', 'bar_mumble', 'bar_grumble', 'foo', 'bar')
* </pre>
*
* @param array $sets An array of arrays containing all sets for which the cartesian
* product should be calculated.
* @param string $glue The glue used to join the strings, defaults to ''.
*
* @returns array The cartesian product in one array of strings.
*/
public static function cartesianProduct(array $sets, $glue = '')
{
$product = null;
foreach ($sets as $set) {
if (! isset($product)) {
$product = $set;
} else {
$newProduct = array();
foreach ($product as $strA) {
foreach ($set as $strB) {
if ($strB === null) {
$newProduct []= $strA;
} else {
$newProduct []= $strA . $glue . $strB;
}
}
}
$product = $newProduct;
}
}
return $product;
}
} }

View File

@ -3,12 +3,11 @@
namespace Icinga\Web; namespace Icinga\Web;
use Zend_Paginator;
use Icinga\Data\Sortable; use Icinga\Data\Sortable;
use Icinga\Data\QueryInterface; use Icinga\Data\QueryInterface;
use Icinga\Web\Paginator\Adapter\QueryAdapter;
use Icinga\Web\Controller\ModuleActionController; use Icinga\Web\Controller\ModuleActionController;
use Icinga\Web\Widget\Limiter; use Icinga\Web\Widget\Limiter;
use Icinga\Web\Widget\Paginator;
use Icinga\Web\Widget\SortBox; use Icinga\Web\Widget\SortBox;
/** /**
@ -115,12 +114,11 @@ class Controller extends ModuleActionController
$request = $this->getRequest(); $request = $this->getRequest();
$limit = $request->getParam('limit', $itemsPerPage); $limit = $request->getParam('limit', $itemsPerPage);
$page = $request->getParam('page', $pageNumber); $page = $request->getParam('page', $pageNumber);
$query->limit($limit, $page * $limit); $query->limit($limit, $page > 0 ? ($page - 1) * $limit : 0);
if (! $this->view->compact) { if (! $this->view->compact) {
$paginator = new Zend_Paginator(new QueryAdapter($query)); $paginator = new Paginator();
$paginator->setItemCountPerPage($limit); $paginator->setQuery($query);
$paginator->setCurrentPageNumber($page);
$this->view->paginator = $paginator; $this->view->paginator = $paginator;
} }

View File

@ -5,11 +5,13 @@ namespace Icinga\Web\Widget\Chart;
use Icinga\Chart\PieChart; use Icinga\Chart\PieChart;
use Icinga\Module\Monitoring\Plugin\PerfdataSet; use Icinga\Module\Monitoring\Plugin\PerfdataSet;
use Icinga\Util\String;
use Icinga\Web\Widget\AbstractWidget; use Icinga\Web\Widget\AbstractWidget;
use Icinga\Web\Url; use Icinga\Web\Url;
use Icinga\Util\Format; use Icinga\Util\Format;
use Icinga\Application\Logger; use Icinga\Application\Logger;
use Icinga\Exception\IcingaException; use Icinga\Exception\IcingaException;
use stdClass;
/** /**
* A SVG-PieChart intended to be displayed as a small icon next to labels, to offer a better visualization of the * A SVG-PieChart intended to be displayed as a small icon next to labels, to offer a better visualization of the
@ -27,6 +29,45 @@ class InlinePie extends AbstractWidget
const NUMBER_FORMAT_BYTES = 'bytes'; const NUMBER_FORMAT_BYTES = 'bytes';
const NUMBER_FORMAT_RATIO = 'ratio'; const NUMBER_FORMAT_RATIO = 'ratio';
public static $colorsHostStates = array(
'#44bb77', // up
'#ff99aa', // down
'#cc77ff', // unreachable
'#77aaff' // pending
);
public static $colorsHostStatesHandledUnhandled = array(
'#44bb77', // up
'#44bb77',
'#ff99aa', // down
'#ff5566',
'#cc77ff', // unreachable
'#aa44ff',
'#77aaff', // pending
'#77aaff'
);
public static $colorsServiceStates = array(
'#44bb77', // Ok
'#ffaa44', // Warning
'#ff99aa', // Critical
'#aa44ff', // Unknown
'#77aaff' // Pending
);
public static $colorsServiceStatesHandleUnhandled = array(
'#44bb77', // Ok
'#44bb77',
'#ffaa44', // Warning
'#ffcc66',
'#ff99aa', // Critical
'#ff5566',
'#cc77ff', // Unknown
'#aa44ff',
'#77aaff', // Pending
'#77aaff'
);
/** /**
* The template string used for rendering this widget * The template string used for rendering this widget
* *
@ -231,4 +272,19 @@ EOD;
$template = str_replace('{data}', htmlspecialchars(implode(',', $data)), $template); $template = str_replace('{data}', htmlspecialchars(implode(',', $data)), $template);
return $template; return $template;
} }
public static function createFromStateSummary(stdClass $states, $title, array $colors)
{
$handledUnhandledStates = array();
foreach ($states as $key => $value) {
if (String::endsWith($key, '_handled') || String::endsWith($key, '_unhandled')) {
$handledUnhandledStates[$key] = $value;
}
}
$chart = new self(array_values($handledUnhandledStates), $title, $colors);
return $chart
->setSize(50)
->setTitle('')
->setSparklineClass('sparkline-multi');
}
} }

View File

@ -76,6 +76,13 @@ class FilterEditor extends AbstractWidget
return $this->filter; return $this->filter;
} }
/**
* Set columns to search in
*
* @param array $searchColumns
*
* @return $this
*/
public function setSearchColumns(array $searchColumns) public function setSearchColumns(array $searchColumns)
{ {
$this->searchColumns = $searchColumns; $this->searchColumns = $searchColumns;
@ -231,10 +238,11 @@ class FilterEditor extends AbstractWidget
if ($searchCol === null) { if ($searchCol === null) {
throw new Exception('Cannot search here'); throw new Exception('Cannot search here');
} }
$search = ltrim($search);
$filter = $this->mergeRootExpression($filter, $searchCol, '=', "*$search*"); $filter = $this->mergeRootExpression($filter, $searchCol, '=', "*$search*");
} else { } else {
list($k, $v) = preg_split('/=/', $search); list($k, $v) = preg_split('/=/', $search);
$filter = $this->mergeRootExpression($filter, $k, '=', $v); $filter = $this->mergeRootExpression($filter, trim($k), '=', ltrim($v));
} }
} else { } else {
if (false === $this->resetSearchColumns($filter)) { if (false === $this->resetSearchColumns($filter)) {
@ -242,6 +250,7 @@ class FilterEditor extends AbstractWidget
} }
$filters = array(); $filters = array();
$search = ltrim($search);
foreach ($this->searchColumns as $searchColumn) { foreach ($this->searchColumns as $searchColumn) {
$filters[] = Filter::expression($searchColumn, '=', "*$search*"); $filters[] = Filter::expression($searchColumn, '=', "*$search*");
} }
@ -445,10 +454,10 @@ class FilterEditor extends AbstractWidget
if ($this->addTo && $this->addTo === $filter->getId()) { if ($this->addTo && $this->addTo === $filter->getId()) {
return return
preg_replace( preg_replace(
'/ class="autosubmit"/', '/ class="autosubmit"/',
' class="autofocus"', ' class="autofocus"',
$this->selectOperator() $this->selectOperator()
) )
. '<ul><li>' . '<ul><li>'
. $this->selectColumn($filter) . $this->selectColumn($filter)
. $this->selectSign($filter) . $this->selectSign($filter)
@ -695,7 +704,7 @@ class FilterEditor extends AbstractWidget
. t('Search...') . t('Search...')
. '" /></form>'; . '" /></form>';
if ($this->filter->isEmpty()) { if ($this->filter->isEmpty()) {
$title = t('Filter this list'); $title = t('Filter this list');
} else { } else {
$title = t('Modify this filter'); $title = t('Modify this filter');

View File

@ -0,0 +1,168 @@
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
namespace Icinga\Web\Widget;
use Icinga\Data\QueryInterface;
use Icinga\Exception\ProgrammingError;
/**
* Paginator
*/
class Paginator extends AbstractWidget
{
/**
* The query the paginator widget is created for
*
* @var QueryInterface
*/
protected $query;
/**
* The view script in use
*
* @var string|array
*/
protected $viewScript = array('mixedPagination.phtml', 'default');
/**
* Set the query to create the paginator widget for
*
* @param QueryInterface $query
*
* @return $this
*/
public function setQuery(QueryInterface $query)
{
$this->query = $query;
return $this;
}
/**
* Set the view script to use
*
* @param string|array $script
*
* @return $this
*/
public function setViewScript($script)
{
$this->viewScript = $script;
return $this;
}
/**
* Render this paginator
*/
public function render()
{
if ($this->query === null) {
throw new ProgrammingError('Need a query to create the paginator widget for');
}
$itemCountPerPage = $this->query->getLimit();
if (! $itemCountPerPage) {
return ''; // No pagination required
}
$totalItemCount = count($this->query);
$pageCount = (int) ceil($totalItemCount / $itemCountPerPage);
$currentPage = $this->query->hasOffset() ? ($this->query->getOffset() / $itemCountPerPage) + 1 : 1;
$pagesInRange = $this->getPages($pageCount, $currentPage);
$variables = array(
'totalItemCount' => $totalItemCount,
'pageCount' => $pageCount,
'itemCountPerPage' => $itemCountPerPage,
'first' => 1,
'current' => $currentPage,
'last' => $pageCount,
'pagesInRange' => $pagesInRange,
'firstPageInRange' => min($pagesInRange),
'lastPageInRange' => max($pagesInRange)
);
if ($currentPage > 1) {
$variables['previous'] = $currentPage - 1;
}
if ($currentPage < $pageCount) {
$variables['next'] = $currentPage + 1;
}
if (is_array($this->viewScript)) {
if ($this->viewScript[1] !== null) {
return $this->view()->partial($this->viewScript[0], $this->viewScript[1], $variables);
}
return $this->view()->partial($this->viewScript[0], $variables);
}
return $this->view()->partial($this->viewScript, $variables);
}
/**
* Returns an array of "local" pages given the page count and current page number
*
* @return array
*/
protected function getPages($pageCount, $currentPage)
{
$range = array();
if ($pageCount < 10) {
// Show all pages if we have less than 10
for ($i = 1; $i < 10; $i++) {
if ($i > $pageCount) {
break;
}
$range[$i] = $i;
}
} else {
// More than 10 pages:
foreach (array(1, 2) as $i) {
$range[$i] = $i;
}
if ($currentPage < 6 ) {
// We are on page 1-5 from
for ($i = 1; $i <= 7; $i++) {
$range[$i] = $i;
}
} else {
// Current page > 5
$range[] = '...';
if (($pageCount - $currentPage) < 5) {
// Less than 5 pages left
$start = 5 - ($pageCount - $currentPage);
} else {
$start = 1;
}
for ($i = $currentPage - $start; $i < ($currentPage + (4 - $start)); $i++) {
if ($i > $pageCount) {
break;
}
$range[$i] = $i;
}
}
if ($currentPage < ($pageCount - 2)) {
$range[] = '...';
}
foreach (array($pageCount - 1, $pageCount) as $i) {
$range[$i] = $i;
}
}
if (empty($range)) {
$range[] = 1;
}
return $range;
}
}

View File

@ -55,8 +55,8 @@ class Monitoring_CommentsController extends Controller
'title' => $this->translate( 'title' => $this->translate(
'Display detailed information about multiple comments.' 'Display detailed information about multiple comments.'
), ),
'icon' => 'comment', 'icon' => 'comment',
'label' => $this->translate('Comments'), 'label' => $this->translate('Comments') . sprintf(' (%d)', count($this->comments)),
'url' =>'monitoring/comments/show' 'url' =>'monitoring/comments/show'
) )
)->activate('comments'); )->activate('comments');

View File

@ -75,8 +75,8 @@ class Monitoring_DowntimesController extends Controller
'title' => $this->translate( 'title' => $this->translate(
'Display detailed information about multiple downtimes.' 'Display detailed information about multiple downtimes.'
), ),
'icon' => 'plug', 'icon' => 'plug',
'label' => $this->translate('Downtimes'), 'label' => $this->translate('Downtimes') . sprintf(' (%d)', count($this->downtimes)),
'url' =>'monitoring/downtimes/show' 'url' =>'monitoring/downtimes/show'
) )
)->activate('downtimes'); )->activate('downtimes');

View File

@ -49,6 +49,11 @@ class Monitoring_HostController extends MonitoredObjectController
$this->getTabs()->activate('host'); $this->getTabs()->activate('host');
} }
/**
* Get host actions from hook
*
* @return array
*/
protected function getHostActions() protected function getHostActions()
{ {
$urls = array(); $urls = array();
@ -67,7 +72,7 @@ class Monitoring_HostController extends MonitoredObjectController
*/ */
public function showAction() public function showAction()
{ {
$this->view->hostActions = $this->getHostActions(); $this->view->actions = $this->getHostActions();
parent::showAction(); parent::showAction();
} }

View File

@ -2,6 +2,7 @@
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ /* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
use Icinga\Data\Filter\Filter; use Icinga\Data\Filter\Filter;
use Icinga\Data\Filter\FilterEqual;
use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Controller;
use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\CheckNowCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\CheckNowCommandForm;
@ -10,11 +11,10 @@ use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostCheckCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostCheckCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostDowntimeCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostDowntimeCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm;
use Icinga\Module\Monitoring\Object\Host;
use Icinga\Module\Monitoring\Object\HostList; use Icinga\Module\Monitoring\Object\HostList;
use Icinga\Web\Url; use Icinga\Web\Url;
use Icinga\Web\Widget\Chart\InlinePie;
use Icinga\Web\Widget\Tabextension\DashboardAction; use Icinga\Web\Widget\Tabextension\DashboardAction;
class Monitoring_HostsController extends Controller class Monitoring_HostsController extends Controller
@ -26,9 +26,28 @@ class Monitoring_HostsController extends Controller
public function init() public function init()
{ {
// Support switching from service-view using the host and service selection. The filter would error
// on any occurrence of a filter based on service.
$filterString = preg_replace('/(service=[^)&]*)/', '', (string)$this->params);
$hostList = new HostList($this->backend); $hostList = new HostList($this->backend);
$hostList->setFilter(Filter::fromQueryString((string) $this->params->without('view'))); $hostList->setFilter(Filter::fromQueryString((string) $this->params->without('view')));
$this->hostList = $hostList; $this->hostList = $hostList;
$this->getTabs()->add(
'show',
array(
'title' => sprintf(
$this->translate('Show summarized information for %u hosts'),
count($this->hostList)
),
'label' => $this->translate('Hosts') . sprintf(' (%d)', count($this->hostList)),
'url' => Url::fromRequest(),
'icon' => 'host'
)
)->extend(new DashboardAction())->activate('show');
$this->view->listAllLink = Url::fromRequest()->setPath('monitoring/list/hosts')->setQueryString($filterString);
} }
protected function handleCommandForm(ObjectsCommandForm $form) protected function handleCommandForm(ObjectsCommandForm $form)
@ -39,7 +58,14 @@ class Monitoring_HostsController extends Controller
'host_problem', 'host_problem',
'host_handled', 'host_handled',
'host_acknowledged', 'host_acknowledged',
'host_in_downtime' 'host_in_downtime',
'host_last_ack',
'host_is_flapping',
'host_last_comment',
'host_output',
'host_notifications_enabled',
'host_active_checks_enabled',
'host_passive_checks_enabled'
)); ));
$form $form
@ -47,23 +73,13 @@ class Monitoring_HostsController extends Controller
->setRedirectUrl(Url::fromPath('monitoring/hosts/show')->setParams($this->params)) ->setRedirectUrl(Url::fromPath('monitoring/hosts/show')->setParams($this->params))
->handleRequest(); ->handleRequest();
$hostStates = array(
Host::getStateText(Host::STATE_UP) => 0,
Host::getStateText(Host::STATE_DOWN) => 0,
Host::getStateText(Host::STATE_UNREACHABLE) => 0,
Host::getStateText(Host::STATE_PENDING) => 0,
);
foreach ($this->hostList as $host) {
++$hostStates[$host::getStateText($host->state)];
}
$this->view->form = $form; $this->view->form = $form;
$this->view->objects = $this->hostList; $this->view->objects = $this->hostList;
$this->view->hostStates = $hostStates; $this->view->stats = $this->hostList->getStateSummary();
$this->view->hostStatesPieChart = $this->createPieChart( $this->view->hostStatesPieChart = InlinePie::createFromStateSummary(
$hostStates, $this->view->stats,
$this->translate('Host State'), $this->translate('Host State'),
array('#44bb77', '#FF5566', '#E066FF', '#77AAFF') InlinePie::$colorsHostStatesHandledUnhandled
); );
$this->_helper->viewRenderer('partials/command/objects-command-form', null, true); $this->_helper->viewRenderer('partials/command/objects-command-form', null, true);
return $form; return $form;
@ -71,17 +87,6 @@ class Monitoring_HostsController extends Controller
public function showAction() public function showAction()
{ {
$this->getTabs()->add(
'show',
array(
'title' => sprintf(
$this->translate('Show summarized information for %u hosts'),
count($this->hostList)
),
'label' => $this->translate('Hosts'),
'url' => Url::fromRequest()
)
)->extend(new DashboardAction())->activate('show');
$this->setAutorefreshInterval(15); $this->setAutorefreshInterval(15);
$checkNowForm = new CheckNowCommandForm(); $checkNowForm = new CheckNowCommandForm();
$checkNowForm $checkNowForm
@ -94,40 +99,20 @@ class Monitoring_HostsController extends Controller
'host_problem', 'host_problem',
'host_handled', 'host_handled',
'host_acknowledged', 'host_acknowledged',
'host_in_downtime'/*, 'host_in_downtime',
'host_passive_checks_enabled', 'host_last_ack',
'host_is_flapping',
'host_last_comment',
'host_output',
'host_notifications_enabled', 'host_notifications_enabled',
'host_event_handler_enabled',
'host_flap_detection_enabled',
'host_active_checks_enabled', 'host_active_checks_enabled',
'host_passive_checks_enabled'
/*'host_event_handler_enabled',
'host_flap_detection_enabled',
'host_obsessing'*/ 'host_obsessing'*/
)); ));
$unhandledObjects = array();
$unhandledFilterExpressions = array(); $acknowledgedObjects = $this->hostList->getAcknowledgedObjects();
$acknowledgedObjects = array();
$objectsInDowntime = array();
$downtimeFilterExpressions = array();
$hostStates = array(
Host::getStateText(Host::STATE_UP) => 0,
Host::getStateText(Host::STATE_DOWN) => 0,
Host::getStateText(Host::STATE_UNREACHABLE) => 0,
Host::getStateText(Host::STATE_PENDING) => 0,
);
foreach ($this->hostList as $host) {
/** @var Host $host */
if ((bool) $host->problem === true && (bool) $host->handled === false) {
$unhandledObjects[] = $host;
$unhandledFilterExpressions[] = Filter::where('host', $host->getName());
}
if ((bool) $host->acknowledged === true) {
$acknowledgedObjects[] = $host;
}
if ((bool) $host->in_downtime === true) {
$objectsInDowntime[] = $host;
$downtimeFilterExpressions[] = Filter::where('host_name', $host->getName());
}
++$hostStates[$host::getStateText($host->state)];
}
if (! empty($acknowledgedObjects)) { if (! empty($acknowledgedObjects)) {
$removeAckForm = new RemoveAcknowledgementCommandForm(); $removeAckForm = new RemoveAcknowledgementCommandForm();
$removeAckForm $removeAckForm
@ -135,43 +120,68 @@ class Monitoring_HostsController extends Controller
->handleRequest(); ->handleRequest();
$this->view->removeAckForm = $removeAckForm; $this->view->removeAckForm = $removeAckForm;
} }
$hostStates = (object)$this->hostList->getStateSummary();
$this->setAutorefreshInterval(15); $this->setAutorefreshInterval(15);
$this->view->listAllLink = Url::fromRequest()->setPath('monitoring/list/hosts');
$this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/hosts/reschedule-check'); $this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/hosts/reschedule-check');
$this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/hosts/schedule-downtime'); $this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/hosts/schedule-downtime');
$this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/hosts/process-check-result'); $this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/hosts/process-check-result');
$this->view->hostStates = $hostStates; $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/hosts/add-comment');
$this->view->stats = $hostStates;
$this->view->objects = $this->hostList; $this->view->objects = $this->hostList;
$this->view->unhandledObjects = $unhandledObjects; $this->view->unhandledObjects = $this->hostList->getUnhandledObjects();
$unhandledFilterQueryString = Filter::matchAny($unhandledFilterExpressions)->toQueryString(); $this->view->problemObjects = $this->hostList->getProblemObjects();
$this->view->acknowledgeUnhandledLink = Url::fromPath('monitoring/hosts/acknowledge-problem') $this->view->acknowledgeUnhandledLink = Url::fromPath('monitoring/hosts/acknowledge-problem')
->setQueryString($unhandledFilterQueryString); ->setQueryString($this->hostList->getUnhandledObjects()->objectsFilter());
$this->view->downtimeUnhandledLink = Url::fromPath('monitoring/hosts/schedule-downtime') $this->view->downtimeUnhandledLink = Url::fromPath('monitoring/hosts/schedule-downtime')
->setQueryString($unhandledFilterQueryString); ->setQueryString($this->hostList->getUnhandledObjects()->objectsFilter());
$this->view->acknowledgedObjects = $acknowledgedObjects; $this->view->downtimeLink = Url::fromPath('monitoring/hosts/schedule-downtime')
$this->view->objectsInDowntime = $objectsInDowntime; ->setQueryString($this->hostList->getProblemObjects()->objectsFilter());
$this->view->inDowntimeLink = Url::fromPath('monitoring/list/downtimes') $this->view->acknowledgedObjects = $this->hostList->getAcknowledgedObjects();
->setQueryString(Filter::matchAny($downtimeFilterExpressions)->toQueryString()); $this->view->objectsInDowntime = $this->hostList->getObjectsInDowntime();
$this->view->commentsLink = Url::fromRequest() $this->view->inDowntimeLink = Url::fromPath('monitoring/list/hosts')
->setPath('monitoring/list/comments'); ->setQueryString(
$this->view->hostStatesPieChart = $this->createPieChart( $this->hostList
$hostStates, ->getObjectsInDowntime()
$this->translate('Host State'), ->objectsFilter()
array('#44bb77', '#FF5566', '#E066FF', '#77AAFF') ->toQueryString()
);
$this->view->sendCustomNotificationLink =
Url::fromRequest()->setPath(
'monitoring/hosts/send-custom-notification'
); );
$this->view->showDowntimesLink = Url::fromPath('monitoring/list/downtimes')
->setQueryString(
$this->hostList
->objectsFilter()
->andFilter(FilterEqual::where('downtime_objecttype', 'host'))
->toQueryString()
);
$this->view->commentsLink = Url::fromRequest()->setPath('monitoring/list/comments');
$this->view->baseFilter = $this->hostList->getFilter();
$this->view->sendCustomNotificationLink = Url::fromRequest()->setPath('monitoring/hosts/send-custom-notification');
} }
protected function createPieChart(array $states, $title, array $colors) /**
* Add a host comments
*/
public function addCommentAction()
{ {
$chart = new InlinePie(array_values($states), $title, $colors); $this->assertPermission('monitoring/command/comment/add');
return $chart
->setSize(75) $form = new AddCommentCommandForm();
->setTitle('') $form->setTitle($this->translate('Add Host Comments'));
->setSparklineClass('sparkline-multi'); $this->handleCommandForm($form);
}
/**
* Delete a comment
*/
public function deleteCommentAction()
{
$this->assertPermission('monitoring/command/comment/delete');
$form = new DeleteCommentCommandForm();
$form->setTitle($this->translate('Delete Host Comments'));
$this->handleCommandForm($form);
} }
/** /**

View File

@ -12,6 +12,7 @@ use Icinga\Web\Widget\Tabs;
use Icinga\Data\Filter\Filter; use Icinga\Data\Filter\Filter;
use Icinga\Web\Widget; use Icinga\Web\Widget;
use Icinga\Module\Monitoring\Forms\StatehistoryForm; use Icinga\Module\Monitoring\Forms\StatehistoryForm;
use Icinga\Data\Filterable;
class Monitoring_ListController extends Controller class Monitoring_ListController extends Controller
{ {
@ -94,8 +95,8 @@ class Monitoring_ListController extends Controller
'host_passive_checks_enabled', 'host_passive_checks_enabled',
'host_current_check_attempt', 'host_current_check_attempt',
'host_max_check_attempts' 'host_max_check_attempts'
), $this->extraColumns())); ), $this->addColumns()));
$this->filterQuery($query); $this->filterQuery($query, array('host', 'host_display_name'));
$this->applyRestriction('monitoring/hosts/filter', $query); $this->applyRestriction('monitoring/hosts/filter', $query);
$this->view->hosts = $query; $this->view->hosts = $query;
@ -177,9 +178,9 @@ class Monitoring_ListController extends Controller
'service_passive_checks_enabled', 'service_passive_checks_enabled',
'current_check_attempt' => 'service_current_check_attempt', 'current_check_attempt' => 'service_current_check_attempt',
'max_check_attempts' => 'service_max_check_attempts' 'max_check_attempts' => 'service_max_check_attempts'
), $this->extraColumns()); ), $this->addColumns());
$query = $this->backend->select()->from('serviceStatus', $columns); $query = $this->backend->select()->from('serviceStatus', $columns);
$this->filterQuery($query); $this->filterQuery($query, array('service', 'service_display_name'));
$this->applyRestriction('monitoring/services/filter', $query); $this->applyRestriction('monitoring/services/filter', $query);
$this->view->services = $query; $this->view->services = $query;
@ -497,7 +498,7 @@ class Monitoring_ListController extends Controller
))->order('services_severity')->order('servicegroup_alias'); ))->order('services_severity')->order('servicegroup_alias');
// TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and
// service groups. We should separate them. // service groups. We should separate them.
$this->filterQuery($query); $this->filterQuery($query, array('servicegroup', 'servicegroup_alias'));
$this->view->servicegroups = $query; $this->view->servicegroups = $query;
$this->setupLimitControl(); $this->setupLimitControl();
@ -554,7 +555,7 @@ class Monitoring_ListController extends Controller
))->order('services_severity')->order('hostgroup_alias'); ))->order('services_severity')->order('hostgroup_alias');
// TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and
// service groups. We should separate them. // service groups. We should separate them.
$this->filterQuery($query); $this->filterQuery($query, array('hostgroup', 'hostgroup_alias'));
$this->view->hostgroups = $query; $this->view->hostgroups = $query;
$this->setupLimitControl(); $this->setupLimitControl();
@ -625,7 +626,15 @@ class Monitoring_ListController extends Controller
$this->view->verticalPaginator = $pivot->paginateYAxis(); $this->view->verticalPaginator = $pivot->paginateYAxis();
} }
protected function filterQuery($query) /**
* Apply filters on a query
*
* @param Filterable $query The query to apply filters on
* @param array $searchColumns Columns to search in
*
* @return Filterable $query
*/
protected function filterQuery(Filterable $query, array $searchColumns = null)
{ {
$editor = Widget::create('filterEditor') $editor = Widget::create('filterEditor')
->setQuery($query) ->setQuery($query)
@ -633,8 +642,11 @@ class Monitoring_ListController extends Controller
'limit', 'sort', 'dir', 'format', 'view', 'backend', 'limit', 'sort', 'dir', 'format', 'view', 'backend',
'stateType', 'addColumns', '_dev' 'stateType', 'addColumns', '_dev'
) )
->ignoreParams('page') ->ignoreParams('page');
->handleRequest($this->getRequest()); if ($searchColumns !== null) {
$editor->setSearchColumns($searchColumns);
}
$editor->handleRequest($this->getRequest());
$query->applyFilter($editor->getFilter()); $query->applyFilter($editor->getFilter());
$this->setupFilterControl($editor); $this->setupFilterControl($editor);
@ -644,7 +656,13 @@ class Monitoring_ListController extends Controller
return $query; return $query;
} }
protected function extraColumns() /**
* Get columns to be added from URL parameter 'addColumns'
* and assign to $this->view->addColumns (as array)
*
* @return array
*/
protected function addColumns()
{ {
$columns = preg_split( $columns = preg_split(
'~,~', '~,~',
@ -652,7 +670,7 @@ class Monitoring_ListController extends Controller
-1, -1,
PREG_SPLIT_NO_EMPTY PREG_SPLIT_NO_EMPTY
); );
$this->view->extraColumns = $columns; $this->view->addColumns = $columns;
return $columns; return $columns;
} }

View File

@ -10,6 +10,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceDowntimeCommand
use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm;
use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\Service;
use Icinga\Module\Monitoring\Web\Controller\MonitoredObjectController; use Icinga\Module\Monitoring\Web\Controller\MonitoredObjectController;
use Icinga\Web\Hook;
class Monitoring_ServiceController extends MonitoredObjectController class Monitoring_ServiceController extends MonitoredObjectController
{ {
@ -48,6 +49,34 @@ class Monitoring_ServiceController extends MonitoredObjectController
$this->getTabs()->activate('service'); $this->getTabs()->activate('service');
} }
/**
* Get service actions from hook
*
* @return array
*/
protected function getServiceActions()
{
$urls = array();
foreach (Hook::all('Monitoring\\ServiceActions') as $hook) {
foreach ($hook->getActionsForService($this->object) as $id => $url) {
$urls[$id] = $url;
}
}
return $urls;
}
/**
* Show a service
*/
public function showAction()
{
$this->view->actions = $this->getServiceActions();
parent::showAction();
}
/** /**
* Acknowledge a service problem * Acknowledge a service problem
*/ */

View File

@ -10,12 +10,11 @@ use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceCheckCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceCheckCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceDowntimeCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleServiceDowntimeCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\SendCustomNotificationCommandForm;
use Icinga\Module\Monitoring\Object\Host;
use Icinga\Module\Monitoring\Object\Service;
use Icinga\Module\Monitoring\Object\ServiceList; use Icinga\Module\Monitoring\Object\ServiceList;
use Icinga\Web\Url; use Icinga\Web\Url;
use Icinga\Web\Widget\Chart\InlinePie;
use Icinga\Web\Widget\Tabextension\DashboardAction; use Icinga\Web\Widget\Tabextension\DashboardAction;
class Monitoring_ServicesController extends Controller class Monitoring_ServicesController extends Controller
@ -32,68 +31,8 @@ class Monitoring_ServicesController extends Controller
(string) $this->params->without(array('service_problem', 'service_handled', 'view')) (string) $this->params->without(array('service_problem', 'service_handled', 'view'))
)); ));
$this->serviceList = $serviceList; $this->serviceList = $serviceList;
} $this->view->listAllLink = Url::fromRequest()->setPath('monitoring/list/services');
protected function handleCommandForm(ObjectsCommandForm $form)
{
$this->serviceList->setColumns(array(
'host_name',
'host_state',
'service_description',
'service_state',
'service_problem',
'service_handled',
'service_acknowledged',
'service_in_downtime'
));
$form
->setObjects($this->serviceList)
->setRedirectUrl(Url::fromPath('monitoring/services/show')->setParams($this->params))
->handleRequest();
$serviceStates = array(
Service::getStateText(Service::STATE_OK) => 0,
Service::getStateText(Service::STATE_WARNING) => 0,
Service::getStateText(Service::STATE_CRITICAL) => 0,
Service::getStateText(Service::STATE_UNKNOWN) => 0,
Service::getStateText(Service::STATE_PENDING) => 0
);
$knownHostStates = array();
$hostStates = array(
Host::getStateText(Host::STATE_UP) => 0,
Host::getStateText(Host::STATE_DOWN) => 0,
Host::getStateText(Host::STATE_UNREACHABLE) => 0,
Host::getStateText(Host::STATE_PENDING) => 0,
);
foreach ($this->serviceList as $service) {
++$serviceStates[$service::getStateText($service->state)];
if (! isset($knownHostStates[$service->getHost()->getName()])) {
$knownHostStates[$service->getHost()->getName()] = true;
++$hostStates[$service->getHost()->getStateText($service->host_state)];
}
}
$this->view->form = $form;
$this->view->objects = $this->serviceList;
$this->view->serviceStates = $serviceStates;
$this->view->hostStates = $hostStates;
$this->view->serviceStatesPieChart = $this->createPieChart(
$serviceStates,
$this->translate('Service State'),
array('#44bb77', '#FFCC66', '#FF5566', '#E066FF', '#77AAFF')
);
$this->view->hostStatesPieChart = $this->createPieChart(
$hostStates,
$this->translate('Host State'),
array('#44bb77', '#FF5566', '#E066FF', '#77AAFF')
);
$this->_helper->viewRenderer('partials/command/objects-command-form', null, true);
return $form;
}
public function showAction()
{
$this->getTabs()->add( $this->getTabs()->add(
'show', 'show',
array( array(
@ -101,10 +40,52 @@ class Monitoring_ServicesController extends Controller
$this->translate('Show summarized information for %u services'), $this->translate('Show summarized information for %u services'),
count($this->serviceList) count($this->serviceList)
), ),
'label' => $this->translate('Services'), 'label' => $this->translate('Services') . sprintf(' (%d)', count($this->serviceList)),
'url' => Url::fromRequest() 'url' => Url::fromRequest(),
'icon' => 'services'
) )
)->extend(new DashboardAction())->activate('show'); )->extend(new DashboardAction())->activate('show');
}
protected function handleCommandForm(ObjectsCommandForm $form)
{
$this->serviceList->setColumns(array(
'host_name',
'host_output',
'host_state',
'host_problem',
'host_handled',
'service_description',
'service_state',
'service_problem',
'service_handled',
'service_acknowledged',
'service_in_downtime',
'service_is_flapping',
'service_output',
'service_last_ack',
'service_last_comment',
'service_notifications_enabled',
'service_active_checks_enabled',
'service_passive_checks_enabled'
));
$form
->setObjects($this->serviceList)
->setRedirectUrl(Url::fromPath('monitoring/services/show')->setParams($this->params))
->handleRequest();
$this->view->form = $form;
$this->view->objects = $this->serviceList;
$this->view->stats = $this->serviceList->getServiceStateSummary();
$this->view->serviceStates = true;
$this->view->hostStates = $this->serviceList->getHostStateSummary();
$this->_helper->viewRenderer('partials/command/objects-command-form', null, true);
return $form;
}
public function showAction()
{
$this->setAutorefreshInterval(15); $this->setAutorefreshInterval(15);
$checkNowForm = new CheckNowCommandForm(); $checkNowForm = new CheckNowCommandForm();
$checkNowForm $checkNowForm
@ -113,64 +94,30 @@ class Monitoring_ServicesController extends Controller
$this->view->checkNowForm = $checkNowForm; $this->view->checkNowForm = $checkNowForm;
$this->serviceList->setColumns(array( $this->serviceList->setColumns(array(
'host_name', 'host_name',
'host_output',
'host_state', 'host_state',
'host_problem',
'host_handled',
'service_output',
'service_description', 'service_description',
'service_state', 'service_state',
'service_problem', 'service_problem',
'service_handled', 'service_handled',
'service_acknowledged', 'service_acknowledged',
'service_in_downtime'/*, 'service_in_downtime',
'service_passive_checks_enabled', 'service_is_flapping',
'service_last_comment',
'service_last_ack',
'service_notifications_enabled', 'service_notifications_enabled',
'service_active_checks_enabled',
'service_passive_checks_enabled'
/*
'service_event_handler_enabled', 'service_event_handler_enabled',
'service_flap_detection_enabled', 'service_flap_detection_enabled',
'service_active_checks_enabled',
'service_obsessing'*/ 'service_obsessing'*/
)); ));
$unhandledObjects = array();
$unhandledFilterExpressions = array(); $acknowledgedObjects = $this->serviceList->getAcknowledgedObjects();
$acknowledgedObjects = array();
$objectsInDowntime = array();
$downtimeFilterExpressions = array();
$serviceStates = array(
Service::getStateText(Service::STATE_OK) => 0,
Service::getStateText(Service::STATE_WARNING) => 0,
Service::getStateText(Service::STATE_CRITICAL) => 0,
Service::getStateText(Service::STATE_UNKNOWN) => 0,
Service::getStateText(Service::STATE_PENDING) => 0
);
$knownHostStates = array();
$hostStates = array(
Host::getStateText(Host::STATE_UP) => 0,
Host::getStateText(Host::STATE_DOWN) => 0,
Host::getStateText(Host::STATE_UNREACHABLE) => 0,
Host::getStateText(Host::STATE_PENDING) => 0,
);
foreach ($this->serviceList as $service) {
/** @var Service $service */
if ((bool) $service->problem === true && (bool) $service->handled === false) {
$unhandledObjects[] = $service;
$unhandledFilterExpressions[] = Filter::matchAll(
Filter::where('host', $service->getHost()->getName()),
Filter::where('service', $service->getName())
);
}
if ((bool) $service->acknowledged === true) {
$acknowledgedObjects[] = $service;
}
if ((bool) $service->in_downtime === true) {
$objectsInDowntime[] = $service;
$downtimeFilterExpressions[] = Filter::matchAll(
Filter::where('host_name', $service->getHost()->getName()),
Filter::where('service_description', $service->getName())
);
}
++$serviceStates[$service::getStateText($service->state)];
if (! isset($knownHostStates[$service->getHost()->getName()])) {
$knownHostStates[$service->getHost()->getName()] = true;
++$hostStates[$service->getHost()->getStateText($service->host_state)];
}
}
if (! empty($acknowledgedObjects)) { if (! empty($acknowledgedObjects)) {
$removeAckForm = new RemoveAcknowledgementCommandForm(); $removeAckForm = new RemoveAcknowledgementCommandForm();
$removeAckForm $removeAckForm
@ -178,53 +125,70 @@ class Monitoring_ServicesController extends Controller
->handleRequest(); ->handleRequest();
$this->view->removeAckForm = $removeAckForm; $this->view->removeAckForm = $removeAckForm;
} }
$this->setAutorefreshInterval(15); $this->setAutorefreshInterval(15);
$this->view->listAllLink = Url::fromRequest()->setPath('monitoring/list/services');
$this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/services/reschedule-check'); $this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/services/reschedule-check');
$this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/services/schedule-downtime'); $this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/services/schedule-downtime');
$this->view->processCheckResultAllLink = Url::fromRequest()->setPath( $this->view->processCheckResultAllLink = Url::fromRequest()->setPath(
'monitoring/services/process-check-result' 'monitoring/services/process-check-result'
); );
$this->view->hostStates = $hostStates; $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/services/add-comment');
$this->view->serviceStates = $serviceStates; $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/services/delete-comment');
$this->view->stats = $this->serviceList->getServiceStateSummary();
$this->view->hostStats = $this->serviceList->getHostStateSummary();
$this->view->objects = $this->serviceList; $this->view->objects = $this->serviceList;
$this->view->unhandledObjects = $unhandledObjects; $this->view->unhandledObjects = $this->serviceList->getUnhandledObjects();
$unhandledFilterQueryString = Filter::matchAny($unhandledFilterExpressions)->toQueryString(); $this->view->problemObjects = $this->serviceList->getProblemObjects();
$this->view->acknowledgeUnhandledLink = Url::fromPath('monitoring/services/acknowledge-problem') $this->view->acknowledgeUnhandledLink = Url::fromPath('monitoring/services/acknowledge-problem')
->setQueryString($unhandledFilterQueryString); ->setQueryString($this->serviceList->getUnhandledObjects()->objectsFilter()->toQueryString());
$this->view->downtimeUnhandledLink = Url::fromPath('monitoring/services/schedule-downtime') $this->view->downtimeUnhandledLink = Url::fromPath('monitoring/services/schedule-downtime')
->setQueryString($unhandledFilterQueryString); ->setQueryString($this->serviceList->getUnhandledObjects()->objectsFilter()->toQueryString());
$this->view->downtimeLink = Url::fromPath('monitoring/services/schedule-downtime')
->setQueryString($this->serviceList->getProblemObjects()->objectsFilter()->toQueryString());
$this->view->acknowledgedObjects = $acknowledgedObjects; $this->view->acknowledgedObjects = $acknowledgedObjects;
$this->view->objectsInDowntime = $objectsInDowntime; $this->view->objectsInDowntime = $this->serviceList->getObjectsInDowntime();
$this->view->inDowntimeLink = Url::fromPath('monitoring/list/downtimes') $this->view->inDowntimeLink = Url::fromPath('monitoring/list/services')
->setQueryString(Filter::matchAny($downtimeFilterExpressions)->toQueryString()); ->setQueryString($this->serviceList->getObjectsInDowntime()
->objectsFilter(array('host' => 'host_name', 'service' => 'service_description'))->toQueryString());
$this->view->showDowntimesLink = Url::fromPath('monitoring/downtimes/show')
->setQueryString(
$this->serviceList->getObjectsInDowntime()
->objectsFilter()->toQueryString()
);
$this->view->commentsLink = Url::fromRequest() $this->view->commentsLink = Url::fromRequest()
->setPath('monitoring/list/comments'); ->setPath('monitoring/list/comments');
$this->view->serviceStatesPieChart = $this->createPieChart( $this->view->baseFilter = $this->serviceList->getFilter();
$serviceStates, $this->view->sendCustomNotificationLink = Url::fromRequest()->setPath(
$this->translate('Service State'), 'monitoring/services/send-custom-notification'
array('#44bb77', '#FFCC66', '#FF5566', '#E066FF', '#77AAFF')
); );
$this->view->hostStatesPieChart = $this->createPieChart(
$hostStates,
$this->translate('Host State'),
array('#44bb77', '#FF5566', '#E066FF', '#77AAFF')
);
$this->view->sendCustomNotificationLink =
Url::fromRequest()->setPath(
'monitoring/services/send-custom-notification'
);
} }
protected function createPieChart(array $states, $title, array $colors) /**
* Add a service comment
*/
public function addCommentAction()
{ {
$chart = new InlinePie(array_values($states), $title, $colors); $this->assertPermission('monitoring/command/comment/add');
return $chart
->setSize(75) $form = new AddCommentCommandForm();
->setTitle('') $form->setTitle($this->translate('Add Service Comments'));
->setSparklineClass('sparkline-multi'); $this->handleCommandForm($form);
} }
/**
* Delete a comment
*/
public function deleteCommentAction()
{
$this->assertPermission('monitoring/command/comment/delete');
$form = new DeleteCommentCommandForm();
$form->setTitle($this->translate('Delete Service Comments'));
$this->handleCommandForm($form);
}
/** /**
* Acknowledge service problems * Acknowledge service problems
*/ */

View File

@ -85,7 +85,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox', 'checkbox',
ToggleInstanceFeatureCommand::FEATURE_ACTIVE_HOST_CHECKS, ToggleInstanceFeatureCommand::FEATURE_ACTIVE_HOST_CHECKS,
array( array(
'label' => $this->translate('Active Host Checks Being Executed'), 'label' => $this->translate('Active Host Checks'),
'autosubmit' => true, 'autosubmit' => true,
'disabled' => $toggleDisabled 'disabled' => $toggleDisabled
) )
@ -94,7 +94,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox', 'checkbox',
ToggleInstanceFeatureCommand::FEATURE_ACTIVE_SERVICE_CHECKS, ToggleInstanceFeatureCommand::FEATURE_ACTIVE_SERVICE_CHECKS,
array( array(
'label' => $this->translate('Active Service Checks Being Executed'), 'label' => $this->translate('Active Service Checks'),
'autosubmit' => true, 'autosubmit' => true,
'disabled' => $toggleDisabled 'disabled' => $toggleDisabled
) )
@ -103,7 +103,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox', 'checkbox',
ToggleInstanceFeatureCommand::FEATURE_EVENT_HANDLERS, ToggleInstanceFeatureCommand::FEATURE_EVENT_HANDLERS,
array( array(
'label' => $this->translate('Event Handlers Enabled'), 'label' => $this->translate('Event Handlers'),
'autosubmit' => true, 'autosubmit' => true,
'disabled' => $toggleDisabled 'disabled' => $toggleDisabled
) )
@ -112,7 +112,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox', 'checkbox',
ToggleInstanceFeatureCommand::FEATURE_FLAP_DETECTION, ToggleInstanceFeatureCommand::FEATURE_FLAP_DETECTION,
array( array(
'label' => $this->translate('Flap Detection Enabled'), 'label' => $this->translate('Flap Detection'),
'autosubmit' => true, 'autosubmit' => true,
'disabled' => $toggleDisabled 'disabled' => $toggleDisabled
) )
@ -121,7 +121,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox', 'checkbox',
ToggleInstanceFeatureCommand::FEATURE_NOTIFICATIONS, ToggleInstanceFeatureCommand::FEATURE_NOTIFICATIONS,
array( array(
'label' => $this->translate('Notifications Enabled'), 'label' => $this->translate('Notifications'),
'autosubmit' => true, 'autosubmit' => true,
'description' => $notificationDescription, 'description' => $notificationDescription,
'decorators' => array( 'decorators' => array(
@ -159,7 +159,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox', 'checkbox',
ToggleInstanceFeatureCommand::FEATURE_PASSIVE_HOST_CHECKS, ToggleInstanceFeatureCommand::FEATURE_PASSIVE_HOST_CHECKS,
array( array(
'label' => $this->translate('Passive Host Checks Being Accepted'), 'label' => $this->translate('Passive Host Checks'),
'autosubmit' => true, 'autosubmit' => true,
'disabled' => $toggleDisabled 'disabled' => $toggleDisabled
) )
@ -168,7 +168,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox', 'checkbox',
ToggleInstanceFeatureCommand::FEATURE_PASSIVE_SERVICE_CHECKS, ToggleInstanceFeatureCommand::FEATURE_PASSIVE_SERVICE_CHECKS,
array( array(
'label' => $this->translate('Passive Service Checks Being Accepted'), 'label' => $this->translate('Passive Service Checks'),
'autosubmit' => true, 'autosubmit' => true,
'disabled' => $toggleDisabled 'disabled' => $toggleDisabled
) )
@ -177,7 +177,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox', 'checkbox',
ToggleInstanceFeatureCommand::FEATURE_PERFORMANCE_DATA, ToggleInstanceFeatureCommand::FEATURE_PERFORMANCE_DATA,
array( array(
'label' => $this->translate('Performance Data Being Processed'), 'label' => $this->translate('Performance Data'),
'autosubmit' => true, 'autosubmit' => true,
'disabled' => $toggleDisabled 'disabled' => $toggleDisabled
) )
@ -209,6 +209,50 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
public function onSuccess() public function onSuccess()
{ {
$this->assertPermission('monitoring/command/feature/instance'); $this->assertPermission('monitoring/command/feature/instance');
$notifications = array(
ToggleInstanceFeatureCommand::FEATURE_ACTIVE_HOST_CHECKS => array(
$this->translate('Enabling active host checks..'),
$this->translate('Disabling active host checks..')
),
ToggleInstanceFeatureCommand::FEATURE_ACTIVE_SERVICE_CHECKS => array(
$this->translate('Enabling active service checks..'),
$this->translate('Disabling active service checks..')
),
ToggleInstanceFeatureCommand::FEATURE_EVENT_HANDLERS => array(
$this->translate('Enabling event handlers..'),
$this->translate('Disabling event handlers..')
),
ToggleInstanceFeatureCommand::FEATURE_FLAP_DETECTION => array(
$this->translate('Enabling flap detection..'),
$this->translate('Disabling flap detection..')
),
ToggleInstanceFeatureCommand::FEATURE_NOTIFICATIONS => array(
$this->translate('Enabling notifications..'),
$this->translate('Disabling notifications..')
),
ToggleInstanceFeatureCommand::FEATURE_HOST_OBSESSING => array(
$this->translate('Enabling obsessing over hosts..'),
$this->translate('Disabling obsessing over hosts..')
),
ToggleInstanceFeatureCommand::FEATURE_SERVICE_OBSESSING => array(
$this->translate('Enabling obsessing over services..'),
$this->translate('Disabling obsessing over services..')
),
ToggleInstanceFeatureCommand::FEATURE_PASSIVE_HOST_CHECKS => array(
$this->translate('Enabling passive host checks..'),
$this->translate('Disabling passive host checks..')
),
ToggleInstanceFeatureCommand::FEATURE_PASSIVE_SERVICE_CHECKS => array(
$this->translate('Enabling passive service checks..'),
$this->translate('Disabling passive service checks..')
),
ToggleInstanceFeatureCommand::FEATURE_PERFORMANCE_DATA => array(
$this->translate('Enabling performance data..'),
$this->translate('Disabling performance data..')
)
);
foreach ($this->getValues() as $feature => $enabled) { foreach ($this->getValues() as $feature => $enabled) {
$toggleFeature = new ToggleInstanceFeatureCommand(); $toggleFeature = new ToggleInstanceFeatureCommand();
$toggleFeature $toggleFeature
@ -216,10 +260,9 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
->setEnabled($enabled); ->setEnabled($enabled);
$this->getTransport($this->request)->send($toggleFeature); $this->getTransport($this->request)->send($toggleFeature);
if ($this->status->{$feature} != $enabled) { if ((bool) $this->status->{$feature} !== (bool) $enabled) {
Notification::success($enabled Notification::success(
? $this->translate('Enabling feature..') $notifications[$feature][$enabled ? 0 : 1]
: $this->translate('Disabling feature..')
); );
} }
} }

View File

@ -117,6 +117,34 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm
public function onSuccess() public function onSuccess()
{ {
$this->assertPermission('monitoring/command/feature/object'); $this->assertPermission('monitoring/command/feature/object');
$notifications = array(
ToggleObjectFeatureCommand::FEATURE_ACTIVE_CHECKS => array(
$this->translate('Enabling active checks..'),
$this->translate('Disabling active checks..')
),
ToggleObjectFeatureCommand::FEATURE_PASSIVE_CHECKS => array(
$this->translate('Enabling passive checks..'),
$this->translate('Disabling passive checks..')
),
ToggleObjectFeatureCommand::FEATURE_OBSESSING => array(
$this->translate('Enabling obsessing..'),
$this->translate('Disabling obsessing..')
),
ToggleObjectFeatureCommand::FEATURE_NOTIFICATIONS => array(
$this->translate('Enabling notifications..'),
$this->translate('Disabling notifications..')
),
ToggleObjectFeatureCommand::FEATURE_EVENT_HANDLER => array(
$this->translate('Enabling event handler..'),
$this->translate('Disabling event handler..')
),
ToggleObjectFeatureCommand::FEATURE_FLAP_DETECTION => array(
$this->translate('Enabling flap detection..'),
$this->translate('Disabling flap detection..')
)
);
foreach ($this->objects as $object) { foreach ($this->objects as $object) {
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
foreach ($this->getValues() as $feature => $enabled) { foreach ($this->getValues() as $feature => $enabled) {
@ -127,10 +155,13 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm
->setObject($object) ->setObject($object)
->setEnabled($enabled); ->setEnabled($enabled);
$this->getTransport($this->request)->send($toggleFeature); $this->getTransport($this->request)->send($toggleFeature);
Notification::success(
$notifications[$feature][$enabled ? 0 : 1]
);
} }
} }
} }
Notification::success($this->translate('Toggling feature..'));
return true; return true;
} }
} }

View File

@ -0,0 +1,39 @@
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
/**
* Generate icons to describe a given hosts state
*/
class Zend_View_Helper_HostFlags extends Zend_View_Helper_Abstract
{
public function hostFlags($host)
{
$icons = array();
if (! $host->host_handled && $host->host_state > 0) {
$icons[] = $this->view->icon('attention-alt', $this->view->translate('Unhandled'));
}
if ($host->host_acknowledged) {
$icons[] = $this->view->icon('ok', $this->view->translate('Acknowledged'));
}
if ($host->host_is_flapping) {
$icons[] = $this->view->icon('flapping', $this->view->translate('Flapping'));
}
if (! $host->host_notifications_enabled) {
$icons[] = $this->view->icon('bell-off-empty', $this->view->translate('Notifications Disabled'));
}
if ($host->host_in_downtime) {
$icons[] = $this->view->icon('plug', $this->view->translate('In Downtime'));
}
if (! $host->host_active_checks_enabled) {
if (! $host->host_passive_checks_enabled) {
$icons[] = $this->view->icon('eye-off', $this->view->translate('Active And Passive Checks Disabled'));
} else {
$icons[] = $this->view->icon('eye-off', $this->view->translate('Active Checks Disabled'));
}
}
if (isset($host->host_last_comment) && $host->host_last_comment !== null) {
$icons[] = $this->view->icon('comment', $this->view->translate('Last Comment: ') . $host->host_last_comment);
}
return $icons;
}
}

View File

@ -1,24 +0,0 @@
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
class Zend_View_Helper_SelectionToolbar extends Zend_View_Helper_Abstract
{
/**
* Create a selection toolbar
*
* @param $type
* @param null $target
*
* @return string
*/
public function selectionToolbar($type, $target = null)
{
return '';
if ($type == 'multi') {
return '<div class="selection-toolbar">'
. '<a href="' . $target . '" data-base-target="_next"> Show All </a> </div>';
} else {
return '';
}
}
}

View File

@ -0,0 +1,40 @@
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
class Zend_View_Helper_ServiceFlags extends Zend_View_Helper_Abstract
{
public function serviceFlags($service) {
$icons = array();
if (!$service->service_handled && $service->service_state > 0) {
$icons[] = $this->view->icon('attention-alt', $this->view->translate('Unhandled'));
}
if ($service->service_acknowledged && !$service->service_in_downtime) {
$icons[] = $this->view->icon('ok', $this->view->translate('Acknowledged') . (
$service->service_last_ack ? ': ' . $service->service_last_ack : ''
));
}
if ($service->service_is_flapping) {
$icons[] = $this->view->icon('flapping', $this->view->translate('Flapping')) ;
}
if (!$service->service_notifications_enabled) {
$icons[] = $this->view->icon('bell-off-empty', $this->view->translate('Notifications Disabled'));
}
if ($service->service_in_downtime) {
$icons[] = $this->view->icon('plug', $this->view->translate('In Downtime'));
}
if (isset($service->service_last_comment) && $service->service_last_comment !== null) {
$icons[] = $this->view->icon(
'comment',
$this->view->translate('Last Comment: ') . $service->service_last_comment
);
}
if (!$service->service_active_checks_enabled) {
if (!$service->service_passive_checks_enabled) {
$icons[] = $this->view->icon('eye-off', $this->view->translate('Active And Passive Checks Disabled'));
} else {
$icons[] = $this->view->icon('eye-off', $this->view->translate('Active Checks Disabled'));
}
}
return $icons;
}
}

View File

@ -8,18 +8,11 @@
</div> </div>
</div> </div>
<div class="content"> <div class="content multi-commands">
<h3><?= $this->icon('reschedule') ?> <?= $this->translate('Commands') ?> </h3> <h3><?= $this->icon('reschedule') ?> <?= $this->translate('Commands') ?> </h3>
<p>
<?= sprintf(
$this->translate('Issue commands to all %s selected comments.'),
'<b>' . count($comments) . '</b>'
)
?>
<div>
<?= $this->qlink( <?= $this->qlink(
sprintf( sprintf(
$this->translate('Remove all %d scheduled comments'), $this->translate('Remove %d comments'),
count($comments) count($comments)
), ),
$removeAllLink, $removeAllLink,
@ -29,6 +22,4 @@
'title' => $this->translate('Remove all selected comments.') 'title' => $this->translate('Remove all selected comments.')
) )
) ?> ) ?>
</div>
</p>
</div> </div>

View File

@ -7,15 +7,8 @@
<?= $this->render('partials/downtime/downtimes-header.phtml'); ?> <?= $this->render('partials/downtime/downtimes-header.phtml'); ?>
</p> </p>
</div> </div>
<div class="content"> <div class="content multi-commands">
<h3><?= $this->icon('reschedule') ?> <?= $this->translate('Commands') ?> </h3> <h3><?= $this->icon('reschedule') ?> <?= $this->translate('Commands') ?> </h3>
<p>
<?= sprintf(
$this->translate('Issue commands to all %s selected downtimes.'),
'<b>' . count($downtimes) . '</b>'
)
?>
<div>
<?= $this->qlink( <?= $this->qlink(
sprintf( sprintf(
$this->translate('Remove all %d scheduled downtimes'), $this->translate('Remove all %d scheduled downtimes'),
@ -28,6 +21,4 @@
'title' => $this->translate('Remove all selected downtimes.') 'title' => $this->translate('Remove all selected downtimes.')
) )
) ?> ) ?>
</div>
</p>
</div> </div>

View File

@ -1,127 +1,231 @@
<div class="controls"> <div data-base-target='_next' class="controls">
<?php if (! $this->compact): ?> <?php if (! $this->compact): ?>
<?= $tabs; ?> <?= $tabs; ?>
<?php endif ?> <?php endif ?>
<?= $this->render('list/components/hostssummary.phtml') ?>
<?= $this->render('partials/host/objects-header.phtml'); ?> <?= $this->render('partials/host/objects-header.phtml'); ?>
</div> </div>
<div class="content">
<div class="content multi-commands">
<h3>
<?= $this->icon('reschedule') ?>
<?= $this->translate('Commands') ?>
</h3>
<p>
<?= sprintf($this->translatePlural(
'Issue commands to %s selected host:',
'Issue commands to all %s selected hosts:',
count($objects)
), '<b>' . count($objects) . '</b>') ?>
</p>
<?php if (($hostCount = count($objects)) === 0): ?> <?php if (($hostCount = count($objects)) === 0): ?>
<?= $this->translate('No hosts found matching the filter'); ?> <?= $this->translate('No hosts found matching the filter'); ?>
<?php else: ?> <?php else: ?>
<h3><?= sprintf($this->translatePlural('%u Host', '%u Hosts', $hostCount), $hostCount); ?></h3> <?= $checkNowForm; ?>
<div><?= $this->qlink(
sprintf($this->translate('List all %u hosts'), $hostCount), <br>
$listAllLink <?= $this->qlink(
); ?></div> $this->translate('Reschedule next checks'),
<div>
<?= $checkNowForm; ?>
</div>
<div><?= $this->qlink(
sprintf($this->translate('Reschedule the next check for all %u hosts'), $hostCount),
$rescheduleAllLink, $rescheduleAllLink,
null, null,
array('icon' => 'reschedule') array('icon' => 'reschedule')
); ?></div> ); ?>
<div><?= $this->qlink(
sprintf($this->translate('Schedule a downtime for all %u hosts'), $hostCount), <br>
<?= $this->qlink(
$this->translate('Schedule downtimes'),
$downtimeAllLink, $downtimeAllLink,
null, null,
array('icon' => 'plug') array('icon' => 'plug')
); ?></div> ); ?>
<div><?= $this->qlink(
sprintf($this->translate('Submit a passive check result for all %u hosts'), $hostCount), <br>
<?= $this->qlink(
$this->translate('Submit passive check results'),
$processCheckResultAllLink, $processCheckResultAllLink,
null, null,
array('icon' => 'reply') array('icon' => 'reply')
); ?></div> ); ?>
<br>
<?= $this->qlink(
$this->translate('Add comments'),
$addCommentLink,
null,
array('icon' => 'comment')
); ?>
<?php if ($this->hasPermission('monitoring/command/send-custom-notification')): ?> <?php if ($this->hasPermission('monitoring/command/send-custom-notification')): ?>
<div><?= $this->qlink( <br>
sprintf($this->translate('Send a custom notification for all %u hosts'), $hostCount), <?= $this->qlink(
$sendCustomNotificationLink, sprintf($this->translate('Send a custom notification for all %u hosts'), $hostCount),
null, $sendCustomNotificationLink,
array('icon' => 'comment') null,
); ?></div> array('icon' => 'comment')
); ?>
<?php endif; ?> <?php endif; ?>
<?php if (($unhandledCount = count($unhandledObjects)) > 0): ?>
<div> <?php
<h3><?= sprintf( $unhandledCount = count($unhandledObjects);
$this->translatePlural( $problemCount = count($problemObjects);
'%u Unhandled Host Problem', ?>
'%u Unhandled Host Problems',
$unhandledCount <?php if ($problemCount || $unhandledCount): ?>
), <h3>
$unhandledCount <?= $this->icon('attention-alt') ?>
); ?></h3> <?= $this->translatePlural(
<div><?= $this->qlink( 'Problem',
sprintf( 'Problems',
$unhandledCount + $problemCount
) ?>
</h3>
<?php if ($problemCount): ?>
<p>
<?= sprintf(
$this->translatePlural( $this->translatePlural(
'Schedule a downtime for %u unhandled host problem', 'There is %s problem.',
'Schedule a downtime for %u unhandled host problems', 'There are %s problems.',
$problemCount
),
'<b>' . $problemCount . '</b>'
); ?>
</p>
<?= $this->qlink(
sprintf(
$this->translatePlural(
'Schedule a downtime for %u problem host',
'Schedule a downtime for %u problem hosts',
$problemCount
),
$problemCount
),
$downtimeLink,
null,
array('icon' => 'plug')
); ?>
<?php endif; ?>
<?php if ($unhandledCount): ?>
<p>
<?= sprintf(
$this->translatePlural(
'There is %s unhandled problem host, issue commands to the problematic host:',
'There are %s unhandled problem hosts, issue commands to the problematic hosts:',
$unhandledCount
),
'<span class="badge badge-critical">' . $unhandledCount . '</span>'
); ?>
</p>
<?= $this->qlink(
sprintf(
$this->translatePlural(
'Schedule a downtime for %u unhandled problem host',
'Schedule a downtime for %u unhandled problem hosts',
$unhandledCount
),
$unhandledCount
),
$downtimeUnhandledLink,
null,
array('icon' => 'plug')
); ?>
<br>
<?= $this->qlink(
sprintf(
$this->translatePlural(
'Acknowledge %u unhandled problem host',
'Acknowledge %u unhandled problem hosts',
$unhandledCount
),
$unhandledCount $unhandledCount
), ),
$unhandledCount $acknowledgeUnhandledLink,
), null,
$downtimeUnhandledLink, array('icon' => 'ok')
null, ); ?>
array('icon' => 'plug')
); ?></div> <?php endif; ?>
<div><?= $this->qlink( <?php endif;?>
sprintf(
$this->translatePlural(
'Acknowledge %u unhandled host problem',
'Acknowledge %u unhandled host problems',
$unhandledCount
),
$unhandledCount
),
$acknowledgeUnhandledLink,
null,
array('icon' => 'ok')
); ?></div>
</div>
<?php endif ?>
<?php if (($acknowledgedCount = count($acknowledgedObjects)) > 0): ?> <?php if (($acknowledgedCount = count($acknowledgedObjects)) > 0): ?>
<div> <div>
<h2><?= sprintf( <h3><?= $this->icon('ok', $this->translate('Acknowledgements')) ?> <?= $this->translate('Acknowledgements') ?></h3>
<?= sprintf(
$this->translatePlural( $this->translatePlural(
'%u Acknowledged Host Problem', '%s Acknowledged Host Problem',
'%u Acknowledged Host Problems', '%s Acknowledged Host Problems',
$acknowledgedCount $acknowledgedCount
), ),
$acknowledgedCount '<b>' . $acknowledgedCount . '</b>'
); ?></h2> ); ?>
<?= $removeAckForm ?> <?= $removeAckForm ?>
</div> </div>
<?php endif ?> <?php endif ?>
<?php if (($inDowntimeCount = count($objectsInDowntime)) > 0): ?>
<h2><?= $this->qlink( <?php $scheduledDowntimeCount = count($objects->getScheduledDowntimes()) ?>
sprintf(
$this->translatePlural( <?php if ($scheduledDowntimeCount): ?>
'List %u host currently in downtime', <h3><?= $this->icon('plug', $this->translate('Downtimes'))?> <?=$this->translate('Downtimes')?></h3>
'List %u hosts currently in downtime', <?= $this->qlink(
$inDowntimeCount sprintf(
$this->translatePlural(
'%s scheduled downtime',
'%s scheduled downtimes',
$scheduledDowntimeCount
),
$scheduledDowntimeCount
), ),
$inDowntimeCount $showDowntimesLink,
), null,
$inDowntimeLink, array('data-base-target' => '_next')
null, );?>
array('icon' => 'plug') <?= sprintf($this->translate('on all selected hosts.')) ?>
); ?></h2>
<?php if (($inDowntimeCount = count($objectsInDowntime)) > 0): ?>
<br>
<?= $this->qlink(
sprintf(
$this->translatePlural(
'%s host',
'%s hosts',
$inDowntimeCount
),
$inDowntimeCount
),
$inDowntimeLink,
null,
array('data-base-target' => '_next')
); ?>
<?= $this->translate('are currently in downtime.') ?>
<?php endif; ?>
<?php endif ?> <?php endif ?>
<?php if (($commentCount = count($objects->getComments())) > 0): ?> <?php if (($commentCount = count($objects->getComments())) > 0): ?>
<h2><?= $this->qlink( <h3> <?= $this->icon('comment', $this->translate('Comments'))?> <?=$this->translate('Comments') ?></h3>
<?= $this->qlink(
sprintf( sprintf(
$this->translatePlural( $this->translatePlural(
'List %u host comment', '%s comment',
'List %u host comments', '%s comments',
$commentCount $commentCount
), ),
$commentCount $commentCount
), ),
$commentsLink, $commentsLink,
null, null,
array('icon' => 'comment') array('data-base-target' => '_next')
); ?></h2> ); ?>
<?= $this->translate('on all selected hosts.') ?>
<?php endif ?> <?php endif ?>
<?php endif ?> <?php endif ?>
</div> </div>

View File

@ -1,7 +1,17 @@
<?php <?php
use Icinga\Web\Url; use Icinga\Web\Url;
use Icinga\Data\Filter\Filter;
function urlAddFilterOptional($url, $filter, $optional) {
$url = Url::fromPath($url);
$f = $filter;
if (isset($optional)) {
$f = Filter::matchAll($filter, $optional);
}
return $url->setQueryString($f->toQueryString());
}
$this->baseFilter = isset($this->baseFilter) ? $this->baseFilter : null;
$selfUrl = 'monitoring/list/hosts'; $selfUrl = 'monitoring/list/hosts';
$currentUrl = Url::fromRequest()->getRelativeUrl(); $currentUrl = Url::fromRequest()->getRelativeUrl();
?><div class="tinystatesummary" <?= $this->compact ? ' data-base-target="col1"' : ''; ?>> ?><div class="tinystatesummary" <?= $this->compact ? ' data-base-target="col1"' : ''; ?>>
@ -10,17 +20,22 @@ $currentUrl = Url::fromRequest()->getRelativeUrl();
<?php if ($this->stats->hosts_up): ?> <?php if ($this->stats->hosts_up): ?>
<span class="state ok<?= $currentUrl === Url::fromPath($selfUrl, array('host_state' => 0))->getRelativeUrl() ? ' active' : ''; ?>"> <span class="state ok<?= $currentUrl === Url::fromPath($selfUrl, array('host_state' => 0))->getRelativeUrl() ? ' active' : ''; ?>">
<?= $this->qlink( <?= $this->qlink(
$this->stats->hosts_up, $this->stats->hosts_up,
$selfUrl, urlAddFilterOptional(
array('host_state' => 0), $selfUrl,
array('title' => sprintf( Filter::where('host_state', 0),
$this->translatePlural( $this->baseFilter
'List %u host that is currently in state UP',
'List %u hosts which are currently in state UP',
$this->stats->hosts_up
), ),
$this->stats->hosts_up null,
)) array('title' => sprintf(
$this->translatePlural(
'List %u host that is currently in state UP',
'List %u hosts which are currently in state UP',
$this->stats->hosts_up
),
$this->stats->hosts_up
)
)
); ?> ); ?>
</span> </span>
<?php endif; ?> <?php endif; ?>
@ -29,11 +44,12 @@ $currentUrl = Url::fromRequest()->getRelativeUrl();
<span class="state critical<?= $currentUrl === Url::fromPath($selfUrl, array('host_state' => 1, 'host_unhandled' => 1))->getRelativeUrl() ? ' active' : ''; ?>"> <span class="state critical<?= $currentUrl === Url::fromPath($selfUrl, array('host_state' => 1, 'host_unhandled' => 1))->getRelativeUrl() ? ' active' : ''; ?>">
<?= $this->qlink( <?= $this->qlink(
$this->stats->hosts_down_unhandled, $this->stats->hosts_down_unhandled,
$selfUrl, urlAddFilterOptional(
array( $selfUrl,
'host_state' => 1, Filter::matchAll(Filter::where('host_state', 1), Filter::where('host_unhandled', 1)),
'host_unhandled' => 1 $this->baseFilter
), ),
null,
array('title' => sprintf( array('title' => sprintf(
$this->translatePlural( $this->translatePlural(
'List %u host that is currently in state DOWN', 'List %u host that is currently in state DOWN',
@ -49,11 +65,12 @@ $currentUrl = Url::fromRequest()->getRelativeUrl();
<span class="state handled critical<?= $currentUrl === Url::fromPath($selfUrl, array('host_state' => 1, 'host_unhandled' =>0))->getRelativeUrl() ? ' active' : ''; ?>"> <span class="state handled critical<?= $currentUrl === Url::fromPath($selfUrl, array('host_state' => 1, 'host_unhandled' =>0))->getRelativeUrl() ? ' active' : ''; ?>">
<?= $this->qlink( <?= $this->qlink(
$this->stats->hosts_down_handled, $this->stats->hosts_down_handled,
$selfUrl, urlAddFilterOptional(
array( $selfUrl,
'host_state' => 1, Filter::matchAll(Filter::where('host_state', 1), Filter::where('host_unhandled', 0)),
'host_unhandled' => 0 $this->baseFilter
), ),
null,
array('title' => sprintf( array('title' => sprintf(
$this->translatePlural( $this->translatePlural(
'List %u host that is currently in state DOWN (Acknowledged)', 'List %u host that is currently in state DOWN (Acknowledged)',
@ -74,11 +91,12 @@ $currentUrl = Url::fromRequest()->getRelativeUrl();
<span class="state unknown<?= $currentUrl === Url::fromPath($selfUrl, array('host_state' => 2, 'host_unhandled' => 1))->getRelativeUrl() ? ' active' : ''; ?>"> <span class="state unknown<?= $currentUrl === Url::fromPath($selfUrl, array('host_state' => 2, 'host_unhandled' => 1))->getRelativeUrl() ? ' active' : ''; ?>">
<?= $this->qlink( <?= $this->qlink(
$this->stats->hosts_unreachable_unhandled, $this->stats->hosts_unreachable_unhandled,
$selfUrl, urlAddFilterOptional(
array( $selfUrl,
'host_state' => 2, Filter::matchAll(Filter::where('host_state', 2), Filter::where('host_unhandled', 1)),
'host_unhandled' => 1 $this->baseFilter
), ),
null,
array('title' => sprintf( array('title' => sprintf(
$this->translatePlural( $this->translatePlural(
'List %u host that is currently in state UNREACHABLE', 'List %u host that is currently in state UNREACHABLE',
@ -94,11 +112,12 @@ $currentUrl = Url::fromRequest()->getRelativeUrl();
<span class="state handled unknown<?= $currentUrl === Url::fromPath($selfUrl, array('host_state' => 2, 'host_unhandled' => 0))->getRelativeUrl() ? ' active' : '' ?>"> <span class="state handled unknown<?= $currentUrl === Url::fromPath($selfUrl, array('host_state' => 2, 'host_unhandled' => 0))->getRelativeUrl() ? ' active' : '' ?>">
<?= $this->qlink( <?= $this->qlink(
$this->stats->hosts_unreachable_handled, $this->stats->hosts_unreachable_handled,
$selfUrl, urlAddFilterOptional(
array( $selfUrl,
'host_state' => 2, Filter::matchAll(Filter::where('host_state', 2), Filter::where('host_unhandled', 0)),
'host_unhandled' => 0 $this->baseFilter
), ),
null,
array('title' => sprintf( array('title' => sprintf(
$this->translatePlural( $this->translatePlural(
'List %u host that is currently in state UNREACHABLE (Acknowledged)', 'List %u host that is currently in state UNREACHABLE (Acknowledged)',
@ -119,8 +138,12 @@ $currentUrl = Url::fromRequest()->getRelativeUrl();
<span class="state pending<?= $currentUrl === Url::fromPath($selfUrl, array('host_state' => 99))->getRelativeUrl() ? ' active' : ''; ?>"> <span class="state pending<?= $currentUrl === Url::fromPath($selfUrl, array('host_state' => 99))->getRelativeUrl() ? ' active' : ''; ?>">
<?= $this->qlink( <?= $this->qlink(
$this->stats->hosts_pending, $this->stats->hosts_pending,
$selfUrl, urlAddFilterOptional(
array('host_state' => 99), $selfUrl,
Filter::where('host_state', 99),
$this->baseFilter
),
null,
array('title' => sprintf( array('title' => sprintf(
$this->translatePlural( $this->translatePlural(
'List %u host that is currently in state PENDING', 'List %u host that is currently in state PENDING',

View File

@ -1,8 +1,19 @@
<?php <?php
use Icinga\Data\Filter\Filter;
use Icinga\Web\Url; use Icinga\Web\Url;
use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\Service;
function urlAddFilterOptional($url, $filter, $optional) {
$url = Url::fromPath($url);
$f = $filter;
if (isset($optional)) {
$f = Filter::matchAll($filter, $optional);
}
return $url->setQueryString($f->toQueryString());
}
$this->baseFilter = isset($this->baseFilter) ? $this->baseFilter : null;
$selfUrl = 'monitoring/list/services'; $selfUrl = 'monitoring/list/services';
$currentUrl = Url::fromRequest()->getRelativeUrl(); $currentUrl = Url::fromRequest()->getRelativeUrl();
?><div class="tinystatesummary" <?= $this->compact ? ' data-base-target="col1"' : ''; ?>> ?><div class="tinystatesummary" <?= $this->compact ? ' data-base-target="col1"' : ''; ?>>
@ -10,19 +21,21 @@ $currentUrl = Url::fromRequest()->getRelativeUrl();
<span class="badges"> <span class="badges">
<?php if ($this->stats->services_ok): ?> <?php if ($this->stats->services_ok): ?>
<span class="state ok<?= $currentUrl === Url::fromPath($selfUrl, array('service_state' => 0))->getRelativeUrl() ? ' active' : ''; ?>"> <span class="state ok<?= $currentUrl === Url::fromPath($selfUrl, array('service_state' => 0))->getRelativeUrl() ? ' active' : ''; ?>">
<?= $this->qlink( <?=
$this->stats->services_ok, $this->qlink(
$selfUrl, $this->stats->services_ok,
array('service_state' => 0), urlAddFilterOptional($selfUrl, Filter::where('service_state', 0), $this->baseFilter),
array('title' => sprintf( null,
$this->translatePlural( array('title' => sprintf(
'List %u service that is currently in state OK', $this->translatePlural(
'List %u services which are currently in state OK', 'List %u service that is currently in state OK',
'List %u services which are currently in state OK',
$this->stats->services_ok
),
$this->stats->services_ok $this->stats->services_ok
), ))
$this->stats->services_ok );
)) ?>
); ?>
</span> </span>
<?php endif ?> <?php endif ?>
<?php <?php
@ -31,12 +44,18 @@ foreach (array(2 => 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $
if ($this->stats->$pre) { if ($this->stats->$pre) {
$handled = $pre . '_handled'; $handled = $pre . '_handled';
$unhandled = $pre . '_unhandled'; $unhandled = $pre . '_unhandled';
$paramsHandled = array('service_state' => $stateId, 'service_handled' => 1); $paramsHandled = Filter::matchAll(
$paramsUnhandled = array('service_state' => $stateId, 'service_handled' => 0); Filter::where('service_state', $stateId),
Filter::where('service_handled', 1)
);
$paramsUnhandled = Filter::matchAll(
Filter::where('service_state', $stateId),
Filter::where('service_handled', 0)
);
if ($this->stats->$unhandled) { if ($this->stats->$unhandled) {
$compareUrl = Url::fromPath($selfUrl, $paramsUnhandled)->getRelativeUrl(); $compareUrl = Url::fromPath($selfUrl)->setQueryString($paramsUnhandled->toQueryString())->getRelativeUrl();
} else { } else {
$compareUrl = Url::fromPath($selfUrl, $paramsHandled)->getRelativeUrl(); $compareUrl = Url::fromPath($selfUrl)->setQueryString($paramsUnhandled->toQueryString())->getRelativeUrl();
} }
if ($compareUrl === $currentUrl) { if ($compareUrl === $currentUrl) {
@ -50,8 +69,8 @@ foreach (array(2 => 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $
echo $this->qlink( echo $this->qlink(
$this->stats->$unhandled, $this->stats->$unhandled,
$selfUrl, urlAddFilterOptional($selfUrl, $paramsUnhandled, $this->baseFilter),
$paramsUnhandled, null,
array('title' => sprintf( array('title' => sprintf(
$this->translatePlural( $this->translatePlural(
'List %u service that is currently in state %s', 'List %u service that is currently in state %s',
@ -65,7 +84,7 @@ foreach (array(2 => 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $
} }
if ($this->stats->$handled) { if ($this->stats->$handled) {
if (Url::fromPath($selfUrl, $paramsHandled)->getRelativeUrl() === $currentUrl) { if (Url::fromPath($selfUrl)->setQueryString($paramsHandled->toQueryString())->getRelativeUrl() === $currentUrl) {
$active = ' active'; $active = ' active';
} else { } else {
$active = ''; $active = '';
@ -75,8 +94,8 @@ foreach (array(2 => 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $
} }
echo $this->qlink( echo $this->qlink(
$this->stats->$handled, $this->stats->$handled,
$selfUrl, urlAddFilterOptional($selfUrl, $paramsHandled, $this->baseFilter),
$paramsHandled, null,
array('title' => sprintf( array('title' => sprintf(
$this->translatePlural( $this->translatePlural(
'List %u service that is currently in state %s (Acknowledged)', 'List %u service that is currently in state %s (Acknowledged)',
@ -99,8 +118,8 @@ foreach (array(2 => 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $
<span class="state pending<?= $currentUrl === Url::fromPath($selfUrl, array('service_state' => 99))->getRelativeUrl() ? ' active' : ''; ?>"> <span class="state pending<?= $currentUrl === Url::fromPath($selfUrl, array('service_state' => 99))->getRelativeUrl() ? ' active' : ''; ?>">
<?= $this->qlink( <?= $this->qlink(
$this->stats->services_pending, $this->stats->services_pending,
$selfUrl, urlAddFilterOptional($selfUrl, Filter::where('service_state', 99), $this->baseFilter),
array('service_state' => 99), null,
array('title' => sprintf( array('title' => sprintf(
$this->translatePlural( $this->translatePlural(
'List %u service that is currently in state PENDING', 'List %u service that is currently in state PENDING',

View File

@ -11,7 +11,6 @@ if (! $this->compact): ?>
<?= $this->sortBox; ?> <?= $this->sortBox; ?>
<?= $this->limiter; ?> <?= $this->limiter; ?>
<?= $this->paginator; ?> <?= $this->paginator; ?>
<?= $this->selectionToolbar('multi', $this->href('monitoring/hosts/show?' . $this->filter->toQueryString())); ?>
<?= $this->filterEditor; ?> <?= $this->filterEditor; ?>
</div> </div>
<?php endif ?> <?php endif ?>
@ -36,38 +35,7 @@ if (count($hosts) === 0) {
$hostStateName = Host::getStateText($host->host_state); $hostStateName = Host::getStateText($host->host_state);
$hostLink = $this->href('monitoring/host/show', array('host' => $host->host_name)); $hostLink = $this->href('monitoring/host/show', array('host' => $host->host_name));
$icons = array();
if (! $host->host_handled && $host->host_state > 0){
$icons[] = $this->icon('attention-alt', $this->translate('Unhandled'));
}
if ($host->host_acknowledged) {
$icons[] = $this->icon('ok', $this->translate('Acknowledged'));
}
if ($host->host_is_flapping) {
$icons[] = $this->icon('flapping', $this->translate('Flapping'));
}
if (! $host->host_notifications_enabled) {
$icons[] = $this->icon('bell-off-empty', $this->translate('Notifications Disabled'));
}
if ($host->host_in_downtime) {
$icons[] = $this->icon('plug', $this->translate('In Downtime'));
}
if (! $host->host_active_checks_enabled) {
if (! $host->host_passive_checks_enabled) {
$icons[] = $this->icon('eye-off', $this->translate('Active And Passive Checks Disabled'));
} else {
$icons[] = $this->icon('eye-off', $this->translate('Active Checks Disabled'));
}
}
if (isset($host->host_last_comment) && $host->host_last_comment !== null) {
$icons[] = $this->icon('comment', $this->translate('Last Comment: ') . $host->host_last_comment);
}
?> ?>
<tr class="state <?= $hostStateName ?><?= $host->host_handled ? ' handled' : '' ?>"> <tr class="state <?= $hostStateName ?><?= $host->host_handled ? ' handled' : '' ?>">
<!-- State --> <!-- State -->
@ -87,7 +55,7 @@ if (count($hosts) === 0) {
<?php if ($host->host_icon_image && ! preg_match('/[\'"]/', $host->host_icon_image)): ?> <?php if ($host->host_icon_image && ! preg_match('/[\'"]/', $host->host_icon_image)): ?>
<?= $this->icon($this->resolveMacros($host->host_icon_image, $host)) ?> <?= $this->icon($this->resolveMacros($host->host_icon_image, $host)) ?>
<?php endif ?> <?php endif ?>
<?= implode(' ', $icons) ?> <?= implode(' ', $this->hostFlags($host)) ?>
<?= $this->qlink( <?= $this->qlink(
$host->host_display_name, $host->host_display_name,
$hostLink, $hostLink,
@ -124,7 +92,7 @@ if (count($hosts) === 0) {
<?php endif ?> <?php endif ?>
<p class="pluginoutput"><?= $this->escape($this->ellipsis($host->host_output, 10000)) ?></p> <p class="pluginoutput"><?= $this->escape($this->ellipsis($host->host_output, 10000)) ?></p>
</td> </td>
<?php foreach($this->extraColumns as $col): ?> <?php foreach($this->addColumns as $col): ?>
<td><?= $this->escape($host->$col) ?></td> <td><?= $this->escape($host->$col) ?></td>
<?php endforeach ?> <?php endforeach ?>
</tr> </tr>

View File

@ -59,39 +59,7 @@ if (count($services) === 0) {
<td> <td>
<div class="sparkline-box"><?= $this->perfdata($service->service_perfdata, true, 8) ?> </div> <div class="sparkline-box"><?= $this->perfdata($service->service_perfdata, true, 8) ?> </div>
<?php if (!$service->service_handled && $service->service_state > 0): ?> <?= implode(' ', $this->serviceFlags($service)); ?>
<?= $this->icon('attention-alt', $this->translate('Unhandled')) ?>
<?php endif ?>
<?php if ($service->service_acknowledged && !$service->service_in_downtime): ?>
<?= $this->icon('ok', $this->translate('Acknowledged') . (
$service->service_last_ack ? ': ' . $service->service_last_ack : ''
)) ?>
<?php endif ?>
<?php if ($service->service_is_flapping): ?>
<?= $this->icon('flapping', $this->translate('Flapping')) ?>
<?php endif ?>
<?php if (!$service->service_notifications_enabled): ?>
<?= $this->icon('bell-off-empty', $this->translate('Notifications Disabled')) ?>
<?php endif ?>
<?php if ($service->service_in_downtime): ?>
<?= $this->icon('plug', $this->translate('In Downtime')) ?>
<?php endif ?>
<?php if (isset($service->service_last_comment) && $service->service_last_comment !== null): ?>
<?= $this->icon('comment', $this->translate('Last Comment: ') . $service->service_last_comment) ?>
<?php endif ?>
<?php if (!$service->service_active_checks_enabled): ?>
<?php if (!$service->service_passive_checks_enabled): ?>
<?= $this->icon('eye-off', $this->translate('Active And Passive Checks Disabled')) ?>
<?php else: ?>
<?= $this->icon('eye-off', $this->translate('Active Checks Disabled')) ?>
<?php endif ?>
<?php endif ?>
<?php if ($service->service_icon_image && ! preg_match('/[\'"]/', $service->service_icon_image)): ?> <?php if ($service->service_icon_image && ! preg_match('/[\'"]/', $service->service_icon_image)): ?>
<?= $this->icon($this->resolveMacros($service->service_icon_image, $service)) ?> <?= $this->icon($this->resolveMacros($service->service_icon_image, $service)) ?>
@ -113,7 +81,7 @@ if (count($services) === 0) {
); ?><?php endif ?><br> ); ?><?php endif ?><br>
<p class="pluginoutput"><?= $this->escape($this->ellipsis($service->service_output, 10000)); ?></p> <p class="pluginoutput"><?= $this->escape($this->ellipsis($service->service_output, 10000)); ?></p>
</td> </td>
<?php foreach($this->extraColumns as $col): ?> <?php foreach($this->addColumns as $col): ?>
<td><?= $this->escape($service->$col) ?></td> <td><?= $this->escape($service->$col) ?></td>
<?php endforeach ?> <?php endforeach ?>
</tr> </tr>

View File

@ -1,31 +1,19 @@
<div class="controls"> <div class="controls">
<?php if (! $this->compact): ?>
<?= $tabs; ?>
<?php endif ?>
<?php if (isset($serviceStates)): ?> <?php if (isset($serviceStates)): ?>
<?= $this->render('list/components/servicesummary.phtml') ?>
<?= $this->render('partials/service/objects-header.phtml'); ?> <?= $this->render('partials/service/objects-header.phtml'); ?>
<?php else: ?> <?php else: ?>
<?= $this->render('list/components/hostssummary.phtml') ?>
<?= $this->render('partials/host/objects-header.phtml'); ?> <?= $this->render('partials/host/objects-header.phtml'); ?>
<?php endif ?> <?php endif ?>
</div> </div>
<div class="content objects-command"> <div class="content objects-command">
<table class="objectlist">
<thead>
<tr>
<th><?= $this->icon('host'); ?> <?= $this->translate('Host'); ?></th>
<th><?= $this->icon('conf'); ?> <?= $this->translate('Service'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($form->getObjects() as $object): /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ ?>
<tr>
<?php if ($object->getType() === $object::TYPE_HOST): ?>
<td colspan="2"><?= $this->escape($object->getName()); ?></td>
<?php else: ?>
<td><?= $this->escape($object->getHost()->getName()); ?></td>
<td><?= $this->escape($object->getName()); ?></td>
<?php endif ?>
</tr>
<?php endforeach ?>
</tbody>
</table>
<hr class="command-separator"> <hr class="command-separator">
<?= $form; ?> <?= $form; ?>
</div> </div>

View File

@ -18,13 +18,15 @@
</table> </table>
<p> <p>
<?php if ($i > 5): ?>
<?= $this->qlink( <?= $this->qlink(
sprintf($this->translate('List all %d comments …'), count($comments)), sprintf($this->translate('show all %d comments'), $i),
$listAllLink, $listAllLink,
null, null,
array( array(
'title' => $this->translate('List all'), 'icon' => $i > 5 ? 'down-open' : '',
'data-base-target' => "_next" 'data-base-target' => "_next"
) )
) ?> ) ?>
<?php endif ?>
</p> </p>

View File

@ -79,14 +79,16 @@
</tbody> </tbody>
</table> </table>
<p> <p>
<?php if ($i > 5): ?>
<?= $this->qlink( <?= $this->qlink(
sprintf($this->translate('List all %d downtimes …'), count($downtimes)), sprintf($this->translate('show all %d downtimes'), $i),
$listAllLink, $listAllLink,
null, null,
array( array(
'title' => $this->translate('List all'), 'icon' => $i > 5 ? 'down-open' : '',
'data-base-target' => "_next" 'data-base-target' => "_next"
) )
) ?> ) ?>
<?php endif ?>
</p> </p>

View File

@ -1,13 +1,44 @@
<?php
use Icinga\Module\Monitoring\Object\Host;
$i = 0;
?>
<?php if (($hostCount = count($objects)) > 0): ?> <?php if (($hostCount = count($objects)) > 0): ?>
<div class="hbox-item"> <table class="action state statesummary">
<strong><?= sprintf($this->translatePlural('Host (%u)', 'Hosts (%u)', $hostCount), $hostCount); ?></strong> <tbody>
</div> <?php foreach ($objects as $host): /** @var Host $host */ ?>
<div class="hbox-item"> <?php
&nbsp;<?= $hostStatesPieChart; ?> if (++ $i > 5) {
</div> continue;
<div class="hbox-item" style="font-size: 14px"> }
<?php foreach (array_filter($hostStates) as $text => $count): ?> ?>
<?= sprintf('%s: %u', $this->translate(strtoupper($text)), $count); ?><br>
<?php endforeach ?> <tr class="state <?= Host::getStateText($host->host_state); ?><?= $host->host_handled ? ' handled' : '' ?>">
</div> <td class="state"><?= Host::getStateText($host->host_state, true); ?><br /></td>
<?php endif ?> <td>
<?= implode(' ', $this->hostFlags($host)) ?>
<b><?= $this->escape($host->getName()); ?></b><br>
<?= $this->escape($host->host_output) ?>
</td>
</tr>
<?php endforeach ?>
</tbody>
</table>
<div class="hbox-item multi-commands">
<?php if ($i > 5): ?>
<?=
$this->qlink(
sprintf($this->translate('show all %d hosts'), $i),
$listAllLink,
null,
array(
'icon' => 'down-open',
'data-base-target' => '_next'
)
);
?>
<?php endif ?>
</div>
<?php endif ?>

View File

@ -3,6 +3,15 @@
use Icinga\Web\Url; use Icinga\Web\Url;
use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\Service;
function urlAddFilterOptional($url, $filter, $optional) {
$url = Url::fromPath($url);
$f = $filter;
if (isset($optional)) {
$f = Filter::matchAll($filter, $optional);
}
return $url->setQueryString($f->toQueryString());
}
$selfUrl = Url::fromPath('monitoring/show/services', array('host' => $object->host_name)); $selfUrl = Url::fromPath('monitoring/show/services', array('host' => $object->host_name));
$currentUrl = Url::fromRequest()->without('limit')->getRelativeUrl(); $currentUrl = Url::fromRequest()->without('limit')->getRelativeUrl();
?><div class="tinystatesummary" <?= $this->compact ? ' data-base-target="col1"' : ''; ?>> ?><div class="tinystatesummary" <?= $this->compact ? ' data-base-target="col1"' : ''; ?>>
@ -31,6 +40,7 @@ $currentUrl = Url::fromRequest()->without('limit')->getRelativeUrl();
<?php else: ?> <?php else: ?>
<?= $this->translate('No services configured on this host'); ?> <?= $this->translate('No services configured on this host'); ?>
<?php endif; ?> <?php endif; ?>
<span class="badges"> <span class="badges">
<?php if ($object->stats->services_ok): ?> <?php if ($object->stats->services_ok): ?>
<span class="state ok<?= $currentUrl === $selfUrl->with('service_state', 0)->getRelativeUrl() ? ' active' : ''; ?>"> <span class="state ok<?= $currentUrl === $selfUrl->with('service_state', 0)->getRelativeUrl() ? ' active' : ''; ?>">

View File

@ -1,29 +1,44 @@
<?php
use Icinga\Module\Monitoring\Object\Service;
$i = 0;
?>
<?php if (($serviceCount = count($objects)) > 0): ?> <?php if (($serviceCount = count($objects)) > 0): ?>
<div class="hbox"> <table class='action state statesummary'>
<div class="hbox-item" style="width: 6em;"> <tbody>
<strong><?= sprintf($this->translatePlural('Service (%u)', 'Services (%u)', $serviceCount), $serviceCount); ?></strong> <?php foreach ($objects as $service): /** @var Service $service */ ?>
<?php
if (++ $i > 5) {
continue;
}
?>
<tr class="state <?= Service::getStateText($service->service_state); ?><?= $service->service_handled ? ' handled' : '' ?>">
<td class="state"><?= Service::getStateText($service->service_state, true); ?><br /></td>
<td>
<?= implode(' ', $this->serviceFlags($service)) ?>
<b>
<?= $this->escape($service->getName()); ?>
<?= $this->translate('on') ?>
<?= $this->escape($service->getHost()->getName()); ?><br>
</b>
<?= $this->escape($service->service_output) ?>
</td>
</tr>
<?php endforeach ?>
</tbody>
</table>
<div class="hbox-item multi-commands">
<?php if ($i > 5): ?>
<?= $this->qlink(
sprintf($this->translate('show all %d services'), $i),
$listAllLink,
null,
array(
'icon' => 'down-open',
'data-base-target' => '_next'
)
);
?>
<?php endif ?>
</div> </div>
<div class="hbox-item"> <?php endif ?>
&nbsp;<?= $serviceStatesPieChart; ?>
</div>
<div class="hbox-item" style="font-size: 14px">
<?php foreach (array_filter($serviceStates) as $text => $count): ?>
<?= sprintf('%s: %u', $this->translate(strtoupper($text)), $count); ?><br>
<?php endforeach ?>
</div>
</div>
<div class="hbox">
<div class="hbox-item" style="width: 6em;">
<?php $hostCount = array_sum(array_values($hostStates)); ?>
<strong><?= sprintf($this->translatePlural('Host (%u)', 'Hosts (%u)', $hostCount), $hostCount); ?></strong>
</div>
<div class="hbox-item">
&nbsp;<?= $hostStatesPieChart; ?>
</div>
<div class="hbox-item" style="font-size: 14px">
<?php foreach (array_filter($hostStates) as $text => $count): ?>
<?= sprintf('%s: %u', $this->translate(strtoupper($text)), $count); ?><br>
<?php endforeach ?>
</div>
</div>
<?php endif ?>

View File

@ -1,127 +1,214 @@
<div class="controls"> <div data-base-target='_next' class="controls">
<?php if (! $this->compact): ?>
<?= $tabs; ?> <?php if (! $this->compact): ?>
<?php endif ?> <?= $tabs; ?>
<?php endif ?>
<?= $this->render('list/components/servicesummary.phtml') ?>
<?= $this->render('partials/service/objects-header.phtml'); ?> <?= $this->render('partials/service/objects-header.phtml'); ?>
</div> </div>
<div class="content"> <div class="content multi-commands">
<h3>
<?= $this->icon('reschedule') ?>
<?= $this->translate('Commands') ?>
</h3>
<?php if (($serviceCount = count($objects)) === 0): ?> <?php if (($serviceCount = count($objects)) === 0): ?>
<?= $this->translate('No services found matching the filter'); ?> <?= $this->translate('No services found matching the filter'); ?>
<?php else: ?> <?php else: ?>
<h3><?= sprintf($this->translatePlural('%u Service', '%u Services', $serviceCount), $serviceCount); ?></h3> <p>
<div><?= $this->qlink( <?= sprintf($this->translatePlural(
sprintf($this->translate('List all %u services'), $serviceCount), 'Issue commands to %s selected service:',
$listAllLink 'Issue commands to all %s selected services:',
); ?></div> count($objects)
<div> ), '<b>' . count($objects) . '</b>') ?>
<?= $checkNowForm; ?> </p>
</div> <?= $checkNowForm; ?>
<div><?= $this->qlink( <br>
sprintf($this->translate('Reschedule the next check for all %u services'), $serviceCount), <?= $this->qlink(
$this->translate('Reschedule next checks'),
$rescheduleAllLink, $rescheduleAllLink,
null, null,
array('icon' => 'reschedule') array('icon' => 'reschedule')
); ?></div> ); ?>
<div><?= $this->qlink(
sprintf($this->translate('Schedule a downtime for all %u services'), $serviceCount), <br>
<?= $this->qlink(
$this->translate('Schedule downtimes'),
$downtimeAllLink, $downtimeAllLink,
null, null,
array('icon' => 'plug') array('icon' => 'plug')
); ?></div> ); ?>
<div><?= $this->qlink(
sprintf($this->translate('Submit a passive check result for all %u services'), $serviceCount), <br>
<?= $this->qlink(
$this->translate('Submit passive check results'),
$processCheckResultAllLink, $processCheckResultAllLink,
null, null,
array('icon' => 'reply') array('icon' => 'reply')
); ?></div> ); ?>
<?php if ($this->hasPermission('monitoring/command/send-custom-notification')): ?>
<div><?= $this->qlink( <br>
sprintf($this->translate('Send a custom notification for all %u services'), $serviceCount), <?= $this->qlink(
$sendCustomNotificationLink, $this->translate('Add comments'),
null, $addCommentLink,
array('icon' => 'comment')
); ?></div>
<?php endif; ?>
<?php if (($unhandledCount = count($unhandledObjects)) > 0): ?>
<div>
<h3><?= sprintf(
$this->translatePlural(
'%u Unhandled Service Problem',
'%u Unhandled Service Problems',
$unhandledCount
),
$unhandledCount
); ?></h3>
<div><?= $this->qlink(
sprintf(
$this->translatePlural(
'Schedule a downtime for %u unhandled service problem',
'Schedule a downtime for %u unhandled service problems',
$unhandledCount
),
$unhandledCount
),
$downtimeUnhandledLink,
null,
array('icon' => 'plug')
); ?></div>
<div><?= $this->qlink(
sprintf(
$this->translatePlural(
'Acknowledge %u unhandled service problem',
'Acknowledge %u unhandled service problems',
$unhandledCount
),
$unhandledCount
),
$acknowledgeUnhandledLink,
null,
array('icon' => 'ok')
); ?></div>
</div>
<?php endif ?>
<?php if (($acknowledgedCount = count($acknowledgedObjects)) > 0): ?>
<div>
<h2><?= sprintf(
$this->translatePlural(
'%u Acknowledged Service Problem',
'%u Acknowledged Service Problems',
$acknowledgedCount
),
$acknowledgedCount
); ?></h2>
<?= $removeAckForm ?>
</div>
<?php endif ?>
<?php if (($inDowntimeCount = count($objectsInDowntime)) > 0): ?>
<h2><?= $this->qlink(
sprintf(
$this->translatePlural(
'List %u service currently in downtime',
'List %u services currently in downtime',
$inDowntimeCount
),
$inDowntimeCount
),
$inDowntimeLink,
null,
array('icon' => 'plug')
); ?></h2>
<?php endif ?>
<?php if (($commentCount = count($objects->getComments())) > 0): ?>
<h2><?= $this->qlink(
sprintf(
$this->translatePlural(
'List %u service comment',
'List %u service comments',
$commentCount
),
$commentCount
),
$commentsLink,
null, null,
array('icon' => 'comment') array('icon' => 'comment')
); ?></h2> ); ?>
<?php endif ?>
<?php if ($this->hasPermission('monitoring/command/send-custom-notification')): ?>
<br>
<?= $this->qlink(
sprintf($this->translate('Send a custom notification for all %u services'), $serviceCount),
$sendCustomNotificationLink,
null,
array('icon' => 'comment')
); ?>
<?php endif; ?>
<?php
$unhandledCount = count($unhandledObjects);
$problemCount = count($problemObjects);
?>
<?php if ($problemCount || $unhandledCount): ?>
<div>
<h3>
<?= $this->icon('attention-alt') ?>
<?= $this->translate('Problems') ?>
</h3>
<?php if ($problemCount): ?>
<p>
<?= sprintf(
$this->translatePlural(
'There is %s problem, issue commands to the problem service',
'There are %s problems, issue commands to the problem services',
$problemCount
),
'<b>' . $problemCount . '</b>'
); ?>
</p>
<?= $this->qlink(
sprintf(
$this->translatePlural(
'Schedule a downtime for %s problem service',
'Schedule downtimes for %s problem services',
$problemCount
),
$problemCount
),
$downtimeLink,
null,
array('icon' => 'plug')
); ?>
<?php endif ?>
<?php if ($unhandledCount): ?>
<p>
<?= sprintf($this->translate('There are %s unhandled problem services. ' .
'Issue commands to the problematic services:'),
'<span class="badge badge-critical">' . $unhandledCount . '</span>') ?>
</p>
<?= $this->qlink(
sprintf(
$this->translatePlural(
'Schedule a downtime for %u unhandled problem service',
'Schedule a downtime for %u unhandled problem services',
$unhandledCount
),
$unhandledCount
),
$downtimeUnhandledLink,
null,
array('icon' => 'plug')
); ?>
<br>
<?= $this->qlink(
sprintf(
$this->translatePlural(
'Acknowledge %u unhandled problem service',
'Acknowledge %u unhandled problem services',
$unhandledCount
),
$unhandledCount
),
$acknowledgeUnhandledLink,
null,
array('icon' => 'ok')
); ?>
<?php endif ?>
</div>
<?php endif; ?>
<?php if (($acknowledgedCount = count($acknowledgedObjects)) > 0): ?>
<h3><?= $this->icon('ok', $this->translate('Acknowledgements')) ?> <?= $this->translate('Acknowledgements') ?></h3>
<p>
<?= sprintf(
$this->translatePlural(
'%s Acknowledged Service Problem.',
'%s Acknowledged Service Problems.',
$acknowledgedCount
),
'<b>' . $acknowledgedCount . '</b>'
); ?> <?= $removeAckForm ?>
</p>
<?php endif ?> <?php endif ?>
</div>
<?php $scheduledDowntimeCount = count($objects->getScheduledDowntimes()) ?>
<?php if ($scheduledDowntimeCount): ?>
<h3><?= $this->icon('plug', $this->translate('Downtimes')) ?> <?= $this->translate('Downtimes') ?></h3>
<?= $this->qlink(
sprintf(
$this->translatePlural(
'%s scheduled downtime',
'%s scheduled downtimes',
$scheduledDowntimeCount
),
$scheduledDowntimeCount
),
$showDowntimesLink,
null,
array('data-base-target' => '_next')
);?>
<?= sprintf($this->translate('on all selected services.')) ?>
<?php if (($inDowntimeCount = count($objectsInDowntime)) > 0): ?>
<br>
<?= $this->qlink(
sprintf($this->translatePlural(
'%s service',
'%s services',
$inDowntimeCount
), $inDowntimeCount),
$inDowntimeLink,
null,
array('data-base-target' => '_next')
);?>
<?= sprintf($this->translate('are currently in downtime.')) ?>
<?php endif ?>
<?php endif ?>
<?php $commentCount = count($objects->getComments()) ?>
<?php if ($commentCount > 0): ?>
<h3> <?= $this->icon('comment') ?> <?= $this->translate('Comments') ?> </h3>
<?= $this->qlink(
sprintf(
$this->translatePlural(
'%s comment.',
'%s comments.',
$commentCount
), $commentCount),
$commentsLink,
null,
array('data-base-target' => '_next')
); ?>
<?= $this->translate('on all selected services.') ?>
<?php endif ?>
<?php endif ?>
</div>

View File

@ -33,8 +33,8 @@ if ($object->action_url) {
} }
} }
if (isset($this->hostActions)) { if (isset($this->actions)) {
foreach ($this->hostActions as $id => $action) { foreach ($this->actions as $id => $action) {
$links[] = sprintf($localLinkText, $action, $id); $links[] = sprintf($localLinkText, $action, $id);
} }
} }

View File

@ -68,17 +68,8 @@ if ($object->getType() === $object::TYPE_HOST) {
<?php if ($object->check_execution_time): ?> <?php if ($object->check_execution_time): ?>
<tr> <tr>
<th><?= $this->translate('Check execution time') ?></th> <th><?= $this->translate('Check execution time') ?></th>
<td><?php <td><?= $object->check_execution_time === null
$matches = array(); ? '-' : round((float) $object->check_execution_time, 3)
if (preg_match(
'/(?<!.)([0-9]+\.[0-9]{4,})(?!.)/ms',
$object->check_execution_time,
$matches
)) {
printf('%.3f', (float) $matches[1]);
} else {
echo $object->check_execution_time;
}
?>s</td> ?>s</td>
</tr> </tr>
<?php endif ?> <?php endif ?>

View File

@ -389,22 +389,6 @@ abstract class DataView implements QueryInterface, IteratorAggregate
return $this; return $this;
} }
/**
* Paginate data
*
* @param int $itemsPerPage Number of items per page
* @param int $pageNumber Current page number
*
* @return Zend_Paginator
*/
public function paginate($itemsPerPage = null, $pageNumber = null)
{
if (! $this->isSorted) {
$this->order();
}
return $this->query->paginate($itemsPerPage, $pageNumber);
}
/** /**
* Count result set * Count result set
* *
@ -466,7 +450,7 @@ abstract class DataView implements QueryInterface, IteratorAggregate
*/ */
public function getOffset() public function getOffset()
{ {
return $this->query->hasOffset(); return $this->query->getOffset();
} }
/** /**

View File

@ -3,6 +3,10 @@
namespace Icinga\Module\Monitoring\Object; namespace Icinga\Module\Monitoring\Object;
use Icinga\Data\Filter\Filter;
use Icinga\Data\Filter\FilterOr;
use Icinga\Util\String;
/** /**
* A host list * A host list
*/ */
@ -25,4 +29,74 @@ class HostList extends ObjectList
} }
return $hosts; return $hosts;
} }
/**
* Create a state summary of all hosts that can be consumed by hostssummary.phtml
*
* @return object The summary
*/
public function getStateSummary()
{
$hostStates = array_fill_keys(self::getHostStatesSummaryEmpty(), 0);
foreach ($this as $host) {
$unhandled = (bool) $host->problem === true && (bool) $host->handled === false;
$stateName = 'hosts_' . $host::getStateText($host->state);
++$hostStates[$stateName];
++$hostStates[$stateName. ($unhandled ? '_unhandled' : '_handled')];
}
$hostStates['hosts_total'] = count($this);
return (object)$hostStates;
}
/**
* Return an empty array with all possible host state names
*
* @return array An array containing all possible host states as keys and 0 as values.
*/
public static function getHostStatesSummaryEmpty()
{
return String::cartesianProduct(
array(
array('hosts'),
array(
Host::getStateText(Host::STATE_UP),
Host::getStateText(Host::STATE_DOWN),
Host::getStateText(Host::STATE_UNREACHABLE),
Host::getStateText(Host::STATE_PENDING)
),
array(null, 'handled', 'unhandled')
),
'_'
);
}
/**
* Returns a Filter that matches all hosts in this list
*
* @return Filter
*/
public function objectsFilter($columns = array('host' => 'host'))
{
$filterExpression = array();
foreach ($this as $host) {
$filterExpression[] = Filter::where($columns['host'], $host->getName());
}
return FilterOr::matchAny($filterExpression);
}
/**
* Get the scheduled downtimes
*
* @return type
*/
public function getScheduledDowntimes()
{
return $this->backend->select()
->from('downtime')
->applyFilter(clone $this->filter)
->where('downtime_objecttype', 'host');
}
} }

View File

@ -5,21 +5,40 @@ namespace Icinga\Module\Monitoring\Object;
use ArrayIterator; use ArrayIterator;
use Countable; use Countable;
use Icinga\Data\Filter\Filter;
use IteratorAggregate; use IteratorAggregate;
use Icinga\Module\Monitoring\Backend\MonitoringBackend; use Icinga\Module\Monitoring\Backend\MonitoringBackend;
abstract class ObjectList implements Countable, IteratorAggregate abstract class ObjectList implements Countable, IteratorAggregate
{ {
/**
* @var string
*/
protected $dataViewName; protected $dataViewName;
/**
* @var MonitoringBackend
*/
protected $backend; protected $backend;
/**
* @var array
*/
protected $columns; protected $columns;
/**
* @var Filter
*/
protected $filter; protected $filter;
/**
* @var array
*/
protected $objects; protected $objects;
/**
* @var int
*/
protected $count; protected $count;
public function __construct(MonitoringBackend $backend) public function __construct(MonitoringBackend $backend)
@ -27,23 +46,39 @@ abstract class ObjectList implements Countable, IteratorAggregate
$this->backend = $backend; $this->backend = $backend;
} }
/**
* @param array $columns
*
* @return $this
*/
public function setColumns(array $columns) public function setColumns(array $columns)
{ {
$this->columns = $columns; $this->columns = $columns;
return $this; return $this;
} }
/**
* @return array
*/
public function getColumns() public function getColumns()
{ {
return $this->columns; return $this->columns;
} }
/**
* @param $filter
*
* @return $this
*/
public function setFilter($filter) public function setFilter($filter)
{ {
$this->filter = $filter; $this->filter = $filter;
return $this; return $this;
} }
/**
* @return Filter
*/
public function getFilter() public function getFilter()
{ {
return $this->filter; return $this->filter;
@ -51,6 +86,9 @@ abstract class ObjectList implements Countable, IteratorAggregate
abstract protected function fetchObjects(); abstract protected function fetchObjects();
/**
* @return array
*/
public function fetch() public function fetch()
{ {
if ($this->objects === null) { if ($this->objects === null) {
@ -59,6 +97,9 @@ abstract class ObjectList implements Countable, IteratorAggregate
return $this->objects; return $this->objects;
} }
/**
* @return int
*/
public function count() public function count()
{ {
if ($this->count === null) { if ($this->count === null) {
@ -85,4 +126,94 @@ abstract class ObjectList implements Countable, IteratorAggregate
{ {
return $this->backend->select()->from('comment')->applyFilter($this->filter); return $this->backend->select()->from('comment')->applyFilter($this->filter);
} }
/**
* Get the scheduled downtimes
*
* @return type
*/
public function getScheduledDowntimes()
{
return $this->backend->select()->from('downtime')->applyFilter($this->filter);
}
/**
* @return ObjectList
*/
public function getAcknowledgedObjects()
{
$acknowledgedObjects = array();
foreach ($this as $object) {
if ((bool) $object->acknowledged === true) {
$acknowledgedObjects[] = $object;
}
}
return $this->newFromArray($acknowledgedObjects);
}
/**
* @return ObjectList
*/
public function getObjectsInDowntime()
{
$objectsInDowntime = array();
foreach ($this as $object) {
if ((bool) $object->in_downtime === true) {
$objectsInDowntime[] = $object;
}
}
return $this->newFromArray($objectsInDowntime);
}
/**
* @return ObjectList
*/
public function getUnhandledObjects()
{
$unhandledObjects = array();
foreach ($this as $object) {
if ((bool) $object->problem === true && (bool) $object->handled === false) {
$unhandledObjects[] = $object;
}
}
return $this->newFromArray($unhandledObjects);
}
/**
* @return ObjectList
*/
public function getProblemObjects()
{
$handledObjects = array();
foreach ($this as $object) {
if ((bool) $object->problem === true) {
$handledObjects[] = $object;
}
}
return $this->newFromArray($handledObjects);
}
/**
* Create a ObjectList from an array of hosts without querying a backend
*
* @return ObjectList
*/
protected function newFromArray(array $objects)
{
$class = get_called_class();
$list = new $class($this->backend);
$list->objects = $objects;
$list->count = count($objects);
$list->filter = $list->objectsFilter();
return $list;
}
/**
* Create a filter that matches exactly the elements of this object list
*
* @param array $columns Override default column names.
*
* @return Filter
*/
abstract function objectsFilter($columns = array());
} }

View File

@ -3,11 +3,19 @@
namespace Icinga\Module\Monitoring\Object; namespace Icinga\Module\Monitoring\Object;
use Icinga\Data\Filter\Filter;
use Icinga\Data\Filter\FilterOr;
use Icinga\Util\String;
/** /**
* A service list * A service list
*/ */
class ServiceList extends ObjectList class ServiceList extends ObjectList
{ {
protected $hostStateSummary;
protected $serviceStateSummary;
protected $dataViewName = 'serviceStatus'; protected $dataViewName = 'serviceStatus';
protected $columns = array('host_name', 'service_description'); protected $columns = array('host_name', 'service_description');
@ -25,4 +33,118 @@ class ServiceList extends ObjectList
} }
return $services; return $services;
} }
/**
* Create a state summary of all services that can be consumed by servicesummary.phtml
*
* @return object The summary
*/
public function getServiceStateSummary()
{
if (! $this->serviceStateSummary) {
$this->initStateSummaries();
}
return (object)$this->serviceStateSummary;
}
/**
* Create a state summary of all hosts that can be consumed by hostsummary.phtml
*
* @return object The summary
*/
public function getHostStateSummary()
{
if (! $this->hostStateSummary) {
$this->initStateSummaries();
}
return (object)$this->hostStateSummary;
}
/**
* Calculate the current state summary and populate hostStateSummary and serviceStateSummary
* properties
*/
protected function initStateSummaries()
{
$serviceStates = array_fill_keys(self::getServiceStatesSummaryEmpty(), 0);
$hostStates = array_fill_keys(HostList::getHostStatesSummaryEmpty(), 0);
foreach ($this as $service) {
$unhandled = false;
if ((bool) $service->problem === true && (bool) $service->handled === false) {
$unhandled = true;
}
$stateName = 'services_' . $service::getStateText($service->state);
++$serviceStates[$stateName];
++$serviceStates[$stateName . ($unhandled ? '_unhandled' : '_handled')];
if (! isset($knownHostStates[$service->getHost()->getName()])) {
$unhandledHost = (bool) $service->host_problem === true && (bool) $service->host_handled === false;
++$hostStates['hosts_' . $service->getHost()->getStateText($service->host_state)];
++$hostStates['hosts_' . $service->getHost()->getStateText($service->host_state)
. ($unhandledHost ? '_unhandled' : '_handled')];
$knownHostStates[$service->getHost()->getName()] = true;
}
}
$serviceStates['services_total'] = count($this);
$this->hostStateSummary = $hostStates;
$this->serviceStateSummary = $serviceStates;
}
/**
* Return an empty array with all possible host state names
*
* @return array An array containing all possible host states as keys and 0 as values.
*/
public static function getServiceStatesSummaryEmpty()
{
return String::cartesianProduct(
array(
array('services'),
array(
Service::getStateText(Service::STATE_OK),
Service::getStateText(Service::STATE_WARNING),
Service::getStateText(Service::STATE_CRITICAL),
Service::getStateText(Service::STATE_UNKNOWN),
Service::getStateText(Service::STATE_PENDING)
),
array(null, 'handled', 'unhandled')
),
'_'
);
}
/**
* Returns a Filter that matches all hosts in this HostList
*
* @param array $columns Override filter column names
*
* @return Filter
*/
public function objectsFilter($columns = array('host' => 'host', 'service' => 'service'))
{
$filterExpression = array();
foreach ($this as $service) {
$filterExpression[] = Filter::matchAll(
Filter::where($columns['host'], $service->getHost()->getName()),
Filter::where($columns['service'], $service->getName())
);
}
return FilterOr::matchAny($filterExpression);
}
/**
* Get the scheduled downtimes
*
* @return type
*/
public function getScheduledDowntimes()
{
return $this->backend->select()
->from('downtime')
->applyFilter(clone $this->filter)
->where('downtime_objecttype', 'service');
}
} }

View File

@ -0,0 +1,46 @@
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
namespace Icinga\Module\Monitoring\Web\Hook;
use Icinga\Module\Monitoring\Object\Service;
/**
* Base class for host action hooks
*/
abstract class ServiceActionsHook
{
/**
* Implementors of this method should return an array containing
* additional action links for a specific host. You get a full Service
* object, which allows you to return specific links only for nodes
* with specific properties.
*
* The result array should be in the form title => url, where title will
* be used as link caption. Url should be an Icinga\Web\Url object when
* the link should point to an Icinga Web url - otherwise a string would
* be fine.
*
* Mixed example:
* <code>
* return array(
* 'Wiki' => 'http://my.wiki/host=' . rawurlencode($service->service_name),
* 'Logstash' => Url::fromPath(
* 'logstash/search/syslog',
* array('service' => $service->host_name)
* )
* );
* </code>
*
* One might also provide ssh:// or rdp:// urls if equipped with fitting
* (safe) URL handlers for his browser(s).
*
* TODO: I'd love to see some kind of a Link/LinkSet object implemented
* for this and similar hooks.
*
* @param Service $service Monitoring service object
*
* @return array An array containing a list of service action links
*/
abstract public function getActionsForService(Service $service);
}

View File

@ -90,7 +90,7 @@ div.contacts div.notification-periods {
margin-top: 0.5em; margin-top: 0.5em;
} }
div.tinystatesummary { .tinystatesummary {
.page-header(); .page-header();
font-size: 1em; font-size: 1em;
margin-bottom: 0.5em; margin-bottom: 0.5em;
@ -99,6 +99,7 @@ div.tinystatesummary {
display: inline-block; display: inline-block;
margin-bottom: 4px; margin-bottom: 4px;
margin-left: 1em; margin-left: 1em;
height: auto;
} }
.state > a { .state > a {
@ -130,14 +131,26 @@ span.state.ok {
background: @colorOk; background: @colorOk;
} }
span.state.up {
background: @colorOk;
}
span.state.critical { span.state.critical {
background: @colorCritical; background: @colorCritical;
} }
span.state.down {
background: @colorCritical;
}
span.state.handled.critical { span.state.handled.critical {
background: @colorCriticalHandled; background: @colorCriticalHandled;
} }
span.state.handled.down {
background: @colorCriticalHandled;
}
span.state.warning { span.state.warning {
background: @colorWarning; background: @colorWarning;
} }
@ -198,7 +211,7 @@ div.selection-info {
.optionbox label { .optionbox label {
max-width: 6.5em; max-width: 6.5em;
text-align: left; text-align: left;
vertical-align: middle; vertgical-align: middle;
margin-right: 0em; margin-right: 0em;
} }

View File

@ -346,6 +346,7 @@ html {
.hbox-item { .hbox-item {
display: inline-block; display: inline-block;
vertical-align: top; vertical-align: top;
margin-top: 0.5em;
margin-bottom: 0.25em; margin-bottom: 0.25em;
margin-left: 1em; margin-left: 1em;
margin-right: 1em; margin-right: 1em;
@ -371,3 +372,8 @@ html {
position: absolute; position: absolute;
width: 1px; width: 1px;
} }
.multi-commands {
padding-top: 0em;
font-size: 0.9em;
}

View File

@ -926,3 +926,39 @@ table.groupview {
} }
/* End of monitoring groupsummary styles */ /* End of monitoring groupsummary styles */
/* compact table */
table.statesummary {
text-align: left;
width: auto;
border-collapse: separate;
tr.state td.state {
width: auto;
font-weight: bold;
}
td {
font-size: 0.9em;
line-height: 1.2em;
padding-left: 0.2em;
margin: 0;
}
td.state {
padding: 0.2em;
min-width: 75px;
font-size: 0.75em;
text-align: center;
}
td.name {
font-weight: bold;
}
td a {
color: inherit;
text-decoration: none;
}
}

View File

@ -217,23 +217,13 @@ li li .badge-container {
margin-right: 0.75em; margin-right: 0.75em;
} }
/*
#layout.hoveredmenu .active > .badge-container {
display: none;
}
#layout.hoveredmenu .hover > .badge-container {
//margin-right: 14.15em;
display: none;
}
*/
.badge { .badge {
position: relative; position: relative;
top: 0.3em; top: -0.15em;
display: inline-block; display: inline-block;
min-width: 1em; min-width: 1em;
padding: 3px 7px; padding: 3px 7px;
margin: 0 0.2em 0 0.2em;
font-size: 0.8em; font-size: 0.8em;
font-weight: 700; font-weight: 700;
line-height: 1.1em; line-height: 1.1em;
@ -244,6 +234,11 @@ li li .badge-container {
background-color: @colorInvalid; background-color: @colorInvalid;
} }
#menu nav ul .badge {
margin-right: 0em;
top: 0.3em;
}
#menu nav > ul > li.active > .badge-container { #menu nav > ul > li.active > .badge-container {
display: none; display: none;
} }
@ -279,6 +274,10 @@ li li .badge {
background-color: @colorCritical; background-color: @colorCritical;
} }
.badge-down {
background-color: @colorCritical;
}
.badge-warning { .badge-warning {
background-color: @colorWarning; background-color: @colorWarning;
} }
@ -287,11 +286,15 @@ li li .badge {
background-color: @colorOk; background-color: @colorOk;
} }
.badge-up {
background-color: @colorOk;
}
.badge-pending { .badge-pending {
background-color: @colorPending; background-color: @colorPending;
} }
.badge-pending { .badge-unknown {
background-color: @colorUnknown; background-color: @colorUnknown;
} }
@ -313,3 +316,25 @@ li li .badge {
margin: 0em 0em 0em 0.1em; margin: 0em 0em 0em 0.1em;
} }
.tipsy .tipsy-inner {
// overwrite tooltip max width, we need them to grow bigger
max-width: 300px;
text-align: left;
}
.color-box {
position: relative;
top: 2px;
margin: 0px 3px 0px 3px;
display: inline-block;
width: 12px;
height: 12px;
}
.oneline {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}

View File

@ -198,16 +198,53 @@ class FilterTest extends BaseTestCase
$this->assertNotEquals((string) $c, (string) $d); $this->assertNotEquals((string) $c, (string) $d);
} }
public function testLeadingAndTrailingWhitespacesSanitizing() public function testLeadingAndTrailingWhitespaces()
{ {
$columnHasWhitespaces = Filter::where(' host ', 'localhost'); $columnWithWhitespaces = Filter::where(' host ', 'localhost');
$expressionHasWhitespaces = Filter::where('host', ' localhost '); $this->assertTrue($columnWithWhitespaces->matches((object) array(
$bothHaveWhitespaces = Filter::fromQueryString(' host = localhost '); 'host' => 'localhost'
$withArray = Filter::where(' host ', array(' no match ', ' localhost ')); )),
$this->assertTrue($columnHasWhitespaces->matches($this->sampleData[0])); 'Filter doesn\'t remove leading and trailing whitespaces from columns'
$this->assertTrue($expressionHasWhitespaces->matches($this->sampleData[0])); );
$this->assertTrue($bothHaveWhitespaces->matches($this->sampleData[0])); $expressionWithLeadingWhitespaces = Filter::where('host', ' localhost');
$this->assertTrue($withArray->matches($this->sampleData[0])); $this->assertTrue($expressionWithLeadingWhitespaces->matches((object) array(
'host' => ' localhost'
)),
'Filter doesn\'t take leading whitespaces of expressions into account'
);
$this->assertFalse($expressionWithLeadingWhitespaces->matches((object) array(
'host' => ' localhost '
)),
'Filter doesn\'t take trailing whitespaces of expressions into account'
);
$expressionWithTrailingWhitespaces = Filter::where('host', 'localhost ');
$this->assertTrue($expressionWithTrailingWhitespaces->matches((object) array(
'host' => 'localhost '
)),
'Filter doesn\'t take trailing whitespaces of expressions into account'
);
$this->assertFalse($expressionWithTrailingWhitespaces->matches((object) array(
'host' => ' localhost '
)),
'Filter doesn\'t take leading whitespaces of expressions into account'
);
$expressionWithLeadingAndTrailingWhitespaces = Filter::where('host', ' localhost ');
$this->assertTrue($expressionWithLeadingAndTrailingWhitespaces->matches((object) array(
'host' => ' localhost '
)),
'Filter doesn\'t take leading and trailing whitespaces of expressions into account'
);
$this->assertFalse($expressionWithLeadingAndTrailingWhitespaces->matches((object) array(
'host' => ' localhost '
)),
'Filter doesn\'t take leading and trailing whitespaces of expressions into account'
);
$queryStringWithWhitespaces = Filter::fromQueryString(' host = localhost ');
$this->assertTrue($queryStringWithWhitespaces->matches((object) array(
'host' => ' localhost '
)),
'Filter doesn\'t take leading and trailing whitespaces of expressions in query strings into account'
);
} }
private function row($idx) private function row($idx)