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