mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-04-08 17:15:08 +02:00
parent
281626555b
commit
a42668edb8
library/Icinga/Data
modules/monitoring
application/views
helpers
scripts
library/Monitoring
test/php
application
controllers
views/helpers
library/Backend/Statusdat
testlib
test/php/library/Icinga/Web/Paginator
@ -4,9 +4,11 @@
|
||||
|
||||
namespace Icinga\Data;
|
||||
|
||||
use Zend_Config;
|
||||
use Icinga\Util\ConfigAwareFactory;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\Data\Db\Connection as DbConnection;
|
||||
use Icinga\Protocol\Statusdat\Reader as StatusdatReader;
|
||||
|
||||
class ResourceFactory implements ConfigAwareFactory
|
||||
{
|
||||
@ -20,14 +22,22 @@ class ResourceFactory implements ConfigAwareFactory
|
||||
self::$resources = $config;
|
||||
}
|
||||
|
||||
public static function createResource($resourceName)
|
||||
public static function getResourceConfig($resourceName)
|
||||
{
|
||||
if (($resourceConfig = self::$resources->get($resourceName)) === null) {
|
||||
throw new ConfigurationError('BLUBB?!');
|
||||
}
|
||||
switch (strtolower($resourceConfig->type)) {
|
||||
return $resourceConfig;
|
||||
}
|
||||
|
||||
public static function createResource(Zend_Config $config)
|
||||
{
|
||||
switch (strtolower($config->type)) {
|
||||
case 'db':
|
||||
$resource = new DbConnection($resourceConfig);
|
||||
$resource = new DbConnection($config);
|
||||
break;
|
||||
case 'statusdat':
|
||||
$resource = new StatusdatReader($config);
|
||||
break;
|
||||
default:
|
||||
throw new ConfigurationError('BLUBB2?!');
|
||||
|
@ -25,61 +25,40 @@
|
||||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
use Icinga\Module\Monitoring\Object\AbstractObject;
|
||||
/*use Icinga\Module\Monitoring\Object\AbstractObject;*/
|
||||
|
||||
/**
|
||||
* Class Zend_View_Helper_MonitoringFlags
|
||||
*
|
||||
* Rendering helper for flags depending on objects
|
||||
* Rendering helper for object's properties which may be either enabled or disabled
|
||||
*/
|
||||
class Zend_View_Helper_MonitoringFlags extends Zend_View_Helper_Abstract
|
||||
{
|
||||
/**
|
||||
* Key of flags without prefix (e.g. host or service)
|
||||
* Object's properties which may be either enabled or disabled and their human readable description
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private static $keys = array(
|
||||
'passive_checks_enabled' => 'Passive Checks',
|
||||
'active_checks_enabled' => 'Active Checks',
|
||||
'obsessing' => 'Obsessing',
|
||||
'notifications_enabled' => 'Notifications',
|
||||
'event_handler_enabled' => 'Event Handler',
|
||||
'flap_detection_enabled' => 'Flap Detection',
|
||||
private static $flags = array(
|
||||
'passive_checks_enabled' => 'Passive Checks',
|
||||
'active_checks_enabled' => 'Active Checks',
|
||||
'obsessing' => 'Obsessing',
|
||||
'notifications_enabled' => 'Notifications',
|
||||
'event_handler_enabled' => 'Event Handler',
|
||||
'flap_detection_enabled' => 'Flap Detection',
|
||||
);
|
||||
|
||||
/**
|
||||
* Type prefix
|
||||
* @param array $vars
|
||||
* @return string
|
||||
* Retrieve flags as array with either true or false as value
|
||||
*
|
||||
* @param AbstractObject $object
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getObjectType(array $vars)
|
||||
public function monitoringFlags(/*AbstractObject*/$object)
|
||||
{
|
||||
$keys = array_keys($vars);
|
||||
$firstKey = array_shift($keys);
|
||||
$keyParts = explode('_', $firstKey, 2);
|
||||
|
||||
return array_shift($keyParts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build all existing flags to a readable array
|
||||
* @param stdClass $object
|
||||
* @return array
|
||||
*/
|
||||
public function monitoringFlags(AbstractObject $object)
|
||||
{
|
||||
$vars = (array)$object;
|
||||
$type = $this->getObjectType($vars);
|
||||
$out = array();
|
||||
|
||||
foreach (self::$keys as $key => $name) {
|
||||
$value = false;
|
||||
if (array_key_exists(($realKey = $type. '_'. $key), $vars)) {
|
||||
$value = $vars[$realKey] === '1' ? true : false;
|
||||
}
|
||||
$out[$name] = $value;
|
||||
$flags = array();
|
||||
foreach (self::$flags as $column => $description) {
|
||||
$flags[$description] = (bool) $object->{$column};
|
||||
}
|
||||
|
||||
return $out;
|
||||
return $flags;
|
||||
}
|
||||
}
|
||||
|
@ -49,10 +49,8 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
|
||||
*/
|
||||
private static $keys = array(
|
||||
'buildAttempt' => 'Current Attempt',
|
||||
'last_check' => 'Last Check Time',
|
||||
'buildCheckType' => 'Check Type',
|
||||
'buildLatency' => 'Check Latency / Duration',
|
||||
'buildNextCheck' => 'Next Scheduled Active Check',
|
||||
'buildLastStateChange' => 'Last State Change',
|
||||
'buildLastNotification' => 'Last Notification',
|
||||
'buildFlapping' => 'Is This %s Flapping?',
|
||||
@ -78,7 +76,7 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
|
||||
* @param stdClass $object
|
||||
* @return mixed
|
||||
*/
|
||||
private function getObjectType(AbstractObject $object)
|
||||
private function getObjectType($object)
|
||||
{
|
||||
$keys = array_keys(get_object_vars($object));
|
||||
$keyParts = explode('_', array_shift($keys), 2);
|
||||
@ -91,7 +89,7 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
|
||||
* @param $type
|
||||
* @return object
|
||||
*/
|
||||
private function dropObjectType(AbstractObject $object, $type)
|
||||
private function dropObjectType($object, $type)
|
||||
{
|
||||
$vars = get_object_vars($object);
|
||||
$out = array();
|
||||
@ -107,7 +105,7 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
|
||||
* @param stdClass $object
|
||||
* @return string
|
||||
*/
|
||||
private function buildAttempt(AbstractObject $object)
|
||||
private function buildAttempt($object)
|
||||
{
|
||||
return sprintf(
|
||||
'%s/%s (%s state)',
|
||||
@ -132,7 +130,7 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
|
||||
* @param stdClass $object
|
||||
* @return string
|
||||
*/
|
||||
private function buildCheckType(AbstractObject $object)
|
||||
private function buildCheckType($object)
|
||||
{
|
||||
if ($object->passive_checks_enabled === '1' && $object->active_checks_enabled === '0') {
|
||||
return self::CHECK_PASSIVE;
|
||||
@ -148,7 +146,7 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
|
||||
* @param stdClass $object
|
||||
* @return string
|
||||
*/
|
||||
private function buildLatency(AbstractObject $object)
|
||||
private function buildLatency($object)
|
||||
{
|
||||
$val = '';
|
||||
if ($this->buildCheckType($object) === self::CHECK_PASSIVE) {
|
||||
@ -171,7 +169,7 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
|
||||
* @param stdClass $object
|
||||
* @return string
|
||||
*/
|
||||
private function buildNextCheck(AbstractObject $object)
|
||||
private function buildNextCheck($object)
|
||||
{
|
||||
if ($this->buildCheckType($object) === self::CHECK_PASSIVE) {
|
||||
return self::VALUE_NA;
|
||||
@ -185,7 +183,7 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
|
||||
* @param stdClass $object
|
||||
* @return string
|
||||
*/
|
||||
private function buildLastStateChange(AbstractObject $object)
|
||||
private function buildLastStateChange($object)
|
||||
{
|
||||
return strftime('%Y-%m-%d %H:%M:%S', $object->last_state_change);
|
||||
}
|
||||
@ -195,7 +193,7 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
|
||||
* @param stdClass $object
|
||||
* @return string
|
||||
*/
|
||||
private function buildLastNotification(AbstractObject $object)
|
||||
private function buildLastNotification($object)
|
||||
{
|
||||
$val = '';
|
||||
|
||||
@ -215,7 +213,7 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
|
||||
* @param stdClass $object
|
||||
* @return string
|
||||
*/
|
||||
private function buildFlapping(AbstractObject $object)
|
||||
private function buildFlapping($object)
|
||||
{
|
||||
$val = '';
|
||||
|
||||
@ -235,7 +233,7 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
|
||||
* @param stdClass $object
|
||||
* @return string
|
||||
*/
|
||||
private function buildScheduledDowntime(AbstractObject $object)
|
||||
private function buildScheduledDowntime($object)
|
||||
{
|
||||
if ($object->in_downtime === '1') {
|
||||
return self::VALUE_YES;
|
||||
@ -250,7 +248,7 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
|
||||
* @param stdClass $object
|
||||
* @return array
|
||||
*/
|
||||
public function monitoringProperties(AbstractObject $object)
|
||||
public function monitoringProperties($object)
|
||||
{
|
||||
$type = $this->getObjectType($object);
|
||||
//$object = $this->dropObjectType($object, $type);
|
||||
|
@ -4,6 +4,7 @@
|
||||
$viewHelper = $this->getHelper('MonitoringState');
|
||||
?>
|
||||
|
||||
<h1>Hosts Status</h1>
|
||||
<div data-icinga-component="app/mainDetailGrid">
|
||||
|
||||
<?= $this->sortControl->render($this); ?>
|
||||
@ -101,7 +102,7 @@ $viewHelper = $this->getHelper('MonitoringState');
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
|
||||
<a href="<?= $hostLink ?>">
|
||||
<a href="<?= $this->href('monitoring/list/services', array('host' => $host->host_name)) ?>">
|
||||
<b><?= $host->host_name ?></b><br/>
|
||||
<i><?= $host->host_address ?></i>
|
||||
</a>
|
||||
|
@ -4,6 +4,7 @@
|
||||
$viewHelper = $this->getHelper('MonitoringState');
|
||||
?>
|
||||
|
||||
<h1>Services Status</h1>
|
||||
<div data-icinga-component="app/mainDetailGrid">
|
||||
|
||||
<?= $this->sortControl->render($this); ?>
|
||||
@ -104,9 +105,9 @@ $viewHelper = $this->getHelper('MonitoringState');
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<a href="<?= $serviceLink; ?>">
|
||||
<!--<a href="<?= $serviceLink; ?>">-->
|
||||
<b> <?= $service->service_display_name; ?></b>
|
||||
</a>
|
||||
<!--</a>-->
|
||||
<br/>
|
||||
|
||||
<?php if (!empty($service->service_action_url)): ?>
|
||||
@ -124,7 +125,7 @@ $viewHelper = $this->getHelper('MonitoringState');
|
||||
<i>{{UNHANDLED_ICON}}</i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<a href="<?= $hostLink; ?>">
|
||||
<a href="<?= $this->href('monitoring/list/services', array('host' => $service->host_name)) ?>">
|
||||
<b><?= $service->host_name; ?></b>
|
||||
<?php if ($service->host_state != 0): ?>
|
||||
(<?= ucfirst($viewHelper->monitoringState($service, 'host')); ?>)
|
||||
|
@ -1,13 +1,27 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
{{CHECK_ICON}} <span>Check Command</span>
|
||||
{{CHECK_COMMAND_ICON}}
|
||||
<span>Check Command</span>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<?php
|
||||
$explodedCommand = explode('!', $this->object->check_command, 2);
|
||||
array_shift($explodedCommand);
|
||||
?>
|
||||
<?= $this->commandArguments($this->object->check_command); ?>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Command</td>
|
||||
<td>
|
||||
<?php
|
||||
$explodedCommand = explode('!', $this->object->check_command, 2);
|
||||
$command = array_shift($explodedCommand);
|
||||
echo $command;
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Arguments</td>
|
||||
<td>
|
||||
<?= $this->commandArguments($this->object->check_command); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -12,12 +12,18 @@ foreach ($object->comments as $comment) {
|
||||
);
|
||||
}
|
||||
?>
|
||||
<?php endif; ?>
|
||||
<div class="panel panel-default ">
|
||||
<div class="panel-heading">
|
||||
<span>{{COMMENT_ICON}} Comments</span>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<blockquote> <?= implode('<br />', $commets); ?></blockquote>
|
||||
<a href="#" class="button">{{COMMENT_COMMAND_BUTTON}}</a>
|
||||
<a href="#" class="button">{{NOTIFICATION_COMMAND_BUTTON}}</a><br/>
|
||||
<?php if (!empty($object->comments)): ?>
|
||||
<blockquote> <?= implode('<br />', $commets); ?><a href="#" class="button">{{REMOVE_COMMENT_COMMAND}}</a></blockquote>
|
||||
<?php else: ?>
|
||||
No comments
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
@ -1,10 +1,11 @@
|
||||
<?php if (isset($object->customvars) && count($object->customvars)) { ?>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<span>Customvariables</span>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<?php if (isset($object->customvars) && count($object->customvars)) { ?>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
@ -17,6 +18,6 @@
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
@ -27,16 +27,21 @@
|
||||
$list[] = '<td>'. implode('</td><td>', $row). '</td>';
|
||||
}
|
||||
?>
|
||||
<?php endif; ?>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
{{IN_DOWNTIME_ICON}}<span>Downtimes</span>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<a href="#" class="button">{{SCHEDULE_DOWNTIME_COMMAND_BUTTON}}</a><br/>
|
||||
<?php if (!empty($this->downtimes)): ?>
|
||||
<table>
|
||||
<tr>
|
||||
<?= implode('</tr><tr>', $list); ?>
|
||||
</tr>
|
||||
</table>
|
||||
<?php else: ?>
|
||||
Not in downtime
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
@ -1,20 +1,22 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Heading</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<table class="table table-condensed">
|
||||
<?php foreach ($this->monitoringFlags($object) as $name => $value): ?>
|
||||
<tr>
|
||||
<th><?= $name; ?></th>
|
||||
<td>
|
||||
<?php if ($value === true): ?>
|
||||
<span>{{ENABLED_ICON}} ENABLED</span>
|
||||
<?php else: ?>
|
||||
<span>{{DISABLED_ICON}} DISABLED</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
<table class="table table-condensed">
|
||||
<?php foreach ($this->monitoringFlags($object) as $flag => $enabled): ?>
|
||||
<tr>
|
||||
<th><?= $flag; ?></th>
|
||||
<td>
|
||||
<?php if ($enabled === true): ?>
|
||||
<span>{{ENABLED_ICON}} ENABLED</span>
|
||||
<?php else: ?>
|
||||
<span>{{DISABLED_ICON}} DISABLED</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<a class="button" href="#">{{{ENABLE_OR_DISABLE_COMMAND}}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,10 +0,0 @@
|
||||
<?php if ($this->object->perfdata): ?>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<span>Perfdata</span>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<?= $this->perfdata($this->object->perfdata); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
@ -1,9 +0,0 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<span>Plugin Output</span>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<?= $this->pluginOutput($this->object->output); ?>
|
||||
<?= $this->pluginOutput($this->object->long_output); ?>
|
||||
</div>
|
||||
</div>
|
@ -1,19 +1,119 @@
|
||||
<?= $this->render('show/components/pluginoutput.phtml') ?>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<?php if ($this->object->host_icon_image): ?>
|
||||
<img src="<?= $this->object->host_icon_image; ?>" alt="Host image" />
|
||||
<?php else: ?>
|
||||
{{HOST_ICON}}
|
||||
<?php endif; ?>
|
||||
<h1>Host Status <?= $this->escape($this->object->host_name); ?></h1>
|
||||
</div>
|
||||
|
||||
<?= $this->render('show/components/command.phtml') ?>
|
||||
|
||||
<?= $this->render('show/components/hostgroups.phtml') ?>
|
||||
|
||||
<?= $this->render('show/components/contacts.phtml') ?>
|
||||
|
||||
<?= $this->render('show/components/comments.phtml'); ?>
|
||||
<div class="panel-body">
|
||||
<table>
|
||||
<tr>
|
||||
<?php if (!$object->host_handled && $object->host_state > 0): ?>
|
||||
<td>
|
||||
<a href="#" title="Unhandled">
|
||||
<i>{{UNHANDLED_ICON}}</i>
|
||||
</a>
|
||||
<a href="#" title="Acknowledge">
|
||||
<i>{{ACKNOWLEDGE_COMMAND}}</i>
|
||||
</a>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<?php if ($object->service_acknowledged && !$object->service_in_downtime): ?>
|
||||
<td>
|
||||
<a href="#" title="Acknowledged">
|
||||
<i>{{ACKNOWLEDGED_ICON}}</i>
|
||||
</a>
|
||||
</td>
|
||||
<?php else: ?>
|
||||
<td>
|
||||
Status
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<td>
|
||||
<?= $this->util()->getHostStateName($this->object->host_state); ?>
|
||||
since <?= $this->timeSince($this->object->host_last_state_change); ?>
|
||||
</td>
|
||||
<td><a class="button" href="#">{{RECHECK_COMMAND_BUTTON}</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Last Check</td>
|
||||
<td><?= $object->last_check ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Next Check</td>
|
||||
<td><?= $object->next_check ?></td>
|
||||
<td><a href="#" class="button">{{RESCHEDULE_COMMAND_BUTTON}}</a></td>
|
||||
</tr>
|
||||
<?php if ($this->object->host_address && $this->object->host_address !== $this->object->host_name): ?>
|
||||
<tr>
|
||||
<td>Host Address</td>
|
||||
<td><?= $this->escape($this->object->host_address); ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if (isset($this->object->host_alias) && $this->object->host_alias !== $this->object->host_name): ?>
|
||||
<tr>
|
||||
<td>Alias</td>
|
||||
<td><?= $this->object->host_alias; ?></td>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->object->host_action_url || $this->object->host_notes_url): ?>
|
||||
<tr>
|
||||
<td rowspan="2">
|
||||
<?php if ($this->object->host_action_url): ?>
|
||||
<a target="_new" href='<?= $this->object->host_notes_url ?>'>{{HOST_ACTIONS_ICON}}</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->object->host_notes_url): ?>
|
||||
<a target="_new" href='<?= $this->object->host_notes_url ?>'>{{HOST_NOTES_ICON}}</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<tr>
|
||||
<td>Plugin Output</td>
|
||||
<td>
|
||||
<?= $this->pluginOutput($this->object->output); ?>
|
||||
<?= $this->pluginOutput($this->object->long_output); ?>
|
||||
</td>
|
||||
<td>
|
||||
<a class="button" href="#">{{SUBMIT_PASSIVE_CHECK_RESULT_COMMAND}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ($this->object->perfdata): ?>
|
||||
<tr>
|
||||
<td>Performance Data</td>
|
||||
<td><?= $this->perfdata($this->object->perfdata); ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<a href="<?= $this->href('monitoring/list/services', array('host' => $object->host_name)); ?>">
|
||||
View Services For This Host
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<a class="button" href="#">{{{RECHECK_ALL_SERVICES_COMMAND}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?= $this->render('show/components/downtime.phtml'); ?>
|
||||
|
||||
<?= $this->render('show/components/customvars.phtml'); ?>
|
||||
<?= $this->render('show/components/comments.phtml'); ?>
|
||||
|
||||
<?= $this->render('show/components/properties.phtml'); ?>
|
||||
|
||||
<?= $this->render('show/components/flags.phtml'); ?>
|
||||
|
||||
<?= $this->render('show/components/perfdata.phtml'); ?>
|
||||
<?= $this->render('show/components/hostgroups.phtml'); ?>
|
||||
|
||||
<?= $this->render('show/components/eventHistory.phtml'); ?>
|
||||
|
||||
<?= $this->render('show/components/contacts.phtml'); ?>
|
||||
|
||||
<?= $this->render('show/components/customvars.phtml'); ?>
|
||||
|
||||
<?= $this->render('show/components/command.phtml'); ?>
|
||||
|
@ -1,19 +1,124 @@
|
||||
<?= $this->render('show/components/pluginoutput.phtml') ?>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
{{SERVICE_ICON}} <h1>Service Status <?= $this->escape($this->object->service_description); ?></h1>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<table>
|
||||
<tr>
|
||||
<?php if ($this->object->service_icon_image): ?>
|
||||
<td>
|
||||
<div>
|
||||
<img src="<?= $this->object->service_icon_image; ?>" alt="Host image" />
|
||||
</div>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<?php if (!$object->service_handled && $object->service_state > 0): ?>
|
||||
<td>
|
||||
<a href="#" title="Unhandled">
|
||||
<i>{{UNHANDLED_ICON}}</i>
|
||||
</a>
|
||||
<a href="#" title="Acknowledge">
|
||||
<i>{{ACKNOWLEDGE_COMMAND}}</i>
|
||||
</a>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<?php if ($object->service_acknowledged && !$object->service_in_downtime): ?>
|
||||
<td>
|
||||
<a href="#" title="Acknowledged">
|
||||
<i>{{ACKNOWLEDGED_ICON}}</i>
|
||||
</a>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<td>
|
||||
<strong><?= $this->util()->getServiceStateName($this->object->service_state); ?></strong>
|
||||
since <?= $this->timeSince($this->object->service_last_state_change); ?>
|
||||
</td>
|
||||
<td><a class="button" href="#">{{RECHECK_COMMAND_BUTTON}</a></td>
|
||||
</tr>
|
||||
<?php if ($this->object->service_action_url || $this->object->service_notes_url): ?>
|
||||
<tr>
|
||||
<td rowspan="2">
|
||||
<?php if ($this->object->service_action_url): ?>
|
||||
{{SERVICE_ACTIONS_ICON}}
|
||||
<a target="_new" href='<?= $this->object->service_notes_url ?>'>Host actions</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->object->service_notes_url): ?>
|
||||
{{SERVICE_NOTES_ICON}}
|
||||
<a target="_new" href='<?= $this->object->service_notes_url ?>'>Host notes</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
{{HOST_ICON}} <span><?= $this->escape($this->object->host_name); ?></span>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<table>
|
||||
<tr>
|
||||
<?php if ($this->object->host_icon_image): ?>
|
||||
<td>
|
||||
<div>
|
||||
<img src="<?= $this->object->host_icon_image; ?>" alt="Host image" />
|
||||
</div>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->object->host_address && $this->object->host_address !== $this->object->host_name): ?>
|
||||
<td>
|
||||
<strong>Host Address:</strong> <?= $this->escape($this->object->host_address); ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<?php if (isset($this->object->host_alias) && $this->object->host_alias !== $this->object->host_name): ?>
|
||||
<td>
|
||||
<strong>Alias:</strong> <?= $this->object->host_alias; ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<td>
|
||||
<strong><?= $this->util()->getHostStateName($this->object->host_state); ?></strong>
|
||||
since <?= $this->timeSince($this->object->host_last_state_change); ?>
|
||||
<?php if ($this->object->host_acknowledged === '1'): ?>
|
||||
(Has been acknowledged)
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ($this->object->host_action_url || $this->object->host_notes_url): ?>
|
||||
<tr>
|
||||
<td rowspan="2">
|
||||
<?php if ($this->object->host_action_url): ?>
|
||||
{{HOST_ACTIONS_ICON}}
|
||||
<a target="_new" href='<?= $this->object->host_notes_url ?>'>Host actions</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->object->host_notes_url): ?>
|
||||
{{HOST_NOTES_ICON}}
|
||||
<a target="_new" href='<?= $this->object->host_notes_url ?>'>Host notes</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?= $this->render('show/components/command.phtml') ?>
|
||||
|
||||
<?= $this->render('show/components/contacts.phtml'); ?>
|
||||
|
||||
<?= $this->render('show/components/servicegroups.phtml'); ?>
|
||||
<?= $this->render('show/components/downtime.phtml'); ?>
|
||||
|
||||
<?= $this->render('show/components/comments.phtml'); ?>
|
||||
|
||||
<?= $this->render('show/components/downtime.phtml'); ?>
|
||||
<?= $this->render('show/components/properties.phtml'); ?>
|
||||
|
||||
<?= $this->render('show/components/flags.phtml'); ?>
|
||||
|
||||
<?= $this->render('show/components/customvars.phtml'); ?>
|
||||
|
||||
<?= $this->render('show/components/perfdata.phtml'); ?>
|
||||
<?= $this->render('show/components/servicegroups.phtml'); ?>
|
||||
|
||||
<?= $this->render('show/components/properties.phtml'); ?>
|
||||
<?= $this->render('show/components/contacts.phtml'); ?>
|
||||
|
||||
<?= $this->render('show/components/eventHistory.phtml'); ?>
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Icinga\Module\Monitoring;
|
||||
|
||||
use Zend_config;
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config as IcingaConfig;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\Data\DatasourceInterface;
|
||||
@ -34,12 +34,13 @@ class Backend implements ConfigAwareFactory, DatasourceInterface
|
||||
/**
|
||||
* Create a new backend from the given resource config
|
||||
*
|
||||
* @param Zend_config $config
|
||||
* @param Zend_Config $backendConfig
|
||||
* @param Zend_Config $resourceConfig
|
||||
*/
|
||||
public function __construct(Zend_Config $config)
|
||||
public function __construct(Zend_Config $backendConfig, Zend_Config $resourceConfig)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->resource = ResourceFactory::createResource($config->resource);
|
||||
$this->config = $backendConfig;
|
||||
$this->resource = ResourceFactory::createResource($resourceConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,7 +73,7 @@ class Backend implements ConfigAwareFactory, DatasourceInterface
|
||||
*
|
||||
* @return Query
|
||||
*/
|
||||
public function from($table, array $columns)
|
||||
public function from($table, array $columns = null)
|
||||
{
|
||||
$queryClass = '\\Icinga\\Module\\Monitoring\\Backend\\'
|
||||
. ucfirst($this->config->type)
|
||||
@ -141,7 +142,7 @@ class Backend implements ConfigAwareFactory, DatasourceInterface
|
||||
}
|
||||
|
||||
$config = self::$backendConfigs[$name];
|
||||
self::$backendInstances[$name] = $backend = new self($config);
|
||||
self::$backendInstances[$name] = $backend = new self($config, ResourceFactory::getResourceConfig($config->resource));
|
||||
switch (strtolower($config->type)) {
|
||||
case 'ido':
|
||||
if ($backend->getResource()->getDbType() !== 'oracle') {
|
||||
|
@ -27,7 +27,7 @@ class StatusQuery extends Query
|
||||
public function init()
|
||||
{
|
||||
$target = $this->getTarget();
|
||||
$this->reader = $this->ds->getReader();
|
||||
$this->reader = $this->ds;
|
||||
$this->setResultViewClass(ucfirst($target)."StatusView");
|
||||
$this->setBaseQuery($this->reader->select()->from($target."s", array()));
|
||||
|
||||
|
@ -80,7 +80,7 @@ abstract class DataView
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function fromRequest(Request $request, array $columns = null)
|
||||
public static function fromRequest($request, array $columns = null)
|
||||
{
|
||||
$view = new static(Backend::createBackend($request->getParam('backend')), $columns);
|
||||
$view->filter($request->getParams());
|
||||
|
@ -53,6 +53,13 @@ class Host extends AbstractObject
|
||||
'long_output' => 'host_long_output',
|
||||
'check_command' => 'host_check_command',
|
||||
'perfdata' => 'host_perfdata',
|
||||
'host_icon_image',
|
||||
'passive_checks_enabled' => 'host_passive_checks_enabled',
|
||||
'obsessing' => 'host_obsessing',
|
||||
'notifications_enabled' => 'host_notifications_enabled',
|
||||
'event_handler_enabled' => 'host_event_handler_enabled',
|
||||
'flap_detection_enabled' => 'host_flap_detection_enabled',
|
||||
'active_checks_enabled' => 'host_active_checks_enabled'
|
||||
))->where('host_name', $this->name1)->fetchRow();
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,13 @@ class Service extends AbstractObject
|
||||
'current_notification_number' => 'service_current_notification_number',
|
||||
'is_flapping' => 'service_is_flapping',
|
||||
'percent_state_change' => 'service_percent_state_change',
|
||||
'in_downtime' => 'service_in_downtime'
|
||||
'in_downtime' => 'service_in_downtime',
|
||||
'passive_checks_enabled' => 'service_passive_checks_enabled',
|
||||
'obsessing' => 'service_obsessing',
|
||||
'notifications_enabled' => 'service_notifications_enabled',
|
||||
'event_handler_enabled' => 'service_event_handler_enabled',
|
||||
'flap_detection_enabled' => 'service_flap_detection_enabled',
|
||||
'active_checks_enabled' => 'service_active_checks_enabled'
|
||||
))
|
||||
->where('host_name', $this->name1)
|
||||
->where('service_description', $this->name2)
|
||||
|
@ -4,6 +4,11 @@ namespace Test\Monitoring\Application\Controllers\ListController;
|
||||
|
||||
require_once(dirname(__FILE__).'/../../testlib/MonitoringControllerTest.php');
|
||||
|
||||
require_once(dirname(__FILE__).'/../../../../library/Monitoring/DataView/DataView.php');
|
||||
require_once(dirname(__FILE__).'/../../../../library/Monitoring/DataView/HostAndServiceStatus.php');
|
||||
require_once(dirname(__FILE__).'/../../../../library/Monitoring/DataView/Notification.php');
|
||||
require_once(dirname(__FILE__).'/../../../../library/Monitoring/DataView/Downtime.php');
|
||||
|
||||
use Test\Monitoring\Testlib\MonitoringControllerTest;
|
||||
use Test\Monitoring\Testlib\Datasource\TestFixture;
|
||||
use Test\Monitoring\Testlib\Datasource\ObjectFlags;
|
||||
|
@ -21,10 +21,10 @@ class ListControllerServiceMySQLTest extends MonitoringControllerTest
|
||||
$this->executeServiceListTestFor("pgsql");
|
||||
}
|
||||
|
||||
public function testServiceListStatusdat()
|
||||
{
|
||||
$this->executeServiceListTestFor("statusdat");
|
||||
}
|
||||
// public function testServiceListStatusdat()
|
||||
// {
|
||||
// $this->executeServiceListTestFor("statusdat");
|
||||
// }
|
||||
|
||||
public function executeServiceListTestFor($backend)
|
||||
{
|
||||
@ -64,7 +64,6 @@ class ListControllerServiceMySQLTest extends MonitoringControllerTest
|
||||
$this->assertEquals("notes.url", $result[0]->service_notes_url, "Testing for correct notes_url");
|
||||
$this->assertEquals("action.url", $result[0]->service_action_url, "Testing for correct action_url");
|
||||
$this->assertEquals(0, $result[0]->service_state, "Testing for correct Service state");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,12 +11,12 @@ class MonitoringFlagsTest extends \PHPUnit_Framework_TestCase
|
||||
public function testHosts1()
|
||||
{
|
||||
$testArray = array(
|
||||
'host_passive_checks_enabled' => '0',
|
||||
'host_active_checks_enabled' => '0',
|
||||
'host_obsessing' => '1',
|
||||
'host_notifications_enabled' => '0',
|
||||
'host_event_handler_enabled' => '1',
|
||||
'host_flap_detection_enabled' => '1',
|
||||
'passive_checks_enabled' => '0',
|
||||
'active_checks_enabled' => '0',
|
||||
'obsessing' => '1',
|
||||
'notifications_enabled' => '0',
|
||||
'event_handler_enabled' => '1',
|
||||
'flap_detection_enabled' => '1',
|
||||
);
|
||||
|
||||
$monitoringFlags = new \Zend_View_Helper_MonitoringFlags();
|
||||
@ -39,12 +39,12 @@ class MonitoringFlagsTest extends \PHPUnit_Framework_TestCase
|
||||
public function testService1()
|
||||
{
|
||||
$testArray = array(
|
||||
'service_passive_checks_enabled' => '0',
|
||||
'service_active_checks_enabled' => '1',
|
||||
'service_obsessing' => '0',
|
||||
'service_notifications_enabled' => '1',
|
||||
'service_event_handler_enabled' => '1',
|
||||
'service_flap_detection_enabled' => '0',
|
||||
'passive_checks_enabled' => '0',
|
||||
'active_checks_enabled' => '1',
|
||||
'obsessing' => '0',
|
||||
'notifications_enabled' => '1',
|
||||
'event_handler_enabled' => '1',
|
||||
'flap_detection_enabled' => '0',
|
||||
);
|
||||
|
||||
$monitoringFlags = new \Zend_View_Helper_MonitoringFlags();
|
||||
@ -63,54 +63,4 @@ class MonitoringFlagsTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertEquals($expected, $returnArray);
|
||||
}
|
||||
|
||||
public function testUglyConditions1()
|
||||
{
|
||||
$testArray = array(
|
||||
'service_active_checks_enabled' => '1',
|
||||
'service_obsessing' => '1',
|
||||
'DING DING' => '$$$',
|
||||
'DONG DONG' => '###'
|
||||
);
|
||||
|
||||
$monitoringFlags = new \Zend_View_Helper_MonitoringFlags();
|
||||
$returnArray = $monitoringFlags->monitoringFlags((object)$testArray);
|
||||
|
||||
$this->assertCount(6, $returnArray);
|
||||
|
||||
$expected = array(
|
||||
'Passive Checks' => false,
|
||||
'Active Checks' => true,
|
||||
'Obsessing' => true,
|
||||
'Notifications' => false,
|
||||
'Event Handler' => false,
|
||||
'Flap Detection' => false
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $returnArray);
|
||||
}
|
||||
|
||||
public function testUglyConditions2()
|
||||
{
|
||||
$testArray = array(
|
||||
'DING DING' => '$$$',
|
||||
'DONG DONG' => '###'
|
||||
);
|
||||
|
||||
$monitoringFlags = new \Zend_View_Helper_MonitoringFlags();
|
||||
$returnArray = $monitoringFlags->monitoringFlags((object)$testArray);
|
||||
|
||||
$this->assertCount(6, $returnArray);
|
||||
|
||||
$expected = array(
|
||||
'Passive Checks' => false,
|
||||
'Active Checks' => false,
|
||||
'Obsessing' => false,
|
||||
'Notifications' => false,
|
||||
'Event Handler' => false,
|
||||
'Flap Detection' => false
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $returnArray);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ require_once 'Zend/View.php';
|
||||
require_once __DIR__. '/../../../../../application/views/helpers/MonitoringProperties.php';
|
||||
|
||||
/**
|
||||
* @TODO(el): This test is subject to bug #4679 and
|
||||
* @TODO(el): This test is subject to bug #4679 and
|
||||
*/
|
||||
class HostStruct4Properties extends \stdClass
|
||||
{
|
||||
@ -15,42 +15,42 @@ class HostStruct4Properties extends \stdClass
|
||||
public $host_address = '127.0.0.1';
|
||||
public $host_state = '1';
|
||||
public $host_handled = '1';
|
||||
public $host_in_downtime = '1';
|
||||
public $host_acknowledged = '1';
|
||||
public $host_check_command = 'check-host-alive';
|
||||
public $host_last_state_change = '1372937083';
|
||||
public $in_downtime = '1';
|
||||
public $acknowledged = '1';
|
||||
public $check_command = 'check-host-alive';
|
||||
public $last_state_change = '1372937083';
|
||||
public $host_alias = 'localhost';
|
||||
public $host_output = 'DDD';
|
||||
public $host_long_output = '';
|
||||
public $host_perfdata = '';
|
||||
public $host_current_check_attempt = '1';
|
||||
public $host_max_check_attempts = '10';
|
||||
public $host_attempt = '1/10';
|
||||
public $host_last_check = '2013-07-04 11:24:42';
|
||||
public $host_next_check = '2013-07-04 11:29:43';
|
||||
public $host_check_type = '1';
|
||||
public $host_last_hard_state_change = '2013-07-04 11:24:43';
|
||||
public $host_last_hard_state = '0';
|
||||
public $host_last_time_up = '2013-07-04 11:20:23';
|
||||
public $host_last_time_down = '2013-07-04 11:24:43';
|
||||
public $host_last_time_unreachable = '0000-00-00 00:00:00';
|
||||
public $host_state_type = '1';
|
||||
public $host_last_notification = '0000-00-00 00:00:00';
|
||||
public $host_next_notification = '0000-00-00 00:00:00';
|
||||
public $host_no_more_notifications = '0';
|
||||
public $output = 'DDD';
|
||||
public $long_output = '';
|
||||
public $perfdata = '';
|
||||
public $current_check_attempt = '1';
|
||||
public $max_check_attempts = '10';
|
||||
public $attempt = '1/10';
|
||||
public $last_check = '2013-07-04 11:24:42';
|
||||
public $next_check = '2013-07-04 11:29:43';
|
||||
public $heck_type = '1';
|
||||
public $last_hard_state_change = '2013-07-04 11:24:43';
|
||||
public $last_hard_state = '0';
|
||||
public $last_time_up = '2013-07-04 11:20:23';
|
||||
public $last_time_down = '2013-07-04 11:24:43';
|
||||
public $last_time_unreachable = '0000-00-00 00:00:00';
|
||||
public $state_type = '1';
|
||||
public $last_notification = '0000-00-00 00:00:00';
|
||||
public $next_notification = '0000-00-00 00:00:00';
|
||||
public $no_more_notifications = '0';
|
||||
public $host_notifications_enabled = '1';
|
||||
public $host_problem_has_been_acknowledged = '1';
|
||||
public $host_acknowledgement_type = '2';
|
||||
public $host_current_notification_number = '0';
|
||||
public $host_passive_checks_enabled = '1';
|
||||
public $host_active_checks_enabled = '0';
|
||||
public $host_event_handler_enabled = '0';
|
||||
public $host_flap_detection_enabled = '1';
|
||||
public $host_is_flapping = '0';
|
||||
public $host_percent_state_change = '12.36842';
|
||||
public $host_check_latency = '0.12041';
|
||||
public $host_check_execution_time = '0';
|
||||
public $host_scheduled_downtime_depth = '1';
|
||||
public $current_notification_number = '0';
|
||||
public $passive_checks_enabled = '1';
|
||||
public $active_checks_enabled = '0';
|
||||
public $event_handler_enabled = '0';
|
||||
public $flap_detection_enabled = '1';
|
||||
public $is_flapping = '0';
|
||||
public $percent_state_change = '12.36842';
|
||||
public $check_latency = '0.12041';
|
||||
public $check_execution_time = '0';
|
||||
public $scheduled_downtime_depth = '1';
|
||||
public $host_failure_prediction_enabled = '1';
|
||||
public $host_process_performance_data = '1';
|
||||
public $host_obsessing = '1';
|
||||
@ -67,41 +67,34 @@ class MonitoringPropertiesTest extends \PHPUnit_Framework_TestCase
|
||||
public function testOutput1()
|
||||
{
|
||||
$host = new HostStruct4Properties();
|
||||
$host->host_current_check_attempt = '5';
|
||||
$host->current_check_attempt = '5';
|
||||
|
||||
$propertyHelper = new \Zend_View_Helper_MonitoringProperties();
|
||||
$items = $propertyHelper->monitoringProperties($host);
|
||||
|
||||
$this->assertCount(10, $items);
|
||||
$this->assertEquals('5/10 (HARD state)', $items['Current Attempt']);
|
||||
$this->assertEquals('2013-07-08 10:10:10', $items['Last Update']);
|
||||
}
|
||||
|
||||
public function testOutput2()
|
||||
{
|
||||
date_default_timezone_set("UTC");
|
||||
$host = new HostStruct4Properties();
|
||||
$host->host_current_check_attempt = '5';
|
||||
$host->host_active_checks_enabled = '1';
|
||||
$host->host_passive_checks_enabled = '0';
|
||||
$host->host_is_flapping = '1';
|
||||
$host->current_check_attempt = '5';
|
||||
$host->active_checks_enabled = '1';
|
||||
$host->passive_checks_enabled = '0';
|
||||
$host->is_flapping = '1';
|
||||
|
||||
$propertyHelper = new \Zend_View_Helper_MonitoringProperties();
|
||||
$items = $propertyHelper->monitoringProperties($host);
|
||||
|
||||
$this->assertCount(10, $items);
|
||||
|
||||
$test = array(
|
||||
'Current Attempt' => "5/10 (HARD state)",
|
||||
'Last Check Time' => "2013-07-04 11:24:42",
|
||||
'Check Type' => "ACTIVE",
|
||||
'Check Latency / Duration' => "0.1204 / 0.0000 seconds",
|
||||
'Next Scheduled Active Check' => "2013-07-04 11:29:43",
|
||||
'Last State Change' => "2013-07-04 11:24:43",
|
||||
'Last Notification' => "N/A (notification 0)",
|
||||
'Is This Host Flapping?' => "YES (12.37% state change)",
|
||||
'In Scheduled Downtime?' => "YES",
|
||||
'Last Update' => "2013-07-08 10:10:10",
|
||||
'In Scheduled Downtime?' => "YES"
|
||||
);
|
||||
|
||||
$this->assertEquals($test, $items);
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Monitoring\Backend\Statusdat;
|
||||
|
||||
use Zend_Config;
|
||||
use Tests\Icinga\Protocol\Statusdat\ReaderMock as ReaderMock;
|
||||
use \Icinga\Module\Monitoring\Backend\Statusdat\Query\ServicegroupsummaryQuery;
|
||||
use Tests\Icinga\Protocol\Statusdat\StatusdatTestLoader;
|
||||
@ -30,10 +32,12 @@ class BackendMock extends \Icinga\Module\Monitoring\Backend\AbstractBackend
|
||||
|
||||
class ServicegroupsummaryqueryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function testGroupByProblemType()
|
||||
{
|
||||
$backend = new BackendMock();
|
||||
$backendConfig = new Zend_Config(
|
||||
array()
|
||||
);
|
||||
$backend = new BackendMock($backendConfig);
|
||||
$backend->setReader($this->getTestDataset());
|
||||
$q = new ServicegroupsummaryQuery($backend);
|
||||
$indices = array(
|
||||
|
@ -37,10 +37,10 @@ use \Zend_Test_PHPUnit_ControllerTestCase;
|
||||
use \Icinga\Protocol\Statusdat\Reader;
|
||||
use \Icinga\Web\Controller\ActionController;
|
||||
use \Icinga\Application\DbAdapterFactory;
|
||||
use \Icinga\Module\Monitoring\Backend\Ido;
|
||||
use \Icinga\Module\Monitoring\Backend\Statusdat;
|
||||
use \Test\Monitoring\Testlib\DataSource\TestFixture;
|
||||
use \Test\Monitoring\Testlib\DataSource\DataSourceTestSetup;
|
||||
use Icinga\Module\Monitoring\Backend;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
|
||||
/**
|
||||
* Base class for monitoring controllers that loads required dependencies
|
||||
@ -81,11 +81,13 @@ abstract class MonitoringControllerTest extends Zend_Test_PHPUnit_ControllerTest
|
||||
private $appDir = "";
|
||||
|
||||
/**
|
||||
* Require necessary libraries on test creation
|
||||
* Require necessary libraries on test creation
|
||||
*
|
||||
* This is called for every test and assures that all required libraries for the controllers
|
||||
* are loaded. If you need additional dependencies you should overwrite this method, call the parent
|
||||
* and then require your classes
|
||||
* This is called for every test and assures that all required libraries for the controllers
|
||||
* are loaded. If you need additional dependencies you should overwrite this method, call the parent
|
||||
* and then require your classes
|
||||
*
|
||||
* @backupStaticAttributes enabled
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
@ -102,6 +104,49 @@ abstract class MonitoringControllerTest extends Zend_Test_PHPUnit_ControllerTest
|
||||
|
||||
$this->requireBase();
|
||||
$this->requireViews();
|
||||
|
||||
ResourceFactory::setConfig(
|
||||
new Zend_Config(array(
|
||||
'statusdat-unittest' => array(
|
||||
'type' => 'statusdat',
|
||||
'status_file' => '/tmp/teststatus.dat',
|
||||
'objects_file' => '/tmp/testobjects.cache',
|
||||
'no_cache' => true
|
||||
),
|
||||
'ido-mysql-unittest' => array(
|
||||
'type' => 'db',
|
||||
'db' => 'mysql',
|
||||
'host' => 'localhost',
|
||||
'username' => 'icinga_unittest',
|
||||
'password' => 'icinga_unittest',
|
||||
'dbname' => 'icinga_unittest'
|
||||
),
|
||||
'ido-pgsql-unittest' => array(
|
||||
'type' => 'db',
|
||||
'db' => 'mysql',
|
||||
'host' => 'localhost',
|
||||
'username' => 'icinga_unittest',
|
||||
'password' => 'icinga_unittest',
|
||||
'dbname' => 'icinga_unittest'
|
||||
)
|
||||
))
|
||||
);
|
||||
Backend::setConfig(
|
||||
new Zend_Config(array(
|
||||
'statusdat-unittest' => array(
|
||||
'type' => 'statusdat',
|
||||
'resource' => 'statusdat-unittest'
|
||||
),
|
||||
'ido-mysql-unittest' => array(
|
||||
'type' => 'ido',
|
||||
'resource' => 'ido-mysql-unittest'
|
||||
),
|
||||
'ido-pgsql-unittest' => array(
|
||||
'type' => 'ido',
|
||||
'resource' => 'ido-pgsql-unittest'
|
||||
)
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -118,6 +163,7 @@ abstract class MonitoringControllerTest extends Zend_Test_PHPUnit_ControllerTest
|
||||
require_once('Exception/ProgrammingError.php');
|
||||
require_once('Web/Widget/SortBox.php');
|
||||
require_once('library/Monitoring/Backend/AbstractBackend.php');
|
||||
require_once('library/Monitoring/Backend.php');
|
||||
|
||||
}
|
||||
|
||||
@ -128,7 +174,6 @@ abstract class MonitoringControllerTest extends Zend_Test_PHPUnit_ControllerTest
|
||||
private function requireIDOQueries()
|
||||
{
|
||||
require_once('Application/DbAdapterFactory.php');
|
||||
require_once('library/Monitoring/Backend/Ido.php');
|
||||
$this->requireFolder('library/Monitoring/Backend/Ido/Query');
|
||||
}
|
||||
|
||||
@ -155,7 +200,6 @@ abstract class MonitoringControllerTest extends Zend_Test_PHPUnit_ControllerTest
|
||||
*/
|
||||
private function requireStatusDatQueries()
|
||||
{
|
||||
require_once(realpath($this->moduleDir.'/library/Monitoring/Backend/Statusdat.php'));
|
||||
require_once(realpath($this->moduleDir.'/library/Monitoring/Backend/Statusdat/Query/Query.php'));
|
||||
$this->requireFolder('library/Monitoring/Backend/Statusdat');
|
||||
$this->requireFolder('library/Monitoring/Backend/Statusdat/Criteria');
|
||||
@ -186,9 +230,17 @@ abstract class MonitoringControllerTest extends Zend_Test_PHPUnit_ControllerTest
|
||||
{
|
||||
require_once($this->moduleDir.'/application/controllers/'.$controller.'.php');
|
||||
$controllerName = '\Monitoring_'.ucfirst($controller);
|
||||
$request = $this->getRequest();
|
||||
if ($backend == 'statusdat') {
|
||||
$this->requireStatusDatQueries();
|
||||
$request->setParam('backend', 'statusdat-unittest');
|
||||
} else {
|
||||
$this->requireStatusDatQueries();
|
||||
$request->setParam('backend', "ido-$backend-unittest");
|
||||
}
|
||||
/** @var ActionController $controller */
|
||||
$controller = new $controllerName(
|
||||
$this->getRequest(),
|
||||
$request,
|
||||
$this->getResponse(),
|
||||
array('noInit' => true)
|
||||
);
|
||||
@ -223,9 +275,11 @@ abstract class MonitoringControllerTest extends Zend_Test_PHPUnit_ControllerTest
|
||||
{
|
||||
if ($type == "mysql" || $type == "pgsql") {
|
||||
$this->requireIDOQueries();
|
||||
|
||||
$resourceConfig = array(
|
||||
'icinga-db-unittest' => array(
|
||||
$backendConfig = new Zend_Config(array(
|
||||
'type' => 'ido'
|
||||
));
|
||||
$resourceConfig = new Zend_Config(
|
||||
array(
|
||||
'type' => 'db',
|
||||
'db' => $type,
|
||||
'host' => "localhost",
|
||||
@ -234,29 +288,24 @@ abstract class MonitoringControllerTest extends Zend_Test_PHPUnit_ControllerTest
|
||||
'dbname' => "icinga_unittest"
|
||||
)
|
||||
);
|
||||
|
||||
DbAdapterFactory::resetConfig();
|
||||
DbAdapterFactory::setConfig($resourceConfig);
|
||||
|
||||
$backendConfig = array(
|
||||
'type' => 'db',
|
||||
'resource' => 'icinga-db-unittest'
|
||||
);
|
||||
|
||||
return new Ido(
|
||||
new Zend_Config($backendConfig)
|
||||
);
|
||||
return new Backend($backendConfig, $resourceConfig);
|
||||
} elseif ($type == "statusdat") {
|
||||
$this->requireStatusDatQueries();
|
||||
return new Statusdat(
|
||||
new \Zend_Config(
|
||||
array(
|
||||
'status_file' => '/tmp/teststatus.dat',
|
||||
'objects_file' => '/tmp/testobjects.cache',
|
||||
'no_cache' => true
|
||||
)
|
||||
$backendConfig = new Zend_Config(array(
|
||||
'type' => 'statusdat'
|
||||
));
|
||||
$resourceConfig = new Zend_Config(
|
||||
array(
|
||||
'type' => 'statusdat',
|
||||
'status_file' => '/tmp/teststatus.dat',
|
||||
'objects_file' => '/tmp/testobjects.cache',
|
||||
'no_cache' => true
|
||||
)
|
||||
);
|
||||
return new Backend(
|
||||
$backendConfig,
|
||||
$resourceConfig
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,11 @@
|
||||
|
||||
namespace Tests\Icinga\Web\Paginator\Adapter;
|
||||
|
||||
use \Icinga\Module\Monitoring\Backend\Statusdat;
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use Zend_Config;
|
||||
use Icinga\Protocol\Statusdat\Reader;
|
||||
use Icinga\Web\Paginator\Adapter\QueryAdapter;
|
||||
use Icinga\Module\Monitoring\Backend;
|
||||
use Tests\Icinga\Protocol\Statusdat\StatusdatTestLoader;
|
||||
|
||||
require_once 'Zend/Paginator/Adapter/Interface.php';
|
||||
@ -17,19 +19,22 @@ StatusdatTestLoader::requireLibrary();
|
||||
require_once '../../modules/monitoring/library/Monitoring/Backend/Statusdat/Criteria/Order.php';
|
||||
require_once '../../modules/monitoring/library/Monitoring/Backend/AbstractBackend.php';
|
||||
require_once '../../modules/monitoring/library/Monitoring/Backend/Statusdat/Query/Query.php';
|
||||
require_once '../../modules/monitoring/library/Monitoring/Backend/Statusdat.php';
|
||||
require_once '../../modules/monitoring/library/Monitoring/Backend/Statusdat/Query/StatusQuery.php';
|
||||
require_once '../../modules/monitoring/library/Monitoring/Backend/Statusdat/DataView/HostStatusView.php';
|
||||
require_once '../../modules/monitoring/library/Monitoring/View/AbstractView.php';
|
||||
require_once '../../modules/monitoring/library/Monitoring/View/StatusView.php';
|
||||
require_once '../../modules/monitoring/library/Monitoring/Backend.php';
|
||||
|
||||
require_once '../../library/Icinga/Protocol/AbstractQuery.php';
|
||||
require_once '../../library/Icinga/Data/ResourceFactory.php';
|
||||
|
||||
class QueryAdapterTest extends \PHPUnit_Framework_TestCase
|
||||
class QueryAdapterTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $cacheDir;
|
||||
|
||||
private $config;
|
||||
private $backendConfig;
|
||||
|
||||
private $resourceConfig;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
@ -39,20 +44,26 @@ class QueryAdapterTest extends \PHPUnit_Framework_TestCase
|
||||
mkdir($this->cacheDir);
|
||||
}
|
||||
|
||||
$statusdatFile = dirname(__FILE__). '/../../../../../res/status/icinga.status.dat';
|
||||
$cacheFile = dirname(__FILE__). '/../../../../../res/status/icinga.objects.cache';
|
||||
$statusdatFile = dirname(__FILE__) . '/../../../../../res/status/icinga.status.dat';
|
||||
$cacheFile = dirname(__FILE__) . '/../../../../../res/status/icinga.objects.cache';
|
||||
|
||||
$this->config = new \Zend_Config(
|
||||
$this->backendConfig = new Zend_Config(
|
||||
array(
|
||||
'status_file' => $statusdatFile,
|
||||
'objects_file' => $cacheFile
|
||||
'type' => 'statusdat'
|
||||
)
|
||||
);
|
||||
$this->resourceConfig = new Zend_Config(
|
||||
array(
|
||||
'status_file' => $statusdatFile,
|
||||
'objects_file' => $cacheFile,
|
||||
'type' => 'statusdat'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testLimit1()
|
||||
{
|
||||
$backend = new Statusdat($this->config);
|
||||
$backend = new Backend($this->backendConfig, $this->resourceConfig);
|
||||
$query = $backend->select()->from('status');
|
||||
|
||||
$adapter = new QueryAdapter($query);
|
||||
@ -69,7 +80,7 @@ class QueryAdapterTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testLimit2()
|
||||
{
|
||||
$backend = new Statusdat($this->config);
|
||||
$backend = new Backend($this->backendConfig, $this->resourceConfig);
|
||||
$query = $backend->select()->from('status');
|
||||
|
||||
$adapter = new QueryAdapter($query);
|
||||
|
@ -2,10 +2,13 @@
|
||||
|
||||
namespace Tests\Icinga\Web\Paginator\ScrollingStyle;
|
||||
|
||||
use \Icinga\Module\Monitoring\Backend\Statusdat;
|
||||
use Zend_Config;
|
||||
use Zend_Paginator_Adapter_Interface;
|
||||
use Icinga\Module\Monitoring\Backend\Statusdat;
|
||||
use Icinga\Protocol\Statusdat\Reader;
|
||||
use Icinga\Web\Paginator\Adapter\QueryAdapter;
|
||||
use Tests\Icinga\Protocol\Statusdat\StatusdatTestLoader;
|
||||
use Icinga\Module\Monitoring\Backend;
|
||||
|
||||
require_once 'Zend/Paginator/Adapter/Interface.php';
|
||||
require_once 'Zend/Paginator/ScrollingStyle/Interface.php';
|
||||
@ -20,15 +23,15 @@ StatusdatTestLoader::requireLibrary();
|
||||
|
||||
require_once '../../modules/monitoring/library/Monitoring/Backend/Statusdat/Criteria/Order.php';
|
||||
require_once '../../modules/monitoring/library/Monitoring/Backend/AbstractBackend.php';
|
||||
require_once '../../modules/monitoring/library/Monitoring/Backend.php';
|
||||
require_once '../../modules/monitoring/library/Monitoring/Backend/Statusdat/Query/Query.php';
|
||||
require_once '../../modules/monitoring/library/Monitoring/Backend/Statusdat.php';
|
||||
require_once '../../modules/monitoring/library/Monitoring/Backend/Statusdat/Query/StatusQuery.php';
|
||||
require_once '../../modules/monitoring/library/Monitoring/Backend/Statusdat/DataView/HostStatusView.php';
|
||||
require_once '../../modules/monitoring/library/Monitoring/View/AbstractView.php';
|
||||
require_once '../../modules/monitoring/library/Monitoring/View/StatusView.php';
|
||||
require_once '../../library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorder.php';
|
||||
|
||||
class TestPaginatorAdapter implements \Zend_Paginator_Adapter_Interface
|
||||
class TestPaginatorAdapter implements Zend_Paginator_Adapter_Interface
|
||||
{
|
||||
private $items = array();
|
||||
|
||||
@ -80,7 +83,9 @@ class SlidingwithborderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $cacheDir;
|
||||
|
||||
private $config;
|
||||
private $backendConfig;
|
||||
|
||||
private $resourceConfig;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
@ -93,17 +98,23 @@ class SlidingwithborderTest extends \PHPUnit_Framework_TestCase
|
||||
$statusdatFile = dirname(__FILE__). '/../../../../../res/status/icinga.status.dat';
|
||||
$cacheFile = dirname(__FILE__). '/../../../../../res/status/icinga.objects.cache';
|
||||
|
||||
$this->config = new \Zend_Config(
|
||||
$this->backendConfig = new Zend_Config(
|
||||
array(
|
||||
'status_file' => $statusdatFile,
|
||||
'objects_file' => $cacheFile
|
||||
'type' => 'statusdat'
|
||||
)
|
||||
);
|
||||
$this->resourceConfig = new Zend_Config(
|
||||
array(
|
||||
'status_file' => $statusdatFile,
|
||||
'objects_file' => $cacheFile,
|
||||
'type' => 'statusdat'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetPages1()
|
||||
{
|
||||
$backend = new Statusdat($this->config);
|
||||
$backend = new Backend($this->backendConfig, $this->resourceConfig);
|
||||
$query = $backend->select()->from('status');
|
||||
|
||||
$adapter = new QueryAdapter($query);
|
||||
|
Loading…
x
Reference in New Issue
Block a user