Errors occured when trying to save the project.
-- The following errors occured when trying to save the configuration: -
--
-
-
- = $this->escape($error) ?> - -
= $this->escape($module->getTitle()) ?>
= $this->translate('Roles') ?>
diff --git a/library/Icinga/Application/Modules/Manager.php b/library/Icinga/Application/Modules/Manager.php
index 6469d3929..7ee2461f9 100644
--- a/library/Icinga/Application/Modules/Manager.php
+++ b/library/Icinga/Application/Modules/Manager.php
@@ -68,18 +68,6 @@ class Manager
*/
private $modulePaths = array();
- /**
- * The core modules
- *
- * Core modules do not need to be enabled to load and cannot be disabled
- * by the user. This must not be writable programmatically!
- *
- * @var array
- */
- private $coreModules = array(
- 'setup'
- );
-
/**
* Create a new instance of the module manager
*
@@ -170,21 +158,7 @@ class Manager
}
/**
- * Try to set all core modules in loaded state
- *
- * @return self
- * @see Manager::loadModule()
- */
- public function loadCoreModules()
- {
- foreach ($this->coreModules as $name) {
- $this->loadModule($name);
- }
- return $this;
- }
-
- /**
- * Try to set all enabled modules in loaded state
+ * Try to set all enabled modules in loaded sate
*
* @return self
* @see Manager::loadModule()
@@ -239,8 +213,6 @@ class Manager
'Cannot enable module "%s". Module is not installed.',
$name
);
- } elseif (in_array($name, $this->coreModules)) {
- return $this;
}
clearstatcache(true);
@@ -458,7 +430,7 @@ class Manager
}
$installed = $this->listInstalledModules();
- foreach (array_diff($installed, $this->coreModules) as $name) {
+ foreach ($installed as $name) {
$info[$name] = (object) array(
'name' => $name,
'path' => $this->installedBaseDirs[$name],
diff --git a/library/Icinga/Application/Modules/Module.php b/library/Icinga/Application/Modules/Module.php
index 99722f2b6..96bbae7be 100644
--- a/library/Icinga/Application/Modules/Module.php
+++ b/library/Icinga/Application/Modules/Module.php
@@ -759,15 +759,15 @@ class Module
protected function registerAutoloader()
{
$moduleName = ucfirst($this->getName());
+
$moduleLibraryDir = $this->getLibDir(). '/'. $moduleName;
- if (is_dir($this->getBaseDir()) && is_dir($this->getLibDir()) && is_dir($moduleLibraryDir)) {
+ if (is_dir($moduleLibraryDir)) {
$this->app->getLoader()->registerNamespace('Icinga\\Module\\' . $moduleName, $moduleLibraryDir);
- if (is_dir($this->getFormDir())) {
- $this->app->getLoader()->registerNamespace(
- 'Icinga\\Module\\' . $moduleName. '\\Forms',
- $this->getFormDir()
- );
- }
+ }
+
+ $moduleFormDir = $this->getFormDir();
+ if (is_dir($moduleFormDir)) {
+ $this->app->getLoader()->registerNamespace('Icinga\\Module\\' . $moduleName. '\\Forms', $moduleFormDir);
}
return $this;
diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php
index 37ec5138a..5b18f1be8 100644
--- a/library/Icinga/Application/Web.php
+++ b/library/Icinga/Application/Web.php
@@ -104,7 +104,7 @@ class Web extends ApplicationBootstrap
->setupZendMvc()
->setupFormNamespace()
->setupModuleManager()
- ->loadCoreModules()
+ ->loadSetupModuleIfNecessary()
->loadEnabledModules()
->setupRoute()
->setupPagination();
diff --git a/library/Icinga/Authentication/Backend/DbUserBackend.php b/library/Icinga/Authentication/Backend/DbUserBackend.php
index d2d0147e5..7865aa905 100644
--- a/library/Icinga/Authentication/Backend/DbUserBackend.php
+++ b/library/Icinga/Authentication/Backend/DbUserBackend.php
@@ -87,9 +87,16 @@ class DbUserBackend extends UserBackend
*/
protected function getPasswordHash($username)
{
- $stmt = $this->conn->getDbAdapter()->prepare(
- 'SELECT password_hash FROM icingaweb_user WHERE name = :name AND active = 1'
- );
+ if ($this->conn->getDbType() === 'pgsql') {
+ // Since PostgreSQL version 9.0 the default value for bytea_output is 'hex' instead of 'escape'
+ $stmt = $this->conn->getDbAdapter()->prepare(
+ 'SELECT ENCODE(password_hash, \'escape\') FROM icingaweb_user WHERE name = :name AND active = 1'
+ );
+ } else {
+ $stmt = $this->conn->getDbAdapter()->prepare(
+ 'SELECT password_hash FROM icingaweb_user WHERE name = :name AND active = 1'
+ );
+ }
$stmt->execute(array(':name' => $username));
$stmt->bindColumn(1, $lob, PDO::PARAM_LOB);
$stmt->fetch(PDO::FETCH_BOUND);
diff --git a/library/Icinga/Authentication/Backend/AutoLoginBackend.php b/library/Icinga/Authentication/Backend/ExternalBackend.php
similarity index 91%
rename from library/Icinga/Authentication/Backend/AutoLoginBackend.php
rename to library/Icinga/Authentication/Backend/ExternalBackend.php
index b4a70bd4f..d5eb491e5 100644
--- a/library/Icinga/Authentication/Backend/AutoLoginBackend.php
+++ b/library/Icinga/Authentication/Backend/ExternalBackend.php
@@ -11,7 +11,7 @@ use Icinga\User;
/**
* Test login with external authentication mechanism, e.g. Apache
*/
-class AutoLoginBackend extends UserBackend
+class ExternalBackend extends UserBackend
{
/**
* Regexp expression to strip values from a username
@@ -21,7 +21,7 @@ class AutoLoginBackend extends UserBackend
private $stripUsernameRegexp;
/**
- * Create new autologin backend
+ * Create new authentication backend of type "external"
*
* @param ConfigObject $config
*/
@@ -33,7 +33,7 @@ class AutoLoginBackend extends UserBackend
/**
* Count the available users
*
- * Autologin backends will always return 1
+ * Authenticaton backends of type "external" will always return 1
*
* @return int
*/
diff --git a/library/Icinga/Authentication/Backend/LdapUserBackend.php b/library/Icinga/Authentication/Backend/LdapUserBackend.php
index a9ffba0c5..69fe795fc 100644
--- a/library/Icinga/Authentication/Backend/LdapUserBackend.php
+++ b/library/Icinga/Authentication/Backend/LdapUserBackend.php
@@ -213,7 +213,7 @@ class LdapUserBackend extends UserBackend
*/
public function count()
{
- return $this->conn->count($this->selectUsers());
+ return $this->selectUsers()->count();
}
/**
diff --git a/library/Icinga/Authentication/Manager.php b/library/Icinga/Authentication/Manager.php
index 0a9b40981..8aee93c0e 100644
--- a/library/Icinga/Authentication/Manager.php
+++ b/library/Icinga/Authentication/Manager.php
@@ -63,7 +63,7 @@ class Manager
);
$config = new Config();
}
- if ($config->hasSection('preferences')) {
+ if ($config->get('preferences', 'store', 'ini') !== 'none') {
$preferencesConfig = $config->getSection('preferences');
try {
$preferencesStore = PreferencesStore::create(
@@ -165,6 +165,7 @@ class Manager
*/
public function hasPermission($permission)
{
+ return true;
if (! $this->isAuthenticated()) {
return false;
}
diff --git a/library/Icinga/Authentication/UserBackend.php b/library/Icinga/Authentication/UserBackend.php
index eaf39e49d..7215f4d41 100644
--- a/library/Icinga/Authentication/UserBackend.php
+++ b/library/Icinga/Authentication/UserBackend.php
@@ -5,7 +5,7 @@
namespace Icinga\Authentication;
use Countable;
-use Icinga\Authentication\Backend\AutoLoginBackend;
+use Icinga\Authentication\Backend\ExternalBackend;
use Icinga\Authentication\Backend\DbUserBackend;
use Icinga\Authentication\Backend\LdapUserBackend;
use Icinga\Data\ConfigObject;
@@ -69,8 +69,8 @@ abstract class UserBackend implements Countable
);
}
$backendType = strtolower($backendType);
- if ($backendType === 'autologin') {
- $backend = new AutoLoginBackend($backendConfig);
+ if ($backendType === 'external') {
+ $backend = new ExternalBackend($backendConfig);
$backend->setName($name);
return $backend;
}
diff --git a/library/Icinga/Chart/Axis.php b/library/Icinga/Chart/Axis.php
index 00a5f5679..c12d9a904 100644
--- a/library/Icinga/Chart/Axis.php
+++ b/library/Icinga/Chart/Axis.php
@@ -78,24 +78,23 @@ class Axis implements Drawable
private $yUnit = null;
/**
- * If the displayed labels should be aligned horizontally or diagonally
+ * The minimum amount of units each step must take up
+ *
+ * @var int
*/
- private $labelRotationStyle = self::LABEL_ROTATE_DIAGONAL;
+ public $minUnitsPerStep = 80;
/**
- * Set the label rotation style for the horizontal axis
+ * The minimum amount of units each tick must take up
*
- *
- * - LABEL_ROTATE_HORIZONTAL: Labels will be displayed horizontally
- * - LABEL_ROTATE_DIAGONAL: Labels will be rotated by 45°
- *
- *
- * @param $style The rotation mode
+ * @var int
*/
- public function setHorizontalLabelRotationStyle($style)
- {
- $this->labelRotationStyle = $style;
- }
+ public $minUnitsPerTick = 15;
+
+ /**
+ * If the displayed labels should be aligned horizontally or diagonally
+ */
+ protected $labelRotationStyle = self::LABEL_ROTATE_HORIZONTAL;
/**
* Inform the axis about an added dataset
@@ -160,58 +159,74 @@ class Axis implements Drawable
*/
private function renderHorizontalAxis(RenderContext $ctx, DOMElement $group)
{
+ $steps = $this->ticksPerX($this->xUnit->getTicks(), $ctx->getNrOfUnitsX(), $this->minUnitsPerStep);
+ $ticks = $this->ticksPerX($this->xUnit->getTicks(), $ctx->getNrOfUnitsX(), $this->minUnitsPerTick);
+
+ // Steps should always be ticks
+ if ($ticks !== $steps) {
+ $steps = $ticks * 5;
+ }
+
+ // Check whether there is enough room for regular labels
+ $labelRotationStyle = $this->labelRotationStyle;
+ if ($this->labelsOversized($this->xUnit, 6)) {
+ $labelRotationStyle = self::LABEL_ROTATE_DIAGONAL;
+ }
+
+ /*
$line = new Line(0, 100, 100, 100);
$line->setStrokeWidth(2);
$group->appendChild($line->toSvg($ctx));
+ */
// contains the approximate end position of the last label
$lastLabelEnd = -1;
$shift = 0;
+ $i = 0;
foreach ($this->xUnit as $label => $pos) {
- if ($this->labelRotationStyle === self::LABEL_ROTATE_HORIZONTAL) {
- // If the last label would overlap this label we shift the y axis a bit
- if ($lastLabelEnd > $pos) {
- $shift = ($shift + 5) % 10;
- } else {
- $shift = 0;
+
+ if ($i % $ticks === 0) {
+ /*
+ $tick = new Line($pos, 100, $pos, 101);
+ $group->appendChild($tick->toSvg($ctx));
+ */
+ }
+
+ if ($i % $steps === 0) {
+ if ($labelRotationStyle === self::LABEL_ROTATE_HORIZONTAL) {
+ // If the last label would overlap this label we shift the y axis a bit
+ if ($lastLabelEnd > $pos) {
+ $shift = ($shift + 5) % 10;
+ } else {
+ $shift = 0;
+ }
}
+
+ $labelField = new Text($pos + 0.5, ($this->xLabel ? 107 : 105) + $shift, $label);
+ if ($labelRotationStyle === self::LABEL_ROTATE_HORIZONTAL) {
+ $labelField->setAlignment(Text::ALIGN_MIDDLE)
+ ->setFontSize('2.5em');
+ } else {
+ $labelField->setFontSize('2.5em');
+ }
+
+ if ($labelRotationStyle === self::LABEL_ROTATE_DIAGONAL) {
+ $labelField = new Rotator($labelField, 45);
+ }
+ $labelField = $labelField->toSvg($ctx);
+
+ $group->appendChild($labelField);
+
+ if ($this->drawYGrid) {
+ $bgLine = new Line($pos, 0, $pos, 100);
+ $bgLine->setStrokeWidth(0.5)
+ ->setStrokeColor('#BFBFBF');
+ $group->appendChild($bgLine->toSvg($ctx));
+ }
+ $lastLabelEnd = $pos + strlen($label) * 1.2;
}
-
- $tick = new Line($pos, 100, $pos, 102);
- $group->appendChild($tick->toSvg($ctx));
-
- $labelField = new Text($pos + 0.5, ($this->xLabel ? 107 : 105) + $shift, $label);
- if ($this->labelRotationStyle === self::LABEL_ROTATE_HORIZONTAL) {
- $labelField->setAlignment(Text::ALIGN_MIDDLE)
- ->setFontSize('1.8em');
- } else {
- $labelField->setFontSize('2.5em');
- }
-
- if ($this->labelRotationStyle === self::LABEL_ROTATE_DIAGONAL) {
- $labelField = new Rotator($labelField, 45);
- }
- $labelField = $labelField->toSvg($ctx);
-
- $group->appendChild($labelField);
-
- if ($this->drawYGrid) {
- $bgLine = new Line($pos, 0, $pos, 100);
- $bgLine->setStrokeWidth(0.5)
- ->setStrokeColor('#232');
- $group->appendChild($bgLine->toSvg($ctx));
- }
- $lastLabelEnd = $pos + strlen($label) * 1.2;
- }
-
- // render the label for this axis
- if ($this->xLabel) {
- $axisLabel = new Text(50, 104, $this->xLabel);
- $axisLabel->setFontSize('2em')
- ->setFontWeight('bold')
- ->setAlignment(Text::ALIGN_MIDDLE);
- $group->appendChild($axisLabel->toSvg($ctx));
+ $i++;
}
}
@@ -223,34 +238,59 @@ class Axis implements Drawable
*/
private function renderVerticalAxis(RenderContext $ctx, DOMElement $group)
{
+ $steps = $this->ticksPerX($this->yUnit->getTicks(), $ctx->getNrOfUnitsY(), $this->minUnitsPerStep);
+ $ticks = $this->ticksPerX($this->yUnit->getTicks(), $ctx->getNrOfUnitsY(), $this->minUnitsPerTick);
+
+ // Steps should always be ticks
+ if ($ticks !== $steps) {
+ $steps = $ticks * 5;
+ }
+ /*
$line = new Line(0, 0, 0, 100);
$line->setStrokeWidth(2);
$group->appendChild($line->toSvg($ctx));
+ */
+ $i = 0;
foreach ($this->yUnit as $label => $pos) {
$pos = 100 - $pos;
- $tick = new Line(0, $pos, -1, $pos);
- $group->appendChild($tick->toSvg($ctx));
- $labelField = new Text(-0.5, $pos+0.5, $label);
- $labelField->setFontSize('1.8em')
- ->setAlignment(Text::ALIGN_END);
-
- $group->appendChild($labelField->toSvg($ctx));
- if ($this->drawXGrid) {
- $bgLine = new Line(0, $pos, 100, $pos);
- $bgLine->setStrokeWidth(0.5)
- ->setStrokeColor('#343');
- $group->appendChild($bgLine->toSvg($ctx));
+ if ($i % $ticks === 0) {
+ // draw a tick
+ //$tick = new Line(0, $pos, -1, $pos);
+ //$group->appendChild($tick->toSvg($ctx));
}
+
+ if ($i % $steps === 0) {
+ // draw a step
+ $labelField = new Text(-0.5, $pos + 0.5, $label);
+ $labelField->setFontSize('2.5em')
+ ->setAlignment(Text::ALIGN_END);
+
+ $group->appendChild($labelField->toSvg($ctx));
+ if ($this->drawXGrid) {
+ $bgLine = new Line(0, $pos, 100, $pos);
+ $bgLine->setStrokeWidth(0.5)
+ ->setStrokeColor('#BFBFBF');
+ $group->appendChild($bgLine->toSvg($ctx));
+ }
+ }
+ $i++;
}
- if ($this->yLabel) {
- $axisLabel = new Text(-8, 50, $this->yLabel);
+ if ($this->yLabel || $this->xLabel) {
+ if ($this->yLabel && $this->xLabel) {
+ $txt = $this->yLabel . ' / ' . $this->xLabel;
+ } else if ($this->xLabel) {
+ $txt = $this->xLabel;
+ } else {
+ $txt = $this->yLabel;
+ }
+
+ $axisLabel = new Text(50, -3, $txt);
$axisLabel->setFontSize('2em')
->setFontWeight('bold')
->setAlignment(Text::ALIGN_MIDDLE);
- $axisLabel = new Rotator($axisLabel, 90);
$group->appendChild($axisLabel->toSvg($ctx));
}
@@ -416,4 +456,32 @@ class Axis implements Drawable
$this->renderVerticalAxis($ctx, $group);
return $group;
}
+
+ protected function ticksPerX($ticks, $units, $min)
+ {
+ $per = 1;
+ while ($per * $units / $ticks < $min) {
+ $per++;
+ }
+ return $per;
+ }
+
+ /**
+ * Returns whether at least one label of the given Axis
+ * is bigger than the given maxLength
+ *
+ * @param AxisUnit $axis The axis that contains the labels that will be checked
+ *
+ * @return boolean Whether at least one label is bigger than maxLength
+ */
+ private function labelsOversized(AxisUnit $axis, $maxLength = 5)
+ {
+ $oversized = false;
+ foreach ($axis as $label => $pos) {
+ if (strlen($label) > $maxLength) {
+ $oversized = true;
+ }
+ }
+ return $oversized;
+ }
}
diff --git a/library/Icinga/Chart/Graph/BarGraph.php b/library/Icinga/Chart/Graph/BarGraph.php
index 1225307ad..febad8d09 100644
--- a/library/Icinga/Chart/Graph/BarGraph.php
+++ b/library/Icinga/Chart/Graph/BarGraph.php
@@ -28,7 +28,7 @@ class BarGraph extends Styleable implements Drawable
*
* @var int
*/
- private $barWidth = 4;
+ private $barWidth = 3;
/**
* The dataset to use for this bar graph
@@ -122,6 +122,14 @@ class BarGraph extends Styleable implements Drawable
$doc = $ctx->getDocument();
$group = $doc->createElement('g');
$idx = 0;
+
+ if (count($this->dataSet) > 15) {
+ $this->barWidth = 2;
+ }
+ if (count($this->dataSet) > 25) {
+ $this->barWidth = 1;
+ }
+
foreach ($this->dataSet as $x => $point) {
// add white background bar, to prevent other bars from altering transparency effects
$bar = $this->drawSingleBar($point, $idx++, 'white', $this->strokeWidth, $idx)->toSvg($ctx);
diff --git a/library/Icinga/Chart/Graph/LineGraph.php b/library/Icinga/Chart/Graph/LineGraph.php
index d12d4eed9..3644f1492 100644
--- a/library/Icinga/Chart/Graph/LineGraph.php
+++ b/library/Icinga/Chart/Graph/LineGraph.php
@@ -45,6 +45,13 @@ class LineGraph extends Styleable implements Drawable
*/
public $strokeWidth = 5;
+ /**
+ * The size of the displayed dots
+ *
+ * @var int
+ */
+ public $dotWith = 0;
+
/**
* Create a new LineGraph displaying the given dataset
*
@@ -138,8 +145,8 @@ class LineGraph extends Styleable implements Drawable
$group = $path->toSvg($ctx);
if ($this->showDataPoints === true) {
foreach ($this->dataset as $point) {
- $dot = new Circle($point[0], $point[1], $this->strokeWidth*5);
- $dot->setFill('black');
+ $dot = new Circle($point[0], $point[1], $this->dotWith);
+ $dot->setFill($this->strokeColor);
$group->appendChild($dot->toSvg($ctx));
}
diff --git a/library/Icinga/Chart/Legend.php b/library/Icinga/Chart/Legend.php
index 46ba8081c..df334089f 100644
--- a/library/Icinga/Chart/Legend.php
+++ b/library/Icinga/Chart/Legend.php
@@ -66,13 +66,14 @@ class Legend implements Drawable
$outer->getLayout()->setPadding(2, 2, 2, 2);
$nrOfColumns = 4;
- $leftstep = 100 / $nrOfColumns;
$topstep = 10 / $nrOfColumns + 2;
$top = 0;
$left = 0;
$lastLabelEndPos = -1;
foreach ($this->dataset as $color => $text) {
+ $leftstep = 100 / $nrOfColumns + strlen($text);
+
// Make sure labels don't overlap each other
while ($lastLabelEndPos >= $left) {
$left += $leftstep;
diff --git a/library/Icinga/Chart/Primitive/Circle.php b/library/Icinga/Chart/Primitive/Circle.php
index 058211bf7..da5f1785e 100644
--- a/library/Icinga/Chart/Primitive/Circle.php
+++ b/library/Icinga/Chart/Primitive/Circle.php
@@ -61,7 +61,7 @@ class Circle extends Styleable implements Drawable
$circle = $ctx->getDocument()->createElement('circle');
$circle->setAttribute('cx', Format::formatSVGNumber($coords[0]));
$circle->setAttribute('cy', Format::formatSVGNumber($coords[1]));
- $circle->setAttribute('r', 5);
+ $circle->setAttribute('r', $this->radius);
$circle->setAttribute('style', $this->getStyle());
$this->applyAttributes($circle);
return $circle;
diff --git a/library/Icinga/Chart/Unit/AxisUnit.php b/library/Icinga/Chart/Unit/AxisUnit.php
index dc57f99e0..fba521778 100644
--- a/library/Icinga/Chart/Unit/AxisUnit.php
+++ b/library/Icinga/Chart/Unit/AxisUnit.php
@@ -9,13 +9,14 @@ use Iterator;
/**
* Base class for Axis Units
*
+ * An AxisUnit takes a set of values and places them on a given range
+ *
* Concrete subclasses must implement the iterator interface, with
* getCurrent returning the axis relative position and getValue the label
* that will be displayed
*/
interface AxisUnit extends Iterator
{
-
/**
* Add a dataset to this AxisUnit, required for dynamic min and max vlaues
*
@@ -46,4 +47,11 @@ interface AxisUnit extends Iterator
* @param int $max The new maximum value
*/
public function setMax($max);
+
+ /**
+ * Get the amount of ticks of this axis
+ *
+ * @return int
+ */
+ public function getTicks();
}
diff --git a/library/Icinga/Chart/Unit/LinearUnit.php b/library/Icinga/Chart/Unit/LinearUnit.php
index d776fe304..fe80971d4 100644
--- a/library/Icinga/Chart/Unit/LinearUnit.php
+++ b/library/Icinga/Chart/Unit/LinearUnit.php
@@ -9,7 +9,6 @@ namespace Icinga\Chart\Unit;
*/
class LinearUnit implements AxisUnit
{
-
/**
* The minimum value to display
*
@@ -43,7 +42,7 @@ class LinearUnit implements AxisUnit
*
* @var int
*/
- private $nrOfTicks = 10;
+ protected $nrOfTicks = 10;
/**
* The currently displayed tick
@@ -95,45 +94,13 @@ class LinearUnit implements AxisUnit
if (!$this->staticMin) {
$this->min = min($this->min, $datapoints[0]);
}
- if (!$this->staticMin || !$this->staticMax) {
- $this->updateMaxValue();
- }
$this->currentTick = 0;
$this->currentValue = $this->min;
- return $this;
- }
-
- /**
- * Refresh the range depending on the current values of min, max and nrOfTicks
- */
- private function updateMaxValue()
- {
- $this->max = $this->calculateTickRange($this->max - $this->min, $this->nrOfTicks) *
- $this->nrOfTicks + $this->min;
- }
-
- /**
- * Determine the minimum tick range that is necessary to display the given value range
- * correctly
- *
- * @param int range The range to display
- * @param int ticks The amount of ticks to use
- *
- * @return int The value for each tick
- */
- private function calculateTickRange($range, $ticks)
- {
- $factor = 1;
- $steps = array(1, 2, 5);
- $step = 0;
- while ($range / ($factor * $steps[$step]) > $ticks) {
- $step++;
- if ($step === count($steps)) {
- $step = 0;
- $factor *= 10;
- }
+ if ($this->max === $this->min) {
+ $this->max = $this->min + 10;
}
- return $steps[$step] * $factor;
+ $this->nrOfTicks = $this->max - $this->min;
+ return $this;
}
/**
@@ -149,7 +116,7 @@ class LinearUnit implements AxisUnit
} elseif ($value > $this->max) {
return 100;
} else {
- return 100 * ($value - $this->min) / $this->max - $this->min;
+ return 100 * ($value - $this->min) / $this->nrOfTicks;
}
}
@@ -211,7 +178,6 @@ class LinearUnit implements AxisUnit
if ($max !== null) {
$this->max = $max;
$this->staticMax = true;
- $this->updateMaxValue();
}
}
@@ -225,7 +191,6 @@ class LinearUnit implements AxisUnit
if ($min !== null) {
$this->min = $min;
$this->staticMin = true;
- $this->updateMaxValue();
}
}
@@ -248,4 +213,14 @@ class LinearUnit implements AxisUnit
{
return $this->max;
}
+
+ /**
+ * Get the amount of ticks necessary to display this AxisUnit
+ *
+ * @return int
+ */
+ public function getTicks()
+ {
+ return $this->nrOfTicks;
+ }
}
diff --git a/library/Icinga/Chart/Unit/LogarithmicUnit.php b/library/Icinga/Chart/Unit/LogarithmicUnit.php
new file mode 100644
index 000000000..6d07f3d45
--- /dev/null
+++ b/library/Icinga/Chart/Unit/LogarithmicUnit.php
@@ -0,0 +1,264 @@
+
+ * this article for a more detailed description.
+ */
+class LogarithmicUnit implements AxisUnit
+{
+ /**
+ * @var int
+ */
+ protected $base;
+
+ /**
+ * @var
+ */
+ protected $currentTick;
+
+ /**
+ * @var
+ */
+ protected $minExp;
+
+ /**
+ * @var
+ */
+ protected $maxExp;
+
+ /**
+ * True when the minimum value is static and isn't affected by the data set
+ *
+ * @var bool
+ */
+ protected $staticMin = false;
+
+ /**
+ * True when the maximum value is static and isn't affected by the data set
+ *
+ * @var bool
+ */
+ protected $staticMax = false;
+
+ /**
+ * Create and initialize this AxisUnit
+ *
+ * @param int $nrOfTicks The number of ticks to use
+ */
+ public function __construct($base = 10)
+ {;
+ $this->base = $base;
+ $this->minExp = PHP_INT_MAX;
+ $this->maxExp = ~PHP_INT_MAX;
+ }
+
+ /**
+ * Add a dataset and calculate the minimum and maximum value for this AxisUnit
+ *
+ * @param array $dataset The dataset to add
+ * @param int $idx The idx (0 for x, 1 for y)
+ *
+ * @return self Fluent interface
+ */
+ public function addValues(array $dataset, $idx = 0)
+ {
+ $datapoints = array();
+
+ foreach ($dataset['data'] as $points) {
+ $datapoints[] = $points[$idx];
+ }
+ if (empty($datapoints)) {
+ return $this;
+ }
+ sort($datapoints);
+ if (!$this->staticMax) {
+ $this->maxExp = max($this->maxExp, $this->logCeil($datapoints[count($datapoints) - 1]));
+ }
+ if (!$this->staticMin) {
+ $this->minExp = min($this->minExp, $this->logFloor($datapoints[0]));
+ }
+ $this->currentTick = 0;
+
+ return $this;
+ }
+
+ /**
+ * Transform the absolute value to an axis relative value
+ *
+ * @param int $value The absolute coordinate from the data set
+ * @return float|int The axis relative coordinate (between 0 and 100)
+ */
+ public function transform($value)
+ {
+ if ($value < $this->pow($this->minExp)) {
+ return 0;
+ } elseif ($value > $this->pow($this->maxExp)) {
+ return 100;
+ } else {
+ return 100 * ($this->log($value) - $this->minExp) / $this->getTicks();
+ }
+ }
+
+ /**
+ * Return the position of the current tick
+ *
+ * @return int
+ */
+ public function current()
+ {
+ return $this->currentTick * (100 / $this->getTicks());
+ }
+
+ /**
+ * Calculate the next tick and tick value
+ */
+ public function next()
+ {
+ ++ $this->currentTick;
+ }
+
+ /**
+ * Return the label for the current tick
+ *
+ * @return string The label for the current tick
+ */
+ public function key()
+ {
+ $currentBase = $this->currentTick + $this->minExp;
+ if (abs($currentBase) > 4) {
+ return $this->base . 'E' . $currentBase;
+ }
+ return (string) intval($this->pow($currentBase));
+ }
+
+ /**
+ * True when we're at a valid tick (iterator interface)
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ return $this->currentTick >= 0 && $this->currentTick < $this->getTicks();
+ }
+
+ /**
+ * Reset the current tick and label value
+ */
+ public function rewind()
+ {
+ $this->currentTick = 0;
+ }
+
+ /**
+ * Perform a log-modulo transformation
+ *
+ * @param $value The value to transform
+ *
+ * @return double The transformed value
+ */
+ protected function log($value)
+ {
+ $sign = $value > 0 ? 1 : -1;
+ return $sign * log1p($sign * $value) / log($this->base);
+ }
+
+ /**
+ * Calculate the biggest exponent necessary to display the given data point
+ *
+ * @param $value
+ *
+ * @return float
+ */
+ protected function logCeil($value)
+ {
+ return ceil($this->log($value)) + 1;
+ }
+
+ /**
+ * Calculate the smallest exponent necessary to display the given data point
+ *
+ * @param $value
+ *
+ * @return float
+ */
+ protected function logFloor($value)
+ {
+ return floor($this->log($value));
+ }
+
+ /**
+ * Inverse function to the log-modulo transformation
+ *
+ * @param $value
+ *
+ * @return double
+ */
+ protected function pow($value)
+ {
+ if ($value == 0) {
+ return 0;
+ }
+ $sign = $value > 0 ? 1 : -1;
+ return $sign * (pow($this->base, $sign * $value));
+ }
+
+ /**
+ * Set the axis minimum value to a fixed value
+ *
+ * @param int $min The new minimum value
+ */
+ public function setMin($min)
+ {
+ $this->minExp = $this->logFloor($min);
+ $this->staticMin = true;
+ }
+
+ /**
+ * Set the axis maximum value to a fixed value
+ *
+ * @param int $max The new maximum value
+ */
+ public function setMax($max)
+ {
+ $this->maxExp = $this->logCeil($max);
+ $this->staticMax = true;
+ }
+
+ /**
+ * Return the current minimum value of the axis
+ *
+ * @return int The minimum set for this axis
+ */
+ public function getMin()
+ {
+ return $this->pow($this->minExp);
+ }
+
+ /**
+ * Return the current maximum value of the axis
+ *
+ * @return int The maximum set for this axis
+ */
+ public function getMax()
+ {
+ return $this->pow($this->maxExp);
+ }
+
+ /**
+ * Get the amount of ticks necessary to display this AxisUnit
+ *
+ * @return int
+ */
+ public function getTicks()
+ {
+ return $this->maxExp - $this->minExp;
+ }
+}
diff --git a/library/Icinga/Chart/Unit/StaticAxis.php b/library/Icinga/Chart/Unit/StaticAxis.php
index 6458ae599..c7e9c2be5 100644
--- a/library/Icinga/Chart/Unit/StaticAxis.php
+++ b/library/Icinga/Chart/Unit/StaticAxis.php
@@ -118,4 +118,14 @@ class StaticAxis implements AxisUnit
{
return reset($this->items);
}
+
+ /**
+ * Get the amount of ticks of this axis
+ *
+ * @return int
+ */
+ public function getTicks()
+ {
+ return count($this->items);
+ }
}
diff --git a/library/Icinga/Cli/Command.php b/library/Icinga/Cli/Command.php
index 7546f871f..c410cfc0e 100644
--- a/library/Icinga/Cli/Command.php
+++ b/library/Icinga/Cli/Command.php
@@ -16,6 +16,10 @@ abstract class Command
{
protected $app;
protected $docs;
+
+ /**
+ * @type Params
+ */
protected $params;
protected $screen;
protected $isVerbose;
@@ -124,7 +128,7 @@ abstract class Command
public function fail($msg)
{
- throw new IcingaException('%s', $msg);
+ throw new IcingaException($msg);
}
public function getDefaultActionName()
diff --git a/library/Icinga/Data/Filterable.php b/library/Icinga/Data/Filterable.php
index 73ce5dcb4..25d1fc9f5 100644
--- a/library/Icinga/Data/Filterable.php
+++ b/library/Icinga/Data/Filterable.php
@@ -8,6 +8,11 @@ use Icinga\Data\Filter\Filter;
/**
* Interface for filtering a result set
+ *
+ * @deprecated(EL): addFilter and applyFilter do the same in all usages.
+ * addFilter could be replaced w/ getFilter()->add(). We must no require classes implementing this interface to
+ * implement redundant methods over and over again. This interface must be moved to the namespace Icinga\Data\Filter.
+ * It lacks documentation.
*/
interface Filterable
{
diff --git a/library/Icinga/File/FileExtensionFilterIterator.php b/library/Icinga/File/FileExtensionFilterIterator.php
new file mode 100644
index 000000000..909156749
--- /dev/null
+++ b/library/Icinga/File/FileExtensionFilterIterator.php
@@ -0,0 +1,71 @@
+
+ *
+ */
+class FileExtensionFilterIterator extends FilterIterator
+{
+ /**
+ * The extension to filter for
+ *
+ * @type string
+ */
+ protected $extension;
+
+ /**
+ * Create a new FileExtensionFilterIterator
+ *
+ * @param Iterator $iterator Apply filter to this iterator
+ * @param string $extension The file extension to filter for. The file extension may not contain the leading dot
+ */
+ public function __construct(Iterator $iterator, $extension)
+ {
+ $this->extension = '.' . ltrim(strtolower((string) $extension), '.');
+ parent::__construct($iterator);
+ }
+
+ /**
+ * Accept files which match the file extension to filter for
+ *
+ * @return bool Whether the current element of the iterator is acceptable
+ * through this filter
+ */
+ public function accept()
+ {
+ $current = $this->current();
+ /* @var $current \SplFileInfo */
+ if (! $current->isFile()) {
+ return false;
+ }
+ // SplFileInfo::getExtension() is only available since PHP 5 >= 5.3.6
+ $filename = $current->getFilename();
+ $sfx = substr($filename, -strlen($this->extension));
+ return $sfx === false ? false : strtolower($sfx) === $this->extension;
+ }
+}
diff --git a/library/Icinga/File/Ini/IniWriter.php b/library/Icinga/File/Ini/IniWriter.php
index 94a20faa5..21402ab74 100644
--- a/library/Icinga/File/Ini/IniWriter.php
+++ b/library/Icinga/File/Ini/IniWriter.php
@@ -27,7 +27,7 @@ class IniWriter extends Zend_Config_Writer_FileAbstract
*
* @var int
*/
- public static $fileMode = 0664;
+ public static $fileMode = 0660;
/**
* Create a new INI writer
@@ -90,11 +90,9 @@ class IniWriter extends Zend_Config_Writer_FileAbstract
if ($setMode) {
$mode = isset($this->options['filemode']) ? $this->options['filemode'] : static::$fileMode;
- $old = umask(0); // Make sure that the mode we're going to set doesn't get mangled
if (is_int($mode) && false === @chmod($filePath, $mode)) {
throw new Zend_Config_Exception(sprintf('Failed to set file mode "%o" on file "%s"', $mode, $filePath));
}
- umask($old);
}
}
@@ -234,7 +232,7 @@ class IniWriter extends Zend_Config_Writer_FileAbstract
/**
* Getter for filename
- *
+ *
* @return string
*/
public function getFilename()
diff --git a/library/Icinga/File/NonEmptyFileIterator.php b/library/Icinga/File/NonEmptyFileIterator.php
new file mode 100644
index 000000000..c5c7fda45
--- /dev/null
+++ b/library/Icinga/File/NonEmptyFileIterator.php
@@ -0,0 +1,49 @@
+
+ *
+ */
+class NonEmptyFileIterator extends FilterIterator
+{
+ /**
+ * Accept non-empty files
+ *
+ * @return bool Whether the current element of the iterator is acceptable
+ * through this filter
+ */
+ public function accept()
+ {
+ $current = $this->current();
+ /** @type $current \SplFileInfo */
+ if (! $current->isFile()
+ || $current->getSize() === 0
+ ) {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php
index 2f8737c8b..1f58f34da 100644
--- a/library/Icinga/Protocol/Ldap/Connection.php
+++ b/library/Icinga/Protocol/Ldap/Connection.php
@@ -4,6 +4,7 @@
namespace Icinga\Protocol\Ldap;
+use Exception;
use Icinga\Protocol\Ldap\Exception as LdapException;
use Icinga\Application\Platform;
use Icinga\Application\Config;
@@ -97,6 +98,9 @@ class Connection
protected $namingContexts;
protected $discoverySuccess = false;
+ protected $lastResult;
+ protected $pageCookie;
+
/**
* Constructor
*
@@ -238,7 +242,8 @@ class Connection
*/
public function fetchRow($query, $fields = array())
{
- // TODO: This is ugly, make it better!
+ $query = clone $query;
+ $query->limit(1);
$results = $this->fetchAll($query, $fields);
return array_shift($results);
}
@@ -250,44 +255,56 @@ class Connection
*/
public function count(Query $query)
{
- $results = $this->runQuery($query, '+');
- if (! $results) {
- return 0;
+ $this->connect();
+ $this->bind();
+
+ $count = 0;
+ $results = $this->runQuery($query);
+ while (! empty($results)) {
+ $count += ldap_count_entries($this->ds, $results);
+ $results = $this->runQuery($query);
}
- return ldap_count_entries($this->ds, $results);
+
+ return $count;
}
- public function fetchAll($query, $fields = array())
+ public function fetchAll(Query $query, $fields = array())
{
- $offset = null;
- $limit = null;
+ $this->connect();
+ $this->bind();
+
+ $offset = $limit = null;
if ($query->hasLimit()) {
$offset = $query->getOffset();
- $limit = $query->getLimit();
+ $limit = $query->getLimit();
}
+
+ $count = 0;
$entries = array();
$results = $this->runQuery($query, $fields);
- if (! $results) {
- return array();
- }
- $entry = ldap_first_entry($this->ds, $results);
- $count = 0;
- while ($entry) {
- if (($offset === null || $offset <= $count)
- && ($limit === null || ($offset + $limit) >= $count)
- ) {
- $attrs = ldap_get_attributes($this->ds, $entry);
- $entries[ldap_get_dn($this->ds, $entry)]
- = $this->cleanupAttributes($attrs);
+ while (! empty($results)) {
+ $entry = ldap_first_entry($this->ds, $results);
+ while ($entry) {
+ $count++;
+ if (
+ ($offset === null || $offset <= $count)
+ && ($limit === null || $limit > count($entries))
+ ) {
+ $entries[ldap_get_dn($this->ds, $entry)] = $this->cleanupAttributes(
+ ldap_get_attributes($this->ds, $entry)
+ );
+ }
+
+ $entry = ldap_next_entry($this->ds, $entry);
}
- $count++;
- $entry = ldap_next_entry($this->ds, $entry);
+
+ $results = $this->runQuery($query, $fields);
}
- ldap_free_result($results);
+
return $entries;
}
- public function cleanupAttributes(& $attrs)
+ protected function cleanupAttributes($attrs)
{
$clean = (object) array();
for ($i = 0; $i < $attrs['count']; $i++) {
@@ -303,26 +320,55 @@ class Connection
return $clean;
}
- protected function runQuery($query, $fields)
+ protected function runQuery(Query $query, $fields = array())
{
- $this->connect();
- $this->bind();
- if ($query instanceof Query) {
- $fields = $query->listFields();
+ if ($query->getUsePagedResults() && version_compare(PHP_VERSION, '5.4.0') >= 0) {
+ if ($this->pageCookie === null) {
+ $this->pageCookie = '';
+ } else {
+ try {
+ ldap_control_paged_result_response($this->ds, $this->lastResult, $this->pageCookie);
+ } catch (Exception $e) {
+ $this->pageCookie = '';
+ Logger::debug(
+ 'Unable to request paged LDAP results. Does the server allow paged search requests? (%s)',
+ $e->getMessage()
+ );
+ }
+
+ ldap_free_result($this->lastResult);
+ if (! $this->pageCookie) {
+ $this->pageCookie = $this->lastResult = null;
+ // Abandon the paged search request so that subsequent requests succeed
+ ldap_control_paged_result($this->ds, 0);
+ return false;
+ }
+ }
+
+ // Does not matter whether we'll use a valid page size here,
+ // as the server applies its hard limit in case its too high
+ ldap_control_paged_result(
+ $this->ds,
+ $query->hasLimit() ? $query->getLimit() : 500,
+ true,
+ $this->pageCookie
+ );
+ } elseif ($this->lastResult !== null) {
+ ldap_free_result($this->lastResult);
+ $this->lastResult = null;
+ return false;
}
- // WARNING:
- // We do not support pagination right now, and there is no chance to
- // do so for PHP < 5.4. Warnings about "Sizelimit exceeded" will
- // therefore not be hidden right now.
+
$base = $query->hasBase() ? $query->getBase() : $this->root_dn;
$results = @ldap_search(
$this->ds,
$base,
$query->create(),
- $fields,
+ empty($fields) ? $query->listFields() : $fields,
0, // Attributes and values
- 0 // No limit - at least where possible
+ $query->hasLimit() ? $query->getOffset() + $query->getLimit() : 0 // No limit - at least where possible
);
+
if ($results === false) {
if (ldap_errno($this->ds) === self::LDAP_NO_SUCH_OBJECT) {
return false;
@@ -336,12 +382,12 @@ class Connection
)
);
}
- $list = array();
- if ($query instanceof Query) {
- foreach ($query->getSortColumns() as $col) {
- ldap_sort($this->ds, $results, $col[0]);
- }
+
+ foreach ($query->getSortColumns() as $col) {
+ ldap_sort($this->ds, $results, $col[0]);
}
+
+ $this->lastResult = $results;
return $results;
}
diff --git a/library/Icinga/Protocol/Ldap/Query.php b/library/Icinga/Protocol/Ldap/Query.php
index 462c83d61..c6f0d6fa1 100644
--- a/library/Icinga/Protocol/Ldap/Query.php
+++ b/library/Icinga/Protocol/Ldap/Query.php
@@ -33,6 +33,7 @@ class Query
protected $sort_columns = array();
protected $count;
protected $base;
+ protected $usePagedResults = true;
/**
* Constructor
@@ -61,6 +62,17 @@ class Query
return $this->base;
}
+ public function setUsePagedResults($state = true)
+ {
+ $this->usePagedResults = (bool) $state;
+ return $this;
+ }
+
+ public function getUsePagedResults()
+ {
+ return $this->usePagedResults;
+ }
+
/**
* Count result set, ignoring limits
*
diff --git a/library/Icinga/User.php b/library/Icinga/User.php
index 659767644..db80c929a 100644
--- a/library/Icinga/User.php
+++ b/library/Icinga/User.php
@@ -197,8 +197,8 @@ class User
*/
public function setPermissions(array $permissions)
{
- natcasesort($permissions);
if (! empty($permissions)) {
+ natcasesort($permissions);
$this->permissions = array_combine($permissions, $permissions);
}
return $this;
diff --git a/library/Icinga/User/Preferences/PreferencesStore.php b/library/Icinga/User/Preferences/PreferencesStore.php
index c2cba0c41..11454a2f8 100644
--- a/library/Icinga/User/Preferences/PreferencesStore.php
+++ b/library/Icinga/User/Preferences/PreferencesStore.php
@@ -26,7 +26,7 @@ use Icinga\Data\Db\DbConnection;
* // Create a INI store
* $store = PreferencesStore::create(
* new ConfigObject(
- * 'type' => 'ini',
+ * 'store' => 'ini',
* 'config_path' => '/path/to/preferences'
* ),
* $user // Instance of \Icinga\User
@@ -117,13 +117,7 @@ abstract class PreferencesStore
*/
public static function create(ConfigObject $config, User $user)
{
- if (($type = $config->type) === null) {
- throw new ConfigurationError(
- 'Preferences configuration is missing the type directive'
- );
- }
-
- $type = ucfirst(strtolower($type));
+ $type = ucfirst(strtolower($config->get('store', 'ini')));
$storeClass = 'Icinga\\User\\Preferences\\Store\\' . $type . 'Store';
if (!class_exists($storeClass)) {
throw new ConfigurationError(
diff --git a/library/Icinga/Util/String.php b/library/Icinga/Util/String.php
index 248ab0d34..69fb26927 100644
--- a/library/Icinga/Util/String.php
+++ b/library/Icinga/Util/String.php
@@ -36,4 +36,22 @@ class String
{
return str_replace(' ', '', ucwords(str_replace($separator, ' ', strtolower($name))));
}
+
+ /**
+ * Add ellipsis when a string is longer than max length
+ *
+ * @param string $string
+ * @param int $maxLength
+ * @param string $ellipsis
+ *
+ * @return string
+ */
+ public static function ellipsis($string, $maxLength, $ellipsis = '...')
+ {
+ if (strlen($string) > $maxLength) {
+ return substr($string, 0, $maxLength - strlen($ellipsis)) . $ellipsis;
+ }
+
+ return $string;
+ }
}
diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php
index 400803dce..78fcaf7bf 100644
--- a/library/Icinga/Web/Controller/ActionController.php
+++ b/library/Icinga/Web/Controller/ActionController.php
@@ -5,7 +5,7 @@
namespace Icinga\Web\Controller;
use Exception;
-use Icinga\Authentication\Manager as AuthManager;
+use Icinga\Authentication\Manager;
use Icinga\Application\Benchmark;
use Icinga\Application\Config;
use Icinga\Exception\IcingaException;
@@ -47,6 +47,11 @@ class ActionController extends Zend_Controller_Action
private $xhrLayout = 'inline';
+ /**
+ * Authentication manager
+ *
+ * @type \Icinga\Authentication\Manager|null
+ */
private $auth;
protected $params;
@@ -101,6 +106,49 @@ class ActionController extends Zend_Controller_Action
{
}
+
+ /**
+ * Get the authentication manager
+ *
+ * @return Manager
+ */
+ public function Auth()
+ {
+ if ($this->auth === null) {
+ $this->auth = Manager::getInstance();
+ }
+ return $this->auth;
+ }
+
+ /**
+ * Whether the current user has the given permission
+ *
+ * @param string $permission Name of the permission
+ *
+ * @return bool
+ */
+ public function hasPermission($permission)
+ {
+ return $this->Auth()->hasPermission($permission);
+ }
+
+ /**
+ * Throw an exception if user lacks the given permission
+ *
+ * @param string $name Permission name
+ * @throws Exception
+ */
+ public function assertPermission($name)
+ {
+ if (! $this->Auth()->hasPermission($name)) {
+ // TODO: Shall this be an Auth Exception? Or a 404?
+ throw new IcingaException(
+ 'Auth error, no permission for "%s"',
+ $name
+ );
+ }
+ }
+
public function Config($file = null)
{
if ($file === null) {
@@ -110,14 +158,6 @@ class ActionController extends Zend_Controller_Action
}
}
- public function Auth()
- {
- if ($this->auth === null) {
- $this->auth = AuthManager::getInstance();
- }
- return $this->auth;
- }
-
public function Window()
{
if ($this->window === null) {
@@ -146,6 +186,22 @@ class ActionController extends Zend_Controller_Action
return $this;
}
+ /**
+ * Respond with HTTP 405 if the current request's method is not one of the given methods
+ *
+ * @param string $httpMethod Unlimited number of allowed HTTP methods
+ *
+ * @throws \Zend_Controller_Action_Exception If the request method is not one of the given methods
+ */
+ public function assertHttpMethod($httpMethod)
+ {
+ $httpMethods = array_flip(array_map('strtoupper', func_get_args()));
+ if (! isset($httpMethods[$this->getRequest()->getMethod()])) {
+ $this->getResponse()->setHeader('Allow', implode(', ', array_keys($httpMethods)));
+ throw new \Zend_Controller_Action_Exception($this->translate('Method Not Allowed'), 405);
+ }
+ }
+
/**
* Return restriction information for an eventually authenticated user
*
@@ -157,34 +213,6 @@ class ActionController extends Zend_Controller_Action
return $this->Auth()->getRestrictions($name);
}
- /**
- * Whether the user currently authenticated has the given permission
- *
- * @param string $name Permission name
- * @return bool
- */
- public function hasPermission($name)
- {
- return $this->Auth()->hasPermission($name);
- }
-
- /**
- * Throws an exception if user lacks the given permission
- *
- * @param string $name Permission name
- * @throws Exception
- */
- public function assertPermission($name)
- {
- if (! $this->Auth()->hasPermission($name)) {
- // TODO: Shall this be an Auth Exception? Or a 404?
- throw new IcingaException(
- 'Auth error, no permission for "%s"',
- $name
- );
- }
- }
-
/**
* Check whether the controller requires a login. That is when the controller requires authentication and the
* user is currently not authenticated
@@ -270,7 +298,7 @@ class ActionController extends Zend_Controller_Action
/**
* Redirect to the login path
*
- * @param string $afterLogin The action to call when the login was successful. Defaults to '/index/welcome'
+ * @param Url $afterLogin The action to call when the login was successful. Defaults to '/index/welcome'
*
* @throws \Exception
*/
diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php
index 205c4e238..1f3e0d4bd 100644
--- a/library/Icinga/Web/Form.php
+++ b/library/Icinga/Web/Form.php
@@ -512,7 +512,7 @@ class Form extends Zend_Form
$el = parent::createElement($type, $name, $options);
- if (($description = $el->getDescription()) !== null && ($label = $el->getDecorator('label')) !== null) {
+ if (($description = $el->getDescription()) !== null && ($label = $el->getDecorator('label')) !== false) {
$label->setOptions(array(
'title' => $description,
'class' => 'has-feedback'
@@ -805,6 +805,24 @@ class Form extends Zend_Form
return array();
}
+ /**
+ * Get the translation domain for this form
+ *
+ * The returned translation domain is either determined based on this form's qualified name or it is the default
+ * 'icinga' domain
+ *
+ * @return string
+ */
+ protected function getTranslationDomain()
+ {
+ $parts = explode('\\', get_called_class());
+ if ($parts[1] === 'Module') {
+ // Assume format Icinga\Module\ModuleName\Forms\...
+ return strtolower($parts[2]);
+ }
+ return 'icinga';
+ }
+
/**
* Translate a string
*
@@ -815,7 +833,7 @@ class Form extends Zend_Form
*/
protected function translate($text, $context = null)
{
- return Translator::translate($text, $this->request->getModuleName(), $context);
+ return Translator::translate($text, $this->getTranslationDomain(), $context);
}
/**
@@ -834,7 +852,7 @@ class Form extends Zend_Form
$textSingular,
$textPlural,
$number,
- $this->request->getModuleName(),
+ $this->getTranslationDomain(),
$context
);
}
diff --git a/library/Icinga/Web/LessCompiler.php b/library/Icinga/Web/LessCompiler.php
index 791fdbab0..261790579 100644
--- a/library/Icinga/Web/LessCompiler.php
+++ b/library/Icinga/Web/LessCompiler.php
@@ -43,12 +43,6 @@ class LessCompiler
{
require_once 'lessphp/lessc.inc.php';
$this->lessc = new lessc();
-
- $this->lessc->setVariables(
- array(
- 'baseurl' => '\'' . Zend_Controller_Front::getInstance()->getBaseUrl(). '\''
- )
- );
}
public function compress()
diff --git a/library/Icinga/Web/Menu.php b/library/Icinga/Web/Menu.php
index 18a17ea67..f0279ea9c 100644
--- a/library/Icinga/Web/Menu.php
+++ b/library/Icinga/Web/Menu.php
@@ -248,7 +248,8 @@ class Menu implements RecursiveIterator
$section->add(t('Logout'), array(
'url' => 'authentication/logout',
- 'priority' => 700
+ 'priority' => 700,
+ 'renderer' => 'ForeignMenuItemRenderer'
));
}
}
@@ -366,7 +367,7 @@ class Menu implements RecursiveIterator
/**
* Return the url of this menu
*
- * @return string
+ * @return Url
*/
public function getUrl()
{
diff --git a/library/Icinga/Web/Menu/ForeignMenuItemRenderer.php b/library/Icinga/Web/Menu/ForeignMenuItemRenderer.php
new file mode 100644
index 000000000..659709868
--- /dev/null
+++ b/library/Icinga/Web/Menu/ForeignMenuItemRenderer.php
@@ -0,0 +1,24 @@
+%s%s',
+ $menu->getUrl() ?: '#',
+ $menu->getIcon() ? '
' : '',
+ htmlspecialchars($menu->getTitle())
+ );
+ }
+}
diff --git a/library/Icinga/Web/Session/PhpSession.php b/library/Icinga/Web/Session/PhpSession.php
old mode 100644
new mode 100755
index bef978c0b..fa545fd8d
--- a/library/Icinga/Web/Session/PhpSession.php
+++ b/library/Icinga/Web/Session/PhpSession.php
@@ -78,8 +78,9 @@ class PhpSession extends Session
}
}
- if (!is_writable(session_save_path())) {
- throw new ConfigurationError('Can\'t save session');
+ $sessionSavePath = session_save_path();
+ if (session_module_name() === 'files' && !is_writable($sessionSavePath)) {
+ throw new ConfigurationError("Can't save session, path '$sessionSavePath' is not writable.");
}
if ($this->exists()) {
diff --git a/library/Icinga/Web/StyleSheet.php b/library/Icinga/Web/StyleSheet.php
index 719d1c829..9e6bd0bed 100644
--- a/library/Icinga/Web/StyleSheet.php
+++ b/library/Icinga/Web/StyleSheet.php
@@ -96,6 +96,7 @@ class StyleSheet
$cache->send($cacheFile);
return;
}
+
$less = new LessCompiler();
foreach ($lessFiles as $file) {
$less->addFile($file);
diff --git a/library/Icinga/Web/View.php b/library/Icinga/Web/View.php
index 7a954934a..2122662ac 100644
--- a/library/Icinga/Web/View.php
+++ b/library/Icinga/Web/View.php
@@ -4,10 +4,11 @@
namespace Icinga\Web;
+use Closure;
+use Zend_View_Abstract;
+use Icinga\Authentication\Manager;
use Icinga\Exception\ProgrammingError;
use Icinga\Util\Translator;
-use Zend_View_Abstract;
-use Closure;
/**
* Icinga view
@@ -36,6 +37,13 @@ class View extends Zend_View_Abstract
*/
private $helperFunctions = array();
+ /**
+ * Authentication manager
+ *
+ * @type \Icinga\Authentication\Manager|null
+ */
+ private $auth;
+
/**
* Create a new view object
*
@@ -154,6 +162,31 @@ class View extends Zend_View_Abstract
}
}
+ /**
+ * Get the authentication manager
+ *
+ * @return Manager
+ */
+ public function Auth()
+ {
+ if ($this->auth === null) {
+ $this->auth = Manager::getInstance();
+ }
+ return $this->auth;
+ }
+
+ /**
+ * Whether the current user has the given permission
+ *
+ * @param string $permission Name of the permission
+ *
+ * @return bool
+ */
+ public function hasPermission($permission)
+ {
+ return $this->Auth()->hasPermission($permission);
+ }
+
/**
* Use to include the view script in a scope that only allows public
* members.
diff --git a/library/Icinga/Web/View/helpers/string.php b/library/Icinga/Web/View/helpers/string.php
new file mode 100644
index 000000000..1d79d885a
--- /dev/null
+++ b/library/Icinga/Web/View/helpers/string.php
@@ -0,0 +1,8 @@
+addHelperFunction('ellipsis', function ($string, $maxLength, $ellipsis = '...') {
+ return String::ellipsis($string, $maxLength, $ellipsis);
+});
diff --git a/library/Icinga/Web/Widget/Chart/InlinePie.php b/library/Icinga/Web/Widget/Chart/InlinePie.php
index 618d2903b..04e3e7318 100644
--- a/library/Icinga/Web/Widget/Chart/InlinePie.php
+++ b/library/Icinga/Web/Widget/Chart/InlinePie.php
@@ -5,6 +5,7 @@
namespace Icinga\Web\Widget\Chart;
use Icinga\Chart\PieChart;
+use Icinga\Module\Monitoring\Plugin\PerfdataSet;
use Icinga\Web\Widget\AbstractWidget;
use Icinga\Web\Url;
use Icinga\Util\Format;
@@ -28,36 +29,23 @@ class InlinePie extends AbstractWidget
const NUMBER_FORMAT_RATIO = 'ratio';
/**
- * The template string used for rendering this widget
* The template string used for rendering this widget
*
* @var string
*/
private $template =<<<'EOD'
-
-
+
+
+{noscript}
EOD;
+ private $noscript =<<<'EOD'
+
+EOD;
+
+
/**
* @var Url
*/
@@ -68,35 +56,7 @@ EOD;
*
* @var array
*/
- private $colors = array('#44bb77', '#ffaa44', '#ff5566', '#ddccdd');
-
- /**
- * The width of the rendered chart
- *
- * @var int The value in px
- */
- private $width = 16;
-
- /**
- * The height of the rendered chart
- *
- * @var int The value in px
- */
- private $height = 16;
-
- /**
- * PieChart border width
- *
- * @var float
- */
- private $borderWidth = 1;
-
- /**
- * The color of the border
- *
- * @var string
- */
- private $borderColor = '#fff';
+ private $colors = array('#049BAF', '#ffaa44', '#ff5566', '#ddccdd');
/**
* The title of the chart
@@ -106,11 +66,9 @@ EOD;
private $title;
/**
- * The style for the HtmlElement
- *
- * @var string
+ * @var
*/
- private $style = '';
+ private $size;
/**
* The data displayed by the pie-chart
@@ -120,45 +78,9 @@ EOD;
private $data;
/**
- * The labels to display for each data set
- *
- * @var array
+ * @var
*/
- private $labels = array();
-
- /**
- * If the tooltip for the "empty" area should be hidden
- *
- * @var bool
- */
- private $hideEmptyLabel = false;
-
- /**
- * The format string used to display tooltips
- *
- * @var string
- */
- private $tooltipFormat = '{{title}} {{label}}: {{formatted}} ({{percent}}%)';
-
- /**
- * The number format used to render numeric values in tooltips
- *
- * @var array
- */
- private $format = self::NUMBER_FORMAT_NONE;
-
- /**
- * Set if the tooltip for the empty area should be hidden
- *
- * @param bool $hide Whether to hide the empty area
- *
- * @return $this
- */
- public function setHideEmptyLabel($hide = true)
- {
- $this->hideEmptyLabel = $hide;
- return $this;
- }
+ private $class = '';
/**
* Set the data to be displayed.
@@ -175,24 +97,36 @@ EOD;
}
/**
- * The labels to be displayed in the pie-chart
+ * Set the size of the inline pie
*
- * @param mixed $label The label of the displayed value, or null for no labels
+ * @param int $size Sets both, the height and width
*
- * @return $this
+ * @return $this
*/
- public function setLabel($label)
+ public function setSize($size = null)
{
- if (is_array($label)) {
- $this->url->setParam('labels', implode(',', array_keys($label)));
- } elseif ($label != null) {
- $labelArr = array($label, $label, $label, '');
- $this->url->setParam('labels', implode(',', $labelArr));
- $label = $labelArr;
- } else {
- $this->url->removeKey('labels');
- }
- $this->labels = $label;
+ $this->size = $size;
+ return $this;
+ }
+
+ /**
+ * Do not display the NoScript fallback html
+ */
+ public function disableNoScript()
+ {
+ $this->noscript = '';
+ }
+
+ /**
+ * Set the class to define the
+ *
+ * @param $class
+ *
+ * @return $this
+ */
+ public function setSparklineClass($class)
+ {
+ $this->class = $class;
return $this;
}
@@ -214,105 +148,6 @@ EOD;
return $this;
}
- /**
- * Set the used number format
- *
- * @param $format string 'bytes' or 'time'
- *
- * @return $this
- */
- public function setNumberFormat($format)
- {
- $this->format = $format;
- return $this;
- }
-
- /**
- * A format string used to render the content of the piechart tooltips
- *
- * Placeholders using curly braces '{FOO}' are replace with their specific values. The format
- * String may contain HTML-Markup. The available replaceable values are:
- *
- * - label: The description for the current value
- * - formatted: A string representing the formatted value
- * - value: The raw (non-formatted) value used to render the piechart
- * - percent: The percentage of the current value
- *
- * Note: Changes will only affect JavaScript sparklines and not the SVG charts used for fallback
- *
- * @param $format
- *
- * @return $this
- */
- public function setTooltipFormat($format)
- {
- $this->tooltipFormat = $format;
- return $this;
- }
-
- /**
- * Set the height
- *
- * @param $height
- *
- * @return $this
- */
- public function setHeight($height)
- {
- $this->height = $height;
- return $this;
- }
-
- /**
- * Set the border width of the pie chart
- *
- * @param float $width Width in px
- *
- * @return $this
- */
- public function setBorderWidth($width)
- {
- $this->borderWidth = $width;
- return $this;
- }
-
- /**
- * Set the color of the pie chart border
- *
- * @param string $col The color string
- *
- * @return $this
- */
- public function setBorderColor($col)
- {
- $this->borderColor = $col;
- }
-
- /**
- * Set the width
- *
- * @param $width
- *
- * @return $this
- */
- public function setWidth($width)
- {
- $this->width = $width;
- return $this;
- }
-
- /**
- * Set the styling of the created HtmlElement
- *
- * @param string $style
- *
- * @return $this
- */
- public function setStyle($style)
- {
- $this->style = $style;
- }
-
/**
* Set the title of the displayed Data
*
@@ -322,7 +157,7 @@ EOD;
*/
public function setTitle($title)
{
- $this->title = $title;
+ $this->title = 'title="' . htmlspecialchars($title) . '"';
return $this;
}
@@ -335,13 +170,10 @@ EOD;
*/
public function __construct(array $data, $title, $colors = null)
{
- $this->title = $title;
+ $this->setTitle($title);
$this->url = Url::fromPath('svg/chart.php');
if (array_key_exists('data', $data)) {
$this->data = $data['data'];
- if (array_key_exists('labels', $data)) {
- $this->labels = $data['labels'];
- }
if (array_key_exists('colors', $data)) {
$this->colors = $data['colors'];
}
@@ -354,21 +186,6 @@ EOD;
$this->setColors($this->colors);
}
}
-
- /**
- * Create a serialization containing the current label array
- *
- * @return string A serialized array of labels
- */
- private function createLabelString ()
- {
- $labels = $this->labels;
- foreach ($labels as $key => $label) {
- $labels[$key] = str_replace('|', '', $label);
- }
- return isset($this->labels) && is_array($this->labels) ? implode('|', $this->labels) : '';
- }
-
/**
* Renders this widget via the given view and returns the
* HTML as a string
@@ -382,11 +199,11 @@ EOD;
$pie->alignTopLeft();
$pie->disableLegend();
$pie->drawPie(array(
- 'data' => $this->data, 'colors' => $this->colors, 'labels' => $this->labels
+ 'data' => $this->data, 'colors' => $this->colors
));
try {
- $png = $pie->toPng($this->width, $this->height);
+ $png = $pie->toPng($this->size, $this->size);
return '
';
} catch (IcingaException $_) {
return '';
@@ -394,17 +211,17 @@ EOD;
}
$template = $this->template;
+ // TODO: Check whether we are XHR and don't send
+ $template = str_replace('{noscript}', $this->noscript, $template);
$template = str_replace('{url}', $this->url, $template);
+ $template = str_replace('{class}', $this->class, $template);
// style
- $template = str_replace('{width}', $this->width, $template);
- $template = str_replace('{height}', $this->height, $template);
- $template = str_replace('{title}', htmlspecialchars($this->title), $template);
- $template = str_replace('{style}', $this->style, $template);
+ $template = str_replace('{size}',
+ isset($this->size) ? 'sparkWidth="' . $this->size . '" sparkHeight="' . $this->size . '" ' : '', $template);
+ $template = str_replace('{title}', $this->title, $template);
+
$template = str_replace('{colors}', implode(',', $this->colors), $template);
- $template = str_replace('{borderWidth}', $this->borderWidth, $template);
- $template = str_replace('{borderColor}', $this->borderColor, $template);
- $template = str_replace('{hideEmptyLabel}', $this->hideEmptyLabel ? 'true' : 'false', $template);
// Locale-ignorant string cast. Please. Do. NOT. Remove. This. Again.
// Problem is that implode respects locales when casting floats. This means
@@ -414,38 +231,7 @@ EOD;
$data[] = sprintf('%F', $dat);
}
- // values
- $formatted = array();
- foreach ($this->data as $key => $value) {
- $formatted[$key] = $this->formatValue($value);
- }
$template = str_replace('{data}', htmlspecialchars(implode(',', $data)), $template);
- $template = str_replace('{formatted}', htmlspecialchars(implode('|', $formatted)), $template);
- $template = str_replace('{labels}', htmlspecialchars($this->createLabelString()), $template);
- $template = str_replace('{tooltipFormat}', $this->tooltipFormat, $template);
return $template;
}
-
- /**
- * Format the given value depending on the current value of numberFormat
- *
- * @param float $value The value to format
- *
- * @return string The formatted value
- */
- private function formatValue($value)
- {
- if ($this->format === self::NUMBER_FORMAT_NONE) {
- return (string)$value;
- } elseif ($this->format === self::NUMBER_FORMAT_BYTES) {
- return Format::bytes($value);
- } elseif ($this->format === self::NUMBER_FORMAT_TIME) {
- return Format::duration($value);
- } elseif ($this->format === self::NUMBER_FORMAT_RATIO) {
- return $value;
- } else {
- Logger::warning('Unknown format string "' . $this->format . '" for InlinePie, value not formatted.');
- return $value;
- }
- }
}
diff --git a/library/Icinga/Web/Widget/Tabs.php b/library/Icinga/Web/Widget/Tabs.php
index 72522282e..c6a4bd31b 100644
--- a/library/Icinga/Web/Widget/Tabs.php
+++ b/library/Icinga/Web/Widget/Tabs.php
@@ -218,6 +218,25 @@ EOT;
return $this;
}
+ /**
+ * Remove a tab
+ *
+ * @param string $name
+ *
+ * @return self
+ */
+ public function remove($name)
+ {
+ if ($this->has($name)) {
+ unset($this->tabs[$name]);
+ if (($dropdownIndex = array_search($name, $this->dropdownTabs)) !== false) {
+ array_splice($this->dropdownTabs, $dropdownIndex, 2);
+ }
+ }
+
+ return $this;
+ }
+
/**
* Add a tab to the dropdown on the right side of the tab-bar.
*
diff --git a/library/Icinga/Web/Wizard.php b/library/Icinga/Web/Wizard.php
index 2cc4abe5a..42dea5c1c 100644
--- a/library/Icinga/Web/Wizard.php
+++ b/library/Icinga/Web/Wizard.php
@@ -39,6 +39,13 @@ class Wizard
*/
const BTN_PREV = 'btn_prev';
+ /**
+ * This wizard's parent
+ *
+ * @var Wizard
+ */
+ protected $parent;
+
/**
* The name of the wizard's current page
*
@@ -71,19 +78,55 @@ class Wizard
}
+ /**
+ * Return this wizard's parent or null in case it has none
+ *
+ * @return Wizard|null
+ */
+ public function getParent()
+ {
+ return $this->parent;
+ }
+
+ /**
+ * Set this wizard's parent
+ *
+ * @param Wizard $wizard The parent wizard
+ *
+ * @return self
+ */
+ public function setParent(Wizard $wizard)
+ {
+ $this->parent = $wizard;
+ return $this;
+ }
+
/**
* Return the pages being part of this wizard
*
+ * In case this is a nested wizard a flattened array of all contained pages is returned.
+ *
* @return array
*/
public function getPages()
{
- return $this->pages;
+ $pages = array();
+ foreach ($this->pages as $page) {
+ if ($page instanceof self) {
+ $pages = array_merge($pages, $page->getPages());
+ } else {
+ $pages[] = $page;
+ }
+ }
+
+ return $pages;
}
/**
* Return the page with the given name
*
+ * Note that it's also possible to retrieve a nested wizard's page by using this method.
+ *
* @param string $name The name of the page to return
*
* @return null|Form The page or null in case there is no page with the given name
@@ -98,22 +141,31 @@ class Wizard
}
/**
- * Add a new page to this wizard
+ * Add a new page or wizard to this wizard
*
- * @param Form $page The page to add to the wizard
+ * @param Form|Wizard $page The page or wizard to add to the wizard
*
* @return self
*/
- public function addPage(Form $page)
+ public function addPage($page)
{
+ if (! $page instanceof Form && ! $page instanceof self) {
+ throw InvalidArgumentException(
+ 'The $page argument must be an instance of Icinga\Web\Form '
+ . 'or Icinga\Web\Wizard but is of type: ' . get_class($page)
+ );
+ } elseif ($page instanceof self) {
+ $page->setParent($this);
+ }
+
$this->pages[] = $page;
return $this;
}
/**
- * Add multiple pages to this wizard
+ * Add multiple pages or wizards to this wizard
*
- * @param array $pages The pages to add to the wizard
+ * @param array $pages The pages or wizards to add to the wizard
*
* @return self
*/
@@ -148,6 +200,10 @@ class Wizard
*/
public function getCurrentPage()
{
+ if ($this->parent) {
+ return $this->parent->getCurrentPage();
+ }
+
if ($this->currentPage === null) {
$this->assertHasPages();
$pages = $this->getPages();
@@ -202,6 +258,10 @@ class Wizard
{
$page = $this->getCurrentPage();
+ if (($wizard = $this->findWizard($page)) !== null) {
+ return $wizard->handleRequest($request);
+ }
+
if ($request === null) {
$request = $page->getRequest();
}
@@ -238,6 +298,39 @@ class Wizard
return $request;
}
+ /**
+ * Return the wizard for the given page or null if its not part of a wizard
+ *
+ * @param Form $page The page to return its wizard for
+ *
+ * @return Wizard|null
+ */
+ protected function findWizard(Form $page)
+ {
+ foreach ($this->getWizards() as $wizard) {
+ if ($wizard->getPage($page->getName()) === $page) {
+ return $wizard;
+ }
+ }
+ }
+
+ /**
+ * Return this wizard's child wizards
+ *
+ * @return array
+ */
+ protected function getWizards()
+ {
+ $wizards = array();
+ foreach ($this->pages as $pageOrWizard) {
+ if ($pageOrWizard instanceof self) {
+ $wizards[] = $pageOrWizard;
+ }
+ }
+
+ return $wizards;
+ }
+
/**
* Return the request data based on given form's request method
*
@@ -264,6 +357,10 @@ class Wizard
*/
protected function getRequestedPage(array $requestData)
{
+ if ($this->parent) {
+ return $this->parent->getRequestedPage($requestData);
+ }
+
if (isset($requestData[static::BTN_NEXT])) {
return $requestData[static::BTN_NEXT];
} elseif (isset($requestData[static::BTN_PREV])) {
@@ -280,6 +377,10 @@ class Wizard
*/
protected function getDirection(Request $request = null)
{
+ if ($this->parent) {
+ return $this->parent->getDirection($request);
+ }
+
$currentPage = $this->getCurrentPage();
if ($request === null) {
@@ -299,7 +400,7 @@ class Wizard
/**
* Return the new page to set as current page
*
- * Permission is checked by verifying that the requested page's previous page has page data available.
+ * Permission is checked by verifying that the requested page or its previous page has page data available.
* The requested page is automatically permitted without any checks if the origin page is its previous
* page or one that occurs later in order.
*
@@ -312,11 +413,15 @@ class Wizard
*/
protected function getNewPage($requestedPage, Form $originPage)
{
+ if ($this->parent) {
+ return $this->parent->getNewPage($requestedPage, $originPage);
+ }
+
if (($page = $this->getPage($requestedPage)) !== null) {
$permitted = true;
$pages = $this->getPages();
- if (($index = array_search($page, $pages, true)) > 0) {
+ if (! $this->hasPageData($requestedPage) && ($index = array_search($page, $pages, true)) > 0) {
$previousPage = $pages[$index - 1];
if ($originPage === null || ($previousPage->getName() !== $originPage->getName()
&& array_search($originPage, $pages, true) < $index))
@@ -335,6 +440,36 @@ class Wizard
);
}
+ /**
+ * Return the next or previous page based on the given one
+ *
+ * @param Form $page The page to skip
+ *
+ * @return Form
+ */
+ protected function skipPage(Form $page)
+ {
+ if ($this->parent) {
+ return $this->parent->skipPage($page);
+ }
+
+ if ($this->hasPageData($page->getName())) {
+ $pageData = & $this->getPageData();
+ unset($pageData[$page->getName()]);
+ }
+
+ $pages = $this->getPages();
+ if ($this->getDirection() === static::FORWARD) {
+ $nextPage = $pages[array_search($page, $pages, true) + 1];
+ $newPage = $this->getNewPage($nextPage->getName(), $page);
+ } else { // $this->getDirection() === static::BACKWARD
+ $previousPage = $pages[array_search($page, $pages, true) - 1];
+ $newPage = $this->getNewPage($previousPage->getName(), $page);
+ }
+
+ return $newPage;
+ }
+
/**
* Return whether the given page is this wizard's last page
*
@@ -344,10 +479,27 @@ class Wizard
*/
protected function isLastPage(Form $page)
{
+ if ($this->parent) {
+ return $this->parent->isLastPage($page);
+ }
+
$pages = $this->getPages();
return $page->getName() === end($pages)->getName();
}
+ /**
+ * Return whether all of this wizard's pages were visited by the user
+ *
+ * The base implementation just verifies that the very last page has page data available.
+ *
+ * @return bool
+ */
+ public function isComplete()
+ {
+ $pages = $this->getPages();
+ return $this->hasPageData($pages[count($pages) - 1]->getName());
+ }
+
/**
* Set whether this wizard has been completed
*
@@ -421,6 +573,10 @@ class Wizard
*/
public function getSession()
{
+ if ($this->parent) {
+ return $this->parent->getSession();
+ }
+
return Session::getSession()->getNamespace(get_class($this));
}
diff --git a/library/vendor/Parsedown/LICENSE.txt b/library/vendor/Parsedown/LICENSE
similarity index 100%
rename from library/vendor/Parsedown/LICENSE.txt
rename to library/vendor/Parsedown/LICENSE
diff --git a/library/vendor/Parsedown/SOURCE b/library/vendor/Parsedown/SOURCE
index c5a2c7c28..43ee6c61c 100644
--- a/library/vendor/Parsedown/SOURCE
+++ b/library/vendor/Parsedown/SOURCE
@@ -4,3 +4,4 @@ DESTINATION=.
wget -O ${FILENAME}.tar.gz https://github.com/erusev/parsedown/archive/${RELEASE}.tar.gz
tar xfz ${FILENAME}.tar.gz -C $DESTINATION/ --strip-components 1 $FILENAME/Parsedown.php $FILENAME/LICENSE.txt
chmod 644 $DESTINATION/Parsedown.php
+mv LICENSE.txt LICENSE
diff --git a/library/vendor/dompdf/LICENSE.LGPL b/library/vendor/dompdf/LICENSE
similarity index 100%
rename from library/vendor/dompdf/LICENSE.LGPL
rename to library/vendor/dompdf/LICENSE
diff --git a/library/vendor/dompdf/SOURCE b/library/vendor/dompdf/SOURCE
index 9343b58cf..c26253e30 100644
--- a/library/vendor/dompdf/SOURCE
+++ b/library/vendor/dompdf/SOURCE
@@ -1,6 +1,7 @@
curl https://codeload.github.com/dompdf/dompdf/tar.gz/v0.6.1 -o dompdf-0.6.1.tar.gz
tar xzf dompdf-0.6.1.tar.gz --strip-components 1 dompdf-0.6.1/{include/*.php,lib,dompdf*.php,LICENSE.LGPL}
rm dompdf-0.6.1.tar.gz
+mv LICENSE.LGPL LICENSE
curl https://codeload.github.com/PhenX/php-font-lib/tar.gz/0.3.1 -o php-font-lib-0.3.1.tar.gz
mkdir lib/php-font-lib/classes
diff --git a/modules/doc/application/controllers/IcingawebController.php b/modules/doc/application/controllers/IcingawebController.php
index 5740f50a9..60c5da5ee 100644
--- a/modules/doc/application/controllers/IcingawebController.php
+++ b/modules/doc/application/controllers/IcingawebController.php
@@ -8,12 +8,36 @@ use Icinga\Module\Doc\DocController;
class Doc_IcingawebController extends DocController
{
+ /**
+ * Get the path to Icinga Web 2's documentation
+ *
+ * @return string
+ *
+ * @throws Zend_Controller_Action_Exception If Icinga Web 2's documentation is not available
+ */
+ protected function getPath()
+ {
+ $path = Icinga::app()->getBaseDir('doc');
+ if (is_dir($path)) {
+ return $path;
+ }
+ if (($path = $this->Config()->get('documentation', 'icingaweb2')) !== null) {
+ if (is_dir($path)) {
+ return $path;
+ }
+ }
+ throw new Zend_Controller_Action_Exception(
+ $this->translate('Documentation for Icinga Web 2 is not available'),
+ 404
+ );
+ }
+
/**
* View the toc of Icinga Web 2's documentation
*/
public function tocAction()
{
- return $this->renderToc(Icinga::app()->getApplicationDir('/../doc'), 'Icinga Web 2', 'doc/icingaweb/chapter');
+ $this->renderToc($this->getPath(), 'Icinga Web 2', 'doc/icingaweb/chapter');
}
/**
@@ -26,12 +50,12 @@ class Doc_IcingawebController extends DocController
$chapterId = $this->getParam('chapterId');
if ($chapterId === null) {
throw new Zend_Controller_Action_Exception(
- $this->translate('Missing parameter \'chapterId\''),
+ sprintf($this->translate('Missing parameter \'%s\''), 'chapterId'),
404
);
}
- return $this->renderChapter(
- Icinga::app()->getApplicationDir('/../doc'),
+ $this->renderChapter(
+ $this->getPath(),
$chapterId,
'doc/icingaweb/toc',
'doc/icingaweb/chapter'
@@ -43,6 +67,6 @@ class Doc_IcingawebController extends DocController
*/
public function pdfAction()
{
- return $this->renderPdf(Icinga::app()->getApplicationDir('/../doc'), 'Icinga Web 2', 'doc/icingaweb/chapter');
+ $this->renderPdf($this->getPath(), 'Icinga Web 2', 'doc/icingaweb/chapter');
}
}
diff --git a/modules/doc/application/controllers/ModuleController.php b/modules/doc/application/controllers/ModuleController.php
index 1e9cf43b1..a4d14cf61 100644
--- a/modules/doc/application/controllers/ModuleController.php
+++ b/modules/doc/application/controllers/ModuleController.php
@@ -9,6 +9,40 @@ use Icinga\Module\Doc\Exception\DocException;
class Doc_ModuleController extends DocController
{
+ /**
+ * Get the path to a module documentation
+ *
+ * @param string $module The name of the module
+ * @param string $default The default path
+ * @param bool $suppressErrors Whether to not throw an exception if the module documentation is not
+ * available
+ *
+ * @return string|null Path to the documentation or null if the module documentation is not
+ * available and errors are suppressed
+ *
+ * @throws Zend_Controller_Action_Exception If the module documentation is not available and errors are not
+ * suppressed
+ */
+ protected function getPath($module, $default, $suppressErrors = false)
+ {
+ if (is_dir($default)) {
+ return $default;
+ }
+ if (($path = $this->Config()->get('documentation', 'modules')) !== null) {
+ $path = str_replace('{module}', $module, $path);
+ if (is_dir($path)) {
+ return $path;
+ }
+ }
+ if ($suppressErrors) {
+ return null;
+ }
+ throw new Zend_Controller_Action_Exception(
+ sprintf($this->translate('Documentation for module \'%s\' is not available'), $module),
+ 404
+ );
+ }
+
/**
* List modules which are enabled and having the 'doc' directory
*/
@@ -16,10 +50,10 @@ class Doc_ModuleController extends DocController
{
$moduleManager = Icinga::app()->getModuleManager();
$modules = array();
- foreach (Icinga::app()->getModuleManager()->listEnabledModules() as $enabledModule) {
- $docDir = $moduleManager->getModuleDir($enabledModule, '/doc');
- if (is_dir($docDir)) {
- $modules[] = $enabledModule;
+ foreach (Icinga::app()->getModuleManager()->listEnabledModules() as $module) {
+ $path = $this->getPath($module, $moduleManager->getModuleDir($module, '/doc'), true);
+ if ($path !== null) {
+ $modules[] = $module;
}
}
$this->view->modules = $modules;
@@ -37,7 +71,7 @@ class Doc_ModuleController extends DocController
{
if (empty($moduleName)) {
throw new Zend_Controller_Action_Exception(
- $this->translate('Missing parameter \'moduleName\''),
+ sprintf($this->translate('Missing parameter \'%s\''), 'moduleName'),
404
);
}
@@ -63,16 +97,15 @@ class Doc_ModuleController extends DocController
*/
public function tocAction()
{
- $moduleName = $this->getParam('moduleName');
- $this->assertModuleEnabled($moduleName);
- $this->view->moduleName = $moduleName;
- $moduleManager = Icinga::app()->getModuleManager();
+ $module = $this->getParam('moduleName');
+ $this->assertModuleEnabled($module);
+ $this->view->moduleName = $module;
try {
- return $this->renderToc(
- $moduleManager->getModuleDir($moduleName, '/doc'),
- $moduleName,
+ $this->renderToc(
+ $this->getPath($module, Icinga::app()->getModuleManager()->getModuleDir($module, '/doc')),
+ $module,
'doc/module/chapter',
- array('moduleName' => $moduleName)
+ array('moduleName' => $module)
);
} catch (DocException $e) {
throw new Zend_Controller_Action_Exception($e->getMessage(), 404);
@@ -88,24 +121,23 @@ class Doc_ModuleController extends DocController
*/
public function chapterAction()
{
- $moduleName = $this->getParam('moduleName');
- $this->assertModuleEnabled($moduleName);
+ $module = $this->getParam('moduleName');
+ $this->assertModuleEnabled($module);
$chapterId = $this->getParam('chapterId');
if ($chapterId === null) {
throw new Zend_Controller_Action_Exception(
- $this->translate('Missing parameter \'chapterId\''),
+ sprintf($this->translate('Missing parameter \'%s\''), 'chapterId'),
404
);
}
- $this->view->moduleName = $moduleName;
- $moduleManager = Icinga::app()->getModuleManager();
+ $this->view->moduleName = $module;
try {
- return $this->renderChapter(
- $moduleManager->getModuleDir($moduleName, '/doc'),
+ $this->renderChapter(
+ $this->getPath($module, Icinga::app()->getModuleManager()->getModuleDir($module, '/doc')),
$chapterId,
- $this->_helper->url->url(array('moduleName' => $moduleName), 'doc/module/toc'),
+ $this->_helper->url->url(array('moduleName' => $module), 'doc/module/toc'),
'doc/module/chapter',
- array('moduleName' => $moduleName)
+ array('moduleName' => $module)
);
} catch (DocException $e) {
throw new Zend_Controller_Action_Exception($e->getMessage(), 404);
@@ -119,14 +151,13 @@ class Doc_ModuleController extends DocController
*/
public function pdfAction()
{
- $moduleName = $this->getParam('moduleName');
- $this->assertModuleEnabled($moduleName);
- $moduleManager = Icinga::app()->getModuleManager();
- return $this->renderPdf(
- $moduleManager->getModuleDir($moduleName, '/doc'),
- $moduleName,
+ $module = $this->getParam('moduleName');
+ $this->assertModuleEnabled($module);
+ $this->renderPdf(
+ $this->getPath($module, Icinga::app()->getModuleManager()->getModuleDir($module, '/doc')),
+ $module,
'doc/module/chapter',
- array('moduleName' => $moduleName)
+ array('moduleName' => $module)
);
}
}
diff --git a/modules/doc/configuration.php b/modules/doc/configuration.php
index 87e5da77a..6e924e964 100644
--- a/modules/doc/configuration.php
+++ b/modules/doc/configuration.php
@@ -2,7 +2,7 @@
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
-/* @var $this \Icinga\Application\Modules\Module */
+/** @type $this \Icinga\Application\Modules\Module */
$section = $this->menuSection($this->translate('Documentation'), array(
'title' => 'Documentation',
diff --git a/modules/doc/doc/1-module-documentation.md b/modules/doc/doc/1-module-documentation.md
new file mode 100644
index 000000000..edf20aac2
--- /dev/null
+++ b/modules/doc/doc/1-module-documentation.md
@@ -0,0 +1,67 @@
+# Writing Module Documentation
+
+
+
+Icinga Web 2 is capable of viewing your module's documentation, if the documentation is written in
+[Markdown](http://en.wikipedia.org/wiki/Markdown). Please refer to
+[Markdown Syntax Documentation](http://daringfireball.net/projects/markdown/syntax) for Markdown's formatting syntax.
+
+## Where to Put Module Documentation?
+
+By default, your module's Markdown documentation files must be placed in the `doc` directory beneath your module's root
+directory, e.g.:
+
+ example-module/doc
+
+## Chapters
+
+Each Markdown documentation file represents a chapter of your module's documentation. The first found heading inside
+each file is the chapter's title. The order of chapters is based on the case insensitive "Natural Order" of your files'
+names. Natural Order means that the file names are ordered in the way which seems natural to humans.
+It is best practice to prefix Markdown documentation file names with numbers to ensure that they appear in the correct
+order, e.g.:
+
+ 1-about.md
+ 2-installation.md
+ 3-configuration.md
+
+## Table Of Contents
+
+The table of contents for your module's documentation is auto-generated based on all found headings inside each
+Markdown documentation file.
+
+## Linking Between Headings
+
+For linking between headings, place an anchor where you want to link to, e.g.:
+
+ # Heading
+
+Please note that anchors have to be unique across all your Markdown documentation files.
+
+Now you can reference the anchor either in the same or **in another** Markdown documentation file, e.g.:
+
+ This is a link to [Heading](#heading).
+
+Other tools support linking between headings by giving the filename plus the anchor to link to, e.g.:
+
+ This is a link to [About/Heading](1-about.md#heading.md)
+
+This syntax is also supported in Icinga Web 2.
+
+## Including Images
+
+Images must placed in the `img` directory beneath your module's `public` directory, e.g.:
+
+ example-module/public/img/doc
+
+Module images can be accessed using the following URL:
+
+ {baseURL}/img/{moduleName}/{file} e.g. icingaweb/img/example-module/doc/example.png
+
+Markdown's image syntax is very similar to Markdown's link syntax, but prefixed with an exclamation mark, e.g.:
+
+ 
+
+URLs to images inside your Markdown documentation files must be specified without the base URL, e.g.:
+
+ 
diff --git a/modules/doc/library/Doc/DocController.php b/modules/doc/library/Doc/DocController.php
index bc782953f..0d12f58df 100644
--- a/modules/doc/library/Doc/DocController.php
+++ b/modules/doc/library/Doc/DocController.php
@@ -28,7 +28,7 @@ class DocController extends ModuleActionController
$urlParams
);
$this->view->title = $chapterId;
- return $this->render('chapter', null, true);
+ $this->render('chapter', null, true);
}
/**
@@ -46,7 +46,7 @@ class DocController extends ModuleActionController
$name = ucfirst($name);
$this->view->docName = $name;
$this->view->title = sprintf($this->translate('%s Documentation'), $name);
- return $this->render('toc', null, true);
+ $this->render('toc', null, true);
}
/**
@@ -71,6 +71,6 @@ class DocController extends ModuleActionController
);
$this->view->docName = $name;
$this->_request->setParam('format', 'pdf');
- return $this->render('pdf', null, true);
+ $this->render('pdf', null, true);
}
}
diff --git a/modules/doc/library/Doc/DocIterator.php b/modules/doc/library/Doc/DocIterator.php
index 43a9c7727..3045b6309 100644
--- a/modules/doc/library/Doc/DocIterator.php
+++ b/modules/doc/library/Doc/DocIterator.php
@@ -9,6 +9,8 @@ use Countable;
use IteratorAggregate;
use RecursiveIteratorIterator;
use RecursiveDirectoryIterator;
+use Icinga\File\NonEmptyFileIterator;
+use Icinga\File\FileExtensionFilterIterator;
/**
* Iterator over non-empty Markdown files ordered by the case insensitive "natural order" of file names
@@ -29,12 +31,14 @@ class DocIterator implements Countable, IteratorAggregate
*/
public function __construct($path)
{
- $it = new RecursiveIteratorIterator(
+ $it = new FileExtensionFilterIterator(
new NonEmptyFileIterator(
- new MarkdownFileIterator(
- new RecursiveDirectoryIterator($path)
+ new RecursiveIteratorIterator(
+ new RecursiveDirectoryIterator($path),
+ RecursiveIteratorIterator::SELF_FIRST
)
- )
+ ),
+ 'md'
);
// Unfortunately we have no chance to sort the iterator
$fileInfo = iterator_to_array($it);
diff --git a/modules/doc/library/Doc/DocParser.php b/modules/doc/library/Doc/DocParser.php
index c63532dc1..6cfeca418 100644
--- a/modules/doc/library/Doc/DocParser.php
+++ b/modules/doc/library/Doc/DocParser.php
@@ -31,7 +31,7 @@ class DocParser
/**
* Create a new documentation parser for the given path
*
- * @param string $path Path to the documentation
+ * @param string $path Path to the documentation
*
* @throws DocException If the documentation directory does not exist
* @throws NotReadableError If the documentation directory is not readable
diff --git a/modules/doc/library/Doc/MarkdownFileIterator.php b/modules/doc/library/Doc/MarkdownFileIterator.php
deleted file mode 100644
index 6f317ce6a..000000000
--- a/modules/doc/library/Doc/MarkdownFileIterator.php
+++ /dev/null
@@ -1,31 +0,0 @@
-getInnerIterator()->current();
- /* @var $current \SplFileInfo */
- if (! $current->isFile()) {
- return false;
- }
- $filename = $current->getFilename();
- $sfx = substr($filename, -3);
- return $sfx === false ? false : strtolower($sfx) === '.md';
- }
-}
diff --git a/modules/doc/library/Doc/NonEmptyFileIterator.php b/modules/doc/library/Doc/NonEmptyFileIterator.php
deleted file mode 100644
index 71bf5acfa..000000000
--- a/modules/doc/library/Doc/NonEmptyFileIterator.php
+++ /dev/null
@@ -1,31 +0,0 @@
-getInnerIterator()->current();
- /* @var $current \SplFileInfo */
- if (! $current->isFile()
- || $current->getSize() === 0
- ) {
- return false;
- }
- return true;
- }
-}
diff --git a/modules/doc/library/Doc/SectionRenderer.php b/modules/doc/library/Doc/SectionRenderer.php
index 2fdaf8e90..f923783f6 100644
--- a/modules/doc/library/Doc/SectionRenderer.php
+++ b/modules/doc/library/Doc/SectionRenderer.php
@@ -232,7 +232,7 @@ class SectionRenderer extends Renderer
$html
);
$content[] = preg_replace_callback(
- '/[^>]*?\s+)?href="#(?P[^"]+)"/',
+ '/[^>]*?\s+)?href="(?:(?!http:\/\/)[^#]*)#(?P[^"]+)"/',
array($callback, 'render'),
$html
);
diff --git a/modules/doc/module.info b/modules/doc/module.info
index 2826d72de..1689fd940 100644
--- a/modules/doc/module.info
+++ b/modules/doc/module.info
@@ -1,4 +1,4 @@
Module: doc
-Version: 2.0.0~alpha4
+Version: 2.0.0
Description: Documentation module
Extracts, shows and exports documentation for Icinga Web 2 and it's modules.
diff --git a/modules/doc/public/img/doc/markdown.png b/modules/doc/public/img/doc/markdown.png
new file mode 100644
index 000000000..93e729bc7
Binary files /dev/null and b/modules/doc/public/img/doc/markdown.png differ
diff --git a/modules/doc/run.php b/modules/doc/run.php
index 7392e4c22..31aff8ff0 100644
--- a/modules/doc/run.php
+++ b/modules/doc/run.php
@@ -47,4 +47,3 @@ $this->addRoute('doc/module/chapter', $docModuleChapter);
$this->addRoute('doc/icingaweb/chapter', $docIcingaWebChapter);
$this->addRoute('doc/module/toc', $docModuleToc);
$this->addRoute('doc/module/pdf', $docModulePdf);
-
diff --git a/modules/monitoring/application/controllers/AlertsummaryController.php b/modules/monitoring/application/controllers/AlertsummaryController.php
index 75f0fc1fe..a4ef76b44 100644
--- a/modules/monitoring/application/controllers/AlertsummaryController.php
+++ b/modules/monitoring/application/controllers/AlertsummaryController.php
@@ -78,7 +78,9 @@ class Monitoring_AlertsummaryController extends Controller
'notification',
array(
'host',
+ 'host_display_name',
'service',
+ 'service_display_name',
'notification_output',
'notification_contact',
'notification_start_time',
@@ -193,11 +195,11 @@ class Monitoring_AlertsummaryController extends Controller
$out = new stdClass();
if ($yesterday === $today) {
- $out->trend = 'unchanged';
+ $out->trend = $this->translate('unchanged');
} elseif ($yesterday > $today) {
- $out->trend = 'down';
+ $out->trend = $this->translate('down');
} else {
- $out->trend = 'up';
+ $out->trend = $this->translate('up');
}
if ($yesterday <= 0) {
@@ -342,10 +344,10 @@ class Monitoring_AlertsummaryController extends Controller
$gridChart = new GridChart();
$gridChart->alignTopLeft();
- $gridChart->setAxisLabel('', mt('monitoring', 'Notifications'))
+ $gridChart->setAxisLabel($this->createPeriodDescription(), mt('monitoring', 'Notifications'))
->setXAxis(new StaticAxis())
- ->setAxisMin(null, 0)
- ->setYAxis(new LinearUnit(10));
+ ->setYAxis(new LinearUnit(10))
+ ->setAxisMin(null, 0);
$interval = $this->getInterval();
@@ -429,11 +431,10 @@ class Monitoring_AlertsummaryController extends Controller
$item[1] = $item[1]/60/60;
}
-
$gridChart->drawBars(
array(
'label' => $this->translate('Notifications'),
- 'color' => '#049baf',
+ 'color' => '#07C0D9',
'data' => $notifications,
'showPoints' => true
)
@@ -470,15 +471,15 @@ class Monitoring_AlertsummaryController extends Controller
$gridChart = new GridChart();
$gridChart->alignTopLeft();
- $gridChart->setAxisLabel('', mt('monitoring', 'Notifications'))
+ $gridChart->setAxisLabel($this->createPeriodDescription(), mt('monitoring', 'Notifications'))
->setXAxis(new StaticAxis())
- ->setAxisMin(null, 0)
- ->setYAxis(new LinearUnit(10));
+ ->setYAxis(new LinearUnit(10))
+ ->setAxisMin(null, 0);
$gridChart->drawBars(
array(
'label' => $this->translate('Notifications'),
- 'color' => '#049baf',
+ 'color' => '#07C0D9',
'data' => $this->notificationData,
'showPoints' => true
)
@@ -507,7 +508,9 @@ class Monitoring_AlertsummaryController extends Controller
'notification',
array(
'host',
+ 'host_display_name',
'service',
+ 'service_display_name',
'notification_output',
'notification_contact',
'notification_start_time',
@@ -554,7 +557,7 @@ class Monitoring_AlertsummaryController extends Controller
{
$format = '';
if ($interval === '1d') {
- $format = '%H:00:00';
+ $format = '%H:00';
} elseif ($interval === '1w') {
$format = '%Y-%m-%d';
} elseif ($interval === '1m') {
@@ -623,4 +626,28 @@ class Monitoring_AlertsummaryController extends Controller
return $interval;
}
+
+ /**
+ * Create a human-readable description of the current interval size
+ *
+ * @return string The description of the current interval size
+ */
+ private function createPeriodDescription()
+ {
+ $int = $this->getInterval();
+ switch ($int) {
+ case '1d':
+ return t('Hour');
+ break;
+ case '1w';
+ return t('Day');
+ break;
+ case '1m':
+ return t('Day');
+ break;
+ case '1y':
+ return t('Month');
+ break;
+ }
+ }
}
diff --git a/modules/monitoring/application/controllers/ChartController.php b/modules/monitoring/application/controllers/ChartController.php
index 2024f83f4..757329bfe 100644
--- a/modules/monitoring/application/controllers/ChartController.php
+++ b/modules/monitoring/application/controllers/ChartController.php
@@ -6,6 +6,8 @@ use Icinga\Module\Monitoring\Controller;
use Icinga\Chart\GridChart;
use Icinga\Chart\PieChart;
use Icinga\Chart\Unit\StaticAxis;
+use Icinga\Chart\Unit\LogarithmicUnit;
+use Icinga\Chart\Unit\LinearUnit;
/**
* Class Monitoring_CommandController
@@ -20,6 +22,95 @@ class Monitoring_ChartController extends Controller
$this->view->compact = $this->_request->getParam('view') === 'compact';
}
+ private function drawLogChart1()
+ {
+ $chart = new GridChart();
+ $chart->alignTopLeft();
+ $chart->setAxisLabel('X axis label', 'Y axis label')
+ ->setYAxis(new LogarithmicUnit());
+
+ for ($i = -15; $i < 15; $i++) {
+ $data1[] = array($i, -$i * rand(1, 10) * pow(2, rand(1, 2)));
+ }
+ for ($i = -15; $i < 15; $i++) {
+ $data2[] = array($i, 1000 + $i * rand(1, 35) * pow(2, rand(1, 2)));
+ }
+ for ($i = -15; $i < 15; $i++) {
+ $data3[] = array($i, $i * rand(1, 100) * pow(2, rand(1, 10)) - 1000);
+ }
+
+ $chart->drawLines(
+ array(
+ 'label' => 'Random 1',
+ 'color' => '#F56',
+ 'data' => $data1,
+ 'showPoints' => true
+ )
+ );
+ $chart->drawLines(
+ array(
+ 'label' => 'Random 2',
+ 'color' => '#fa4',
+ 'data' => $data2,
+ 'showPoints' => true
+ )
+ );
+ $chart->drawLines(
+ array(
+ 'label' => 'Random 3',
+ 'color' => '#4b7',
+ 'data' => $data3,
+ 'showPoints' => true
+ )
+ );
+ return $chart;
+ }
+
+ private function drawLogChart2()
+ {
+ $chart = new GridChart();
+ $chart->alignTopLeft();
+ $chart->setAxisLabel('X axis label', 'Y axis label')
+ ->setYAxis(new LogarithmicUnit());
+
+ for ($i = -10; $i < 10; $i++) {
+ $sign = $i > 0 ? 1 :
+ ($i < 0 ? -1 : 0);
+ $data[] = array($i, $sign * pow(10, abs($i)));
+ }
+ $chart->drawLines(
+ array(
+ 'label' => 'f(x): sign(x) * 10^|x|',
+ 'color' => '#F56',
+ 'data' => $data,
+ 'showPoints' => true
+ )
+ );
+ return $chart;
+ }
+ private function drawLogChart3()
+ {
+ $chart = new GridChart();
+ $chart->alignTopLeft();
+ $chart->setAxisLabel('X axis label', 'Y axis label')
+ ->setYAxis(new LogarithmicUnit());
+
+ for ($i = -2; $i < 3; $i++) {
+ $sign = $i > 0 ? 1 :
+ ($i < 0 ? -1 : 0);
+ $data[] = array($i, $sign * pow(10, abs($i)));
+ }
+ $chart->drawLines(
+ array(
+ 'label' => 'f(x): sign(x) * 10^|x|',
+ 'color' => '#F56',
+ 'data' => $data,
+ 'showPoints' => true
+ )
+ );
+ return $chart;
+ }
+
public function testAction()
{
$this->chart = new GridChart();
@@ -28,7 +119,7 @@ class Monitoring_ChartController extends Controller
$data1 = array();
$data2 = array();
$data3 = array();
- for ($i = 0; $i < 25; $i++) {
+ for ($i = 0; $i < 50; $i++) {
$data3[] = array('Label ' . $i, rand(0, 30));
}
@@ -36,13 +127,13 @@ class Monitoring_ChartController extends Controller
$this->chart->drawLines(
array(
'label' => 'Nr of outtakes',
- 'color' => 'red',
+ 'color' => '#F56',
'width' => '5',
'data' => $data
), array(
'label' => 'Some line',
- 'color' => 'blue',
+ 'color' => '#fa4',
'width' => '4',
'data' => $data3,
@@ -52,8 +143,8 @@ class Monitoring_ChartController extends Controller
*/
$this->chart->drawBars(
array(
- 'label' => 'Some other line',
- 'color' => 'green',
+ 'label' => 'A big amount of data',
+ 'color' => '#4b7',
'data' => $data3,
'showPoints' => true
)
@@ -68,7 +159,11 @@ class Monitoring_ChartController extends Controller
)
);
*/
- $this->view->svg = $this->chart;
+ $this->view->svgs = array();
+ $this->view->svgs[] = $this->drawLogChart1();
+ $this->view->svgs[] = $this->drawLogChart2();
+ $this->view->svgs[] = $this->drawLogChart3();
+ $this->view->svgs[] = $this->chart;
}
public function hostgroupAction()
@@ -185,18 +280,15 @@ class Monitoring_ChartController extends Controller
$upBars = array();
$downBars = array();
$unreachableBars = array();
- foreach ($query as $hostgroup) {
+ for ($i = 0; $i < 50; $i++) {
$upBars[] = array(
- $hostgroup->hostgroup,
- $hostgroup->hosts_up
+ (string)$i, rand(1, 200), rand(1, 200)
);
$downBars[] = array(
- $hostgroup->hostgroup,
- $hostgroup->hosts_down_unhandled
+ (string)$i, rand(1, 200), rand(1, 200)
);
$unreachableBars[] = array(
- $hostgroup->hostgroup,
- $hostgroup->hosts_unreachable_unhandled
+ (string)$i, rand(1, 200), rand(1, 200)
);
}
$tooltip = mt('monitoring', '{title}:
{value} of {sum} hosts are {label}');
@@ -272,7 +364,14 @@ class Monitoring_ChartController extends Controller
(int) $query->hosts_unreachable_unhandled,
(int) $query->hosts_pending
),
- 'colors' => array('#44bb77', '#ff4444', '#ff0000', '#E066FF', '#f099FF', '#fefefe'),
+ 'colors' => array(
+ '#44bb77', // 'Ok'
+ '#ff4444', // 'Warning'
+ '#ff0000', // 'WarningHandled'
+ '#E066FF',
+ '#f099FF',
+ '#fefefe'
+ ),
'labels'=> array(
(int) $query->hosts_up . mt('monitoring', ' Up Hosts'),
(int) $query->hosts_down_handled . mt('monitoring', ' Down Hosts (Handled)'),
diff --git a/modules/monitoring/application/controllers/CommandController.php b/modules/monitoring/application/controllers/CommandController.php
deleted file mode 100644
index d2615104a..000000000
--- a/modules/monitoring/application/controllers/CommandController.php
+++ /dev/null
@@ -1,1098 +0,0 @@
-form = $form;
- }
-
- /**
- * Test if we have a valid form object
- *
- * @return bool
- */
- public function issetForm()
- {
- return $this->form !== null && ($this->form instanceof Form);
- }
-
- protected function addTitleTab($action)
- {
- $this->getTabs()->add($action, array(
- 'title' => ucfirst($action),
- 'url' => Url::fromRequest()
- ))->activate($action);
- }
-
- /**
- * Post dispatch method
- *
- * When we have a form put it into the view
- */
- public function postDispatch()
- {
-
- if ($this->issetForm()) {
- if ($this->form->isSubmittedAndValid()) {
- $this->_helper->viewRenderer->setNoRender(true);
- $this->_helper->layout()->disableLayout();
- $this->ignoreXhrBody();
- if ($this->_request->getHeader('referer') && ! $this->getRequest()->isXmlHttpRequest()) {
- $this->redirect($this->_request->getHeader('referer'));
- }
- } else {
- $this->view->form = $this->form;
- }
- }
- parent::postDispatch();
- }
-
- /**
- * Controller configuration
- *
- * @throws Icinga\Exception\ConfigurationError
- */
- public function init()
- {
- if ($this->_request->isPost()) {
- $instance = $this->_request->getPost('instance');
- $targetConfig = Config::module('monitoring', 'instances');
- if ($instance) {
- if ($targetConfig->get($instance)) {
- $this->target = new CommandPipe($targetConfig->get($instance));
- } else {
- throw new ConfigurationError(
- $this->translate('Instance is not configured: %s'),
- $instance
- );
- }
- } else {
- if ($targetConfig && $targetInfo = $targetConfig->current()) {
- // Take the very first section
- $this->target = new CommandPipe($targetInfo);
- } else {
- throw new ConfigurationError($this->translate('No instances are configured yet'));
- }
- }
- }
-
- if ($this->getRequest()->getActionName() !== 'list') {
- $this->_helper->viewRenderer->setRender(self::DEFAULT_VIEW_SCRIPT);
- }
-
- $this->view->objects = array();
- }
-
- /**
- * Retrieve all existing targets for host- and service combination
- *
- * @param $hostOnly Ignore the service parameters
- * (for example when using commands that only make sense for hosts)
- * @return array Array of monitoring objects
- * @throws Icinga\Exception\MissingParameterException
- */
- private function selectCommandTargets($hostOnly = false)
- {
- $query = null;
-
- $fields = array(
- 'host_name',
- 'host_state'
- );
-
- try {
- $hostname = $this->getParam('host', null);
- $servicename = $this->getParam('service', null);
-
- if (!$hostname && !$servicename) {
- throw new MissingParameterException('No target given for this command');
- }
-
- if ($servicename && !$hostOnly) {
- $fields[] = 'service_description';
- $query = $this->backend->select()
- ->from('serviceStatus', $fields)
- ->where('host', $hostname)
- ->where('service', $servicename);
- } elseif ($hostname) {
- $query = $this->backend->select()->from('hostStatus', $fields)->where('host', $hostname);
- } else {
- throw new MissingParameterException('hostOnly command got no hostname');
- }
- return $query->getQuery()->fetchAll();
-
- } catch (\Exception $e) {
- Logger::error(
- "CommandController: SQL Query '%s' failed (message %s) ",
- $query ? (string) $query->dump() : '--', $e->getMessage()
- );
- return array();
- }
- }
-
- /**
- * Convert other params into valid command structure
- *
- * @param array $supported Array of supported parameter names
- * @param array $params Parameters from request
- *
- * @return array Return
- */
- private function selectOtherTargets(array $supported, array $params)
- {
- $others = array_diff_key($supported, array('host' => true, 'service' => true));
- $otherParams = array_intersect_key($params, $others);
- $out = array();
-
- foreach ($otherParams as $name => $value) {
- $data = new stdClass();
- $data->{$name} = $value;
- $out[] = $data;
- }
-
- return $out;
- }
-
- /**
- * Displays a list of all commands
- *
- * This method uses reflection on the sourcecode to determine all *Action classes and return
- * a list of them (ignoring the listAction)
- */
- public function listAction()
- {
- $reflection = new ReflectionObject($this);
- $commands = array();
- $methods = $reflection->getMethods(ReflectionMethod::IS_PUBLIC);
- foreach ($methods as $method) {
- $name = $method->getName();
- if ($name !== 'listAction' && preg_match('/Action$/', $name)) {
- $commands[] = preg_replace('/Action$/', '', $name);
- }
- }
- $this->view->commands = $commands;
- }
-
- /**
- * Tell the controller that at least one of the parameters in $supported is required to be availabe
- *
- * @param array $supported An array of properties to check for existence in the POST or GET parameter list
- * @throws Exception When non of the supported parameters is given
- */
- private function setSupportedParameters(array $supported)
- {
- $objects = array();
-
- $supported = array_flip($supported);
-
- $given = array_intersect_key($supported, $this->getRequest()->getParams());
-
- if (empty($given)) {
- throw new IcingaException(
- 'Missing parameter, supported: %s',
- implode(', ', array_flip($supported))
- );
- }
-
- if (isset($given['host'])) {
- $objects = $this->selectCommandTargets(!in_array("service", $supported));
- if (empty($objects)) {
- throw new IcingaException('No objects found for your command');
- }
- }
-
- $this->view->objects = $objects;
- }
-
- // ------------------------------------------------------------------------
- // Commands for hosts / services
- // ------------------------------------------------------------------------
-
- /**
- * Handle command disableactivechecks
- */
- public function disableactivechecksAction()
- {
- $this->setSupportedParameters(array('host', 'service', 'global'));
-
- $form = new SingleArgumentCommandForm();
-
- $form->setCommand(
- 'DISABLE_HOST_CHECK',
- 'DISABLE_SVC_CHECK'
- );
-
- $form->setGlobalCommands(
- 'STOP_EXECUTING_HOST_CHECKS',
- 'STOP_EXECUTING_SVC_CHECKS'
- );
-
- $form->setRequest($this->getRequest());
- $form->setSubmitLabel($this->translate('Disable Active Checks'));
-
- if ($form->provideGlobalCommand()) {
- $form->addNote($this->translate('Disable active checks on a program-wide basis.'));
- } else {
- $form->addNote($this->translate('Disable active checks for this object.'));
- }
-
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, active checks will be disabled'));
- }
- }
-
- /**
- * Handle command enableactivechecks
- */
- public function enableactivechecksAction()
- {
- $this->setSupportedParameters(array('host', 'service', 'global'));
- $form = new SingleArgumentCommandForm();
- $form->setCommand('ENABLE_HOST_CHECK', 'ENABLE_SVC_CHECK');
- $form->setGlobalCommands('START_EXECUTING_HOST_CHECKS', 'START_EXECUTING_SVC_CHECKS');
-
- $form->setRequest($this->getRequest());
- $form->setSubmitLabel($this->translate('Enable Active Checks'));
- if ($form->provideGlobalCommand()) {
- $form->addNote($this->translate('Enable active checks on a program-wide basis.'));
- } else {
- $form->addNote($this->translate('Enable active checks for this object.'));
- }
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, active checks will be enabled'));
- }
- }
-
- /**
- * Handle command reschedulenextcheck
- */
- public function reschedulenextcheckAction()
- {
- $this->addTitleTab('Reschedule Next Check');
- $this->setSupportedParameters(array('host', 'service'));
- $form = new RescheduleNextCheckForm();
- $form->setRequest($this->getRequest());
- $form->setConfiguration(Config::app());
-
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, check will be rescheduled'));
- }
- }
-
- /**
- * Handle command submitpassivecheckresult
- */
- public function submitpassivecheckresultAction()
- {
- $this->setSupportedParameters(array('host', 'service'));
- $type = SubmitPassiveCheckResultForm::TYPE_SERVICE;
- if ($this->getParam('service', null) === null) {
- $type = SubmitPassiveCheckResultForm::TYPE_HOST;
- }
-
- $form = new SubmitPassiveCheckResultForm();
- $form->setRequest($this->getRequest());
- $form->setType($type);
-
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Passive check result has been submitted'));
- }
- }
-
- /**
- * Handle command stopobsessing
- */
- public function stopobsessingAction()
- {
- $this->setSupportedParameters(array('host', 'service', 'global'));
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->getRequest());
- $form->setSubmitLabel($this->translate('Stop obsessing'));
-
- if ($form->provideGlobalCommand() === true) {
- $form->addNote($this->translate('Disable obsessing on a program-wide basis.'));
- } else {
- $form->addNote($this->translate('Stop obsessing over this object.'));
- }
-
- $form->setCommand(
- 'STOP_OBSESSING_OVER_HOST',
- 'STOP_OBSESSING_OVER_SVC'
- );
-
- $form->setGlobalCommands(
- 'STOP_OBSESSING_OVER_HOST_CHECKS',
- 'STOP_OBSESSING_OVER_SVC_CHECKS'
- );
-
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, obsessing will be disabled'));
- }
- }
-
- /**
- * Handle command startobsessing
- */
- public function startobsessingAction()
- {
- $this->setSupportedParameters(array('host', 'service', 'global'));
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->getRequest());
- $form->setSubmitLabel($this->translate('Start obsessing'));
-
- if ($form->provideGlobalCommand() === true) {
- $form->addNote($this->translate('Enable obsessing on a program-wide basis.'));
- } else {
- $form->addNote($this->translate('Start obsessing over this object.'));
- }
-
- $form->setCommand(
- 'START_OBSESSING_OVER_HOST',
- 'START_OBSESSING_OVER_SVC'
- );
-
- $form->setGlobalCommands(
- 'START_OBSESSING_OVER_HOST_CHECKS',
- 'START_OBSESSING_OVER_SVC_CHECKS'
- );
-
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, obsessing will be enabled'));
- }
- }
-
- /**
- * Handle command stopacceptingpassivechecks
- */
- public function stopacceptingpassivechecksAction()
- {
- $this->setSupportedParameters(array('host', 'service', 'global'));
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->getRequest());
- $form->setSubmitLabel($this->translate('Stop Accepting Passive Checks'));
-
- if ($form->provideGlobalCommand() === true) {
- $form->addNote($this->translate('Disable passive checks on a program-wide basis.'));
- } else {
- $form->addNote($this->translate('Passive checks for this object will be omitted.'));
- }
-
- $form->setCommand(
- 'DISABLE_PASSIVE_HOST_CHECKS',
- 'DISABLE_PASSIVE_SVC_CHECKS'
- );
-
- $form->setGlobalCommands(
- 'STOP_ACCEPTING_PASSIVE_HOST_CHECKS',
- 'STOP_ACCEPTING_PASSIVE_SVC_CHECKS'
- );
-
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, passive check results will be refused'));
- }
- }
-
- /**
- * Handle command startacceptingpassivechecks
- */
- public function startacceptingpassivechecksAction()
- {
- $this->setSupportedParameters(array('host', 'service', 'global'));
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->getRequest());
- $form->setSubmitLabel($this->translate('Start Accepting Passive Checks'));
-
- if ($form->provideGlobalCommand() === true) {
- $form->addNote($this->translate('Enable passive checks on a program-wide basis.'));
- } else {
- $form->addNote($this->translate('Passive checks for this object will be accepted.'));
- }
-
- $form->setCommand(
- 'ENABLE_PASSIVE_HOST_CHECKS',
- 'ENABLE_PASSIVE_SVC_CHECKS'
- );
-
- $form->setGlobalCommands(
- 'START_ACCEPTING_PASSIVE_HOST_CHECKS',
- 'START_ACCEPTING_PASSIVE_SVC_CHECKS'
- );
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, passive check results will be accepted'));
- }
- }
-
- /**
- * Disable notifications with expiration
- *
- * This is a global command only
- */
- public function disablenotificationswithexpireAction()
- {
- $this->setParam('global', 1);
- $form = new DisableNotificationWithExpireForm();
- $form->setRequest($this->_request);
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, notifications will be disabled'));
- }
- }
-
- /**
- * Handle command disablenotifications
- */
- public function disablenotificationsAction()
- {
- $this->setSupportedParameters(array('host', 'service', 'global'));
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->getRequest());
-
- $form->setSubmitLabel($this->translate('Disable Notifications'));
-
- if ($form->provideGlobalCommand() === true) {
- $form->addNote($this->translate('Disable notifications on a program-wide basis.'));
- } else {
- $form->addNote($this->translate('Notifications for this object will be disabled.'));
- }
-
- $form->setCommand('DISABLE_HOST_NOTIFICATIONS', 'DISABLE_SVC_NOTIFICATIONS');
- $form->setGlobalCommands('DISABLE_NOTIFICATIONS');
-
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, notifications will be disabled'));
- }
-
- }
-
- /**
- * Handle command enablenotifications
- */
- public function enablenotificationsAction()
- {
- $this->addTitleTab('Enable Notifications');
- $this->setSupportedParameters(array('host', 'service', 'global'));
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->getRequest());
-
- $form->setSubmitLabel($this->translate('Enable Notifications'));
-
- if ($form->provideGlobalCommand() === true) {
- $form->addNote($this->translate('Enable notifications on a program-wide basis.'));
- } else {
- $form->addNote($this->translate('Notifications for this object will be enabled.'));
- }
-
- $form->setCommand('ENABLE_HOST_NOTIFICATIONS', 'ENABLE_SVC_NOTIFICATIONS');
- $form->setGlobalCommands('ENABLE_NOTIFICATIONS');
-
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, notifications will be enabled'));
- }
- }
-
- /**
- * Handle command sendcustomnotification
- */
- public function sendcustomnotificationAction()
- {
- $this->setSupportedParameters(array('host', 'service'));
- $form = new CustomNotificationForm();
- $form->setRequest($this->getRequest());
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Custom notification has been sent'));
- }
- }
-
- /**
- * Handle command scheduledowntime
- */
- public function scheduledowntimeAction()
- {
- $this->addTitleTab('Schedule Downtime');
- $this->setSupportedParameters(array('host', 'service'));
- $form = new ScheduleDowntimeForm();
- $form->setRequest($this->getRequest());
- $form->setConfiguration(Config::app());
- $form->setWithChildren(false);
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Downtime scheduling requested'));
- }
- }
-
- /**
- * Handle command scheduledowntimeswithchildren
- */
- public function scheduledowntimeswithchildrenAction()
- {
- $this->setSupportedParameters(array('host'));
- $form = new ScheduleDowntimeForm();
- $form->setRequest($this->getRequest());
- $form->setConfiguration(Config::app());
- $form->setWithChildren(true);
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Downtime scheduling requested'));
- }
- }
-
- /**
- * Handle command removedowntimeswithchildren
- */
- public function removedowntimeswithchildrenAction()
- {
- $this->setSupportedParameters(array('host'));
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->getRequest());
- $form->setSubmitLabel($this->translate('Remove Downtime(s)'));
- $form->addNote($this->translate('Remove downtime(s) from this host and its services.'));
- $form->setCommand('DEL_DOWNTIME_BY_HOST_NAME', 'DEL_DOWNTIME_BY_HOST_NAME');
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Downtime removal requested'));
- }
- }
-
- /**
- * Handle command disablenotificationswithchildren
- */
- public function disablenotificationswithchildrenAction()
- {
- $this->setSupportedParameters(array('host'));
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->getRequest());
- $form->setSubmitLabel($this->translate('Disable Notifications'));
- $form->addNote($this->translate('Notifications for this host and its services will be disabled.'));
- $form->setCommand('DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST');
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- $form->setCommand('DISABLE_HOST_NOTIFICATIONS', 'DISABLE_SVC_NOTIFICATIONS');
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, notifications will be disabled'));
- }
- }
-
- /**
- * Handle command enablenotificationswithchildren
- */
- public function enablenotificationswithchildrenAction()
- {
- $this->setSupportedParameters(array('host'));
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->getRequest());
- $form->setSubmitLabel($this->translate('Enable Notifications'));
- $form->addNote($this->translate('Notifications for this host and its services will be enabled.'));
- $form->setCommand('ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST');
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- $form->setCommand('ENABLE_HOST_NOTIFICATIONS', 'ENABLE_SVC_NOTIFICATIONS');
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, notifications will be enabled'));
- }
- }
-
- /**
- * Handle command reschedulenextcheckwithchildren
- */
- public function reschedulenextcheckwithchildrenAction()
- {
- $this->setSupportedParameters(array('host'));
- $form = new RescheduleNextCheckForm();
- $form->setRequest($this->getRequest());
- $form->setConfiguration(Config::app());
- $form->setWithChildren(true);
-
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, checks will be rescheduled'));
- }
- }
-
- /**
- * Handle command disableactivecheckswithchildren
- */
- public function disableactivecheckswithchildrenAction()
- {
- $this->setSupportedParameters(array('host'));
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->getRequest());
- $form->setSubmitLabel($this->translate('Disable Active Checks'));
- $form->addNote($this->translate('Disable active checks for this host and its services.'));
- $form->setCommand('DISABLE_HOST_CHECK');
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- // @TODO(mh): Missing child command
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, active checks will be disabled'));
- }
- }
-
- /**
- * Handle command enableactivecheckswithchildren
- */
- public function enableactivecheckswithchildrenAction()
- {
- $this->setSupportedParameters(array('host'));
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->getRequest());
- $form->setSubmitLabel($this->translate('Enable Active Checks'));
- $form->addNote($this->translate('Enable active checks for this host and its services.'));
- $form->setCommand('ENABLE_HOST_CHECK');
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- // @TODO(mh): Missing child command
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, active checks will be enabled'));
- }
- }
-
- /**
- * Handle command disableeventhandler
- */
- public function disableeventhandlerAction()
- {
- $this->setSupportedParameters(array('host', 'service', 'global'));
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->getRequest());
- $form->setSubmitLabel($this->translate('Disable Event Handler'));
-
- if ($form->provideGlobalCommand() === true) {
- $form->addNote($this->translate('Disable event handler for the whole system.'));
- } else {
- $form->addNote($this->translate('Disable event handler for this object.'));
- }
-
- $form->setCommand(
- 'DISABLE_HOST_EVENT_HANDLER',
- 'DISABLE_SVC_EVENT_HANDLER'
- );
-
- $form->setGlobalCommands('DISABLE_EVENT_HANDLERS');
-
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, event handlers will be disabled'));
- }
- }
-
- /**
- * Handle command enableeventhandler
- */
- public function enableeventhandlerAction()
- {
- $this->setSupportedParameters(array('host', 'service', 'global'));
-
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->getRequest());
- $form->setSubmitLabel($this->translate('Enable Event Handler'));
-
- if ($form->provideGlobalCommand() === true) {
- $form->addNote($this->translate('Enable event handlers on the whole system.'));
- } else {
- $form->addNote($this->translate('Enable event handler for this object.'));
- }
-
- $form->setCommand(
- 'ENABLE_HOST_EVENT_HANDLER',
- 'ENABLE_SVC_EVENT_HANDLER'
- );
-
- $form->setGlobalCommands('ENABLE_EVENT_HANDLERS');
-
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, event handlers will be enabled'));
- }
- }
-
- /**
- * Handle command disableflapdetection
- */
- public function disableflapdetectionAction()
- {
- $this->setSupportedParameters(array('host', 'service', 'global'));
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->getRequest());
- $form->setSubmitLabel($this->translate('Disable Flapping Detection'));
-
- if ($form->provideGlobalCommand() === true) {
- $form->addNote($this->translate('Disable flapping detection on a program-wide basis.'));
- } else {
- $form->addNote($this->translate('Disable flapping detection for this object.'));
- }
-
- $form->setCommand(
- 'DISABLE_HOST_FLAP_DETECTION',
- 'DISABLE_SVC_FLAP_DETECTION'
- );
-
- $form->setGlobalCommands(
- 'DISABLE_FLAP_DETECTION'
- );
-
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, flap detection will be disabled'));
- }
- }
-
- /**
- * Handle command enableflapdetection
- */
- public function enableflapdetectionAction()
- {
- $this->setSupportedParameters(array('host', 'service', 'global'));
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->getRequest());
- $form->setSubmitLabel($this->translate('Enable Flapping Detection'));
-
- if ($form->provideGlobalCommand() === true) {
- $form->addNote($this->translate('Enable flapping detection on a program-wide basis.'));
- } else {
- $form->addNote($this->translate('Enable flapping detection for this object.'));
- }
-
- $form->setCommand(
- 'ENABLE_HOST_FLAP_DETECTION',
- 'ENABLE_SVC_FLAP_DETECTION'
- );
-
- $form->setGlobalCommands(
- 'ENABLE_FLAP_DETECTION'
- );
-
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, flap detection will be enabled'));
- }
- }
-
- /**
- * Handle command addcomment
- */
- public function addcommentAction()
- {
- $this->addTitleTab('Add comment');
- $this->setSupportedParameters(array('host', 'service'));
- $form = new CommentForm();
- $form->setRequest($this->_request);
-
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Your new comment has been submitted'));
- }
- }
-
- /**
- * Remove a single comment
- */
- public function removecommentAction()
- {
- $this->addTitleTab('Remove Comment');
- $this->setSupportedParameters(array('commentid', 'host', 'service'));
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->_request);
- $form->setCommand('DEL_HOST_COMMENT', 'DEL_SVC_COMMENT');
- $form->setParameterName('commentid');
- $form->setSubmitLabel($this->translate('Remove comment'));
- $form->setObjectIgnoreFlag(true);
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Comment removal has been requested'));
- }
- }
-
- /**
- * Handle command resetattributes
- */
- public function resetattributesAction()
- {
- $this->setSupportedParameters(array('host', 'service'));
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->getRequest());
- $form->setSubmitLabel($this->translate('Reset Attributes'));
- $form->addNote($this->translate('Reset modified attributes to its default.'));
- $form->setCommand('CHANGE_HOST_MODATTR', 'CHANGE_SVC_MODATTR');
- $form->setParameterValue(0);
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- }
- }
-
- /**
- * Handle command acknowledgeproblem
- */
- public function acknowledgeproblemAction()
- {
- $this->addTitleTab('Acknowledge Problem');
- $this->setSupportedParameters(array('host', 'service'));
- $form = new AcknowledgeForm();
- $form->setRequest($this->getRequest());
- $form->setConfiguration(Config::app());
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Acknowledgement has been sent'));
- }
-
- $this->setForm($form);
- }
-
- /**
- * Handle command removeacknowledgement
- */
- public function removeacknowledgementAction()
- {
- $this->addTitleTab('Remove Acknowledgement');
- $this->setSupportedParameters(array('host', 'service'));
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->getRequest());
- $form->setSubmitLabel($this->translate('Remove Problem Acknowledgement'));
- $form->addNote($this->translate('Remove problem acknowledgement for this object.'));
- $form->setCommand('REMOVE_HOST_ACKNOWLEDGEMENT', 'REMOVE_SVC_ACKNOWLEDGEMENT');
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Acknowledgement removal has been requested'));
- }
- }
-
- /**
- * Handle command delaynotification
- */
- public function delaynotificationAction()
- {
- $this->setSupportedParameters(array('host', 'service'));
- $form = new DelayNotificationForm();
- $form->setRequest($this->getRequest());
-
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Notification delay has been requested'));
- }
- }
-
- /**
- * Handle command removedowntime
- */
- public function removedowntimeAction()
- {
- $this->setSupportedParameters(array('host', 'service', 'downtimeid'));
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->getRequest());
-
- $form->setSubmitLabel($this->translate('Delete Downtime'));
- $form->setParameterName('downtimeid');
- $form->addNote($this->translate('Delete a single downtime with the id shown above'));
- $form->setCommand('DEL_HOST_DOWNTIME', 'DEL_SVC_DOWNTIME');
- $form->setObjectIgnoreFlag(true);
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Downtime removal has been requested'));
- }
- }
-
- /**
- * Shutdown the icinga process
- */
- public function shutdownprocessAction()
- {
- $this->setParam('global', '1');
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->_request);
-
- $form->setSubmitLabel($this->translate('Shutdown monitoring process'));
- $form->addNote($this->translate('Stop monitoring instance. You have to start it again from command line.'));
- $form->setGlobalCommands('SHUTDOWN_PROCESS');
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, process will shut down'));
- }
- }
-
- /**
- * Restart the icinga process
- */
- public function restartprocessAction()
- {
- $this->setParam('global', '1');
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->_request);
-
- $form->setSubmitLabel($this->translate('Restart monitoring process'));
- $form->addNote($this->translate('Restart the monitoring process.'));
- $form->setGlobalCommands('RESTART_PROCESS');
-
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, monitoring process will restart now'));
- }
- }
-
- /**
- * Disable processing of performance data
- */
- public function disableperformancedataAction()
- {
- $this->setParam('global', 1);
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->_request);
-
- $form->setSubmitLabel($this->translate('Disable Performance Data'));
- $form->addNote($this->translate('Disable processing of performance data on a program-wide basis.'));
-
- $form->setGlobalCommands('DISABLE_PERFORMANCE_DATA');
-
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, performance data processing will be disabled'));
- }
- }
-
- /**
- * Enable processing of performance data
- */
- public function enableperformancedataAction()
- {
- $this->setParam('global', 1);
- $form = new SingleArgumentCommandForm();
- $form->setRequest($this->_request);
-
- $form->setSubmitLabel($this->translate('Enable Performance Data'));
- $form->addNote($this->translate('Enable processing of performance data on a program-wide basis.'));
-
- $form->setGlobalCommands('ENABLE_PERFORMANCE_DATA');
-
- $this->setForm($form);
-
- if ($form->IsSubmittedAndValid() === true) {
- $this->target->sendCommand($form->createCommand(), $this->view->objects);
- Notification::success($this->translate('Command has been sent, performance data processing will be enabled'));
- }
- }
-}
diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php
index ab62c3756..4eccb8899 100644
--- a/modules/monitoring/application/controllers/HostController.php
+++ b/modules/monitoring/application/controllers/HostController.php
@@ -26,20 +26,15 @@ class Monitoring_HostController extends MonitoredObjectController
public function init()
{
$host = new Host($this->backend, $this->params->get('host'));
+
+ $this->applyRestriction('monitoring/hosts/filter', $host);
+
if ($host->fetch() === false) {
throw new Zend_Controller_Action_Exception($this->translate('Host not found'));
}
$this->object = $host;
$this->createTabs();
- }
-
- /**
- * Show a host
- */
- public function showAction()
- {
$this->getTabs()->activate('host');
- parent::showAction();
}
/**
@@ -47,6 +42,8 @@ class Monitoring_HostController extends MonitoredObjectController
*/
public function acknowledgeProblemAction()
{
+ $this->assertPermission('monitoring/command/acknowledge-problem');
+
$this->view->title = $this->translate('Acknowledge Host Problem');
$this->handleCommandForm(new AcknowledgeProblemCommandForm());
}
@@ -56,6 +53,8 @@ class Monitoring_HostController extends MonitoredObjectController
*/
public function addCommentAction()
{
+ $this->assertPermission('monitoring/command/comment/add');
+
$this->view->title = $this->translate('Add Host Comment');
$this->handleCommandForm(new AddCommentCommandForm());
}
@@ -65,6 +64,8 @@ class Monitoring_HostController extends MonitoredObjectController
*/
public function rescheduleCheckAction()
{
+ $this->assertPermission('monitoring/command/schedule-check');
+
$this->view->title = $this->translate('Reschedule Host Check');
$this->handleCommandForm(new ScheduleHostCheckCommandForm());
}
@@ -74,6 +75,8 @@ class Monitoring_HostController extends MonitoredObjectController
*/
public function scheduleDowntimeAction()
{
+ $this->assertPermission('monitoring/command/downtime/schedule');
+
$this->view->title = $this->translate('Schedule Host Downtime');
$this->handleCommandForm(new ScheduleHostDowntimeCommandForm());
}
@@ -83,6 +86,8 @@ class Monitoring_HostController extends MonitoredObjectController
*/
public function processCheckResultAction()
{
+ $this->assertPermission('monitoring/command/process-check-result');
+
$this->view->title = $this->translate('Submit Passive Host Check Result');
$this->handleCommandForm(new ProcessCheckResultCommandForm());
}
diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php
index 4944cc237..869be92d8 100644
--- a/modules/monitoring/application/controllers/HostsController.php
+++ b/modules/monitoring/application/controllers/HostsController.php
@@ -72,8 +72,10 @@ class Monitoring_HostsController extends Controller
'host_obsessing'*/
));
$unhandledObjects = array();
+ $unhandledFilterExpressions = array();
$acknowledgedObjects = array();
$objectsInDowntime = array();
+ $downtimeFilterExpressions = array();
$hostStates = array(
Host::getStateText(Host::STATE_UP) => 0,
Host::getStateText(Host::STATE_DOWN) => 0,
@@ -81,15 +83,17 @@ class Monitoring_HostsController extends Controller
Host::getStateText(Host::STATE_PENDING) => 0,
);
foreach ($this->hostList as $host) {
- /** @var Service $host */
+ /** @var Host $host */
if ((bool) $host->problem === true && (bool) $host->handled === false) {
$unhandledObjects[] = $host;
+ $unhandledFilterExpressions[] = Filter::where('host', $host->getName());
}
if ((bool) $host->acknowledged === true) {
$acknowledgedObjects[] = $host;
}
if ((bool) $host->in_downtime === true) {
$objectsInDowntime[] = $host;
+ $downtimeFilterExpressions[] = Filter::where('downtime_host', $host->getName());
}
++$hostStates[$host::getStateText($host->state)];
}
@@ -108,16 +112,15 @@ class Monitoring_HostsController extends Controller
$this->view->hostStates = $hostStates;
$this->view->objects = $this->hostList;
$this->view->unhandledObjects = $unhandledObjects;
- $this->view->acknowledgeUnhandledLink = Url::fromRequest()
- ->setPath('monitoring/hosts/acknowledge-problem')
- ->addParams(array('host_problem' => 1, 'host_handled' => 0));
- $this->view->downtimeUnhandledLink = Url::fromRequest()
- ->setPath('monitoring/hosts/schedule-downtime')
- ->addParams(array('host_problem' => 1, 'host_handled' => 0));
+ $unhandledFilterQueryString = Filter::matchAny($unhandledFilterExpressions)->toQueryString();
+ $this->view->acknowledgeUnhandledLink = Url::fromPath('monitoring/hosts/acknowledge-problem')
+ ->setQueryString($unhandledFilterQueryString);
+ $this->view->downtimeUnhandledLink = Url::fromPath('monitoring/hosts/schedule-downtime')
+ ->setQueryString($unhandledFilterQueryString);
$this->view->acknowledgedObjects = $acknowledgedObjects;
$this->view->objectsInDowntime = $objectsInDowntime;
- $this->view->inDowntimeLink = Url::fromRequest()
- ->setPath('monitoring/list/downtimes');
+ $this->view->inDowntimeLink = Url::fromPath('monitoring/list/downtimes')
+ ->setQueryString(Filter::matchAny($downtimeFilterExpressions)->toQueryString());
$this->view->havingCommentsLink = Url::fromRequest()
->setPath('monitoring/list/comments');
$this->view->hostStatesPieChart = $this->createPieChart(
@@ -131,10 +134,9 @@ class Monitoring_HostsController extends Controller
{
$chart = new InlinePie(array_values($states), $title, $colors);
return $chart
- ->setLabel(array_map('strtoupper', array_keys($states)))
- ->setHeight(100)
- ->setWidth(100)
- ->setTitle($title);
+ ->setSize(75)
+ ->setTitle('')
+ ->setSparklineClass('sparkline-multi');
}
/**
diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php
index 4f92a25b1..faaea713a 100644
--- a/modules/monitoring/application/controllers/ListController.php
+++ b/modules/monitoring/application/controllers/ListController.php
@@ -1,6 +1,4 @@
params->shift('stateType', 'soft');
- if ($stateType == 'hard') {
+ if (strtolower($this->params->shift('stateType', 'soft')) === 'hard') {
$stateColumn = 'host_hard_state';
$stateChangeColumn = 'host_last_hard_state_change';
} else {
- $stateType = 'soft';
$stateColumn = 'host_state';
$stateChangeColumn = 'host_last_state_change';
}
@@ -112,6 +104,7 @@ class Monitoring_ListController extends Controller
$query = $this->backend->select()->from('hostStatus', array_merge(array(
'host_icon_image',
'host_name',
+ 'host_display_name',
'host_state' => $stateColumn,
'host_address',
'host_acknowledged',
@@ -138,13 +131,14 @@ class Monitoring_ListController extends Controller
$this->filterQuery($query);
+ $this->applyRestriction('monitoring/hosts/filter', $query);
+
$this->setupSortControl(array(
- 'host_last_check' => $this->translate('Last Check'),
'host_severity' => $this->translate('Severity'),
- 'host_name' => $this->translate('Hostname'),
- 'host_address' => $this->translate('Address'),
'host_state' => $this->translate('Current State'),
- 'host_state' => $this->translate('Hard State')
+ 'host_display_name' => $this->translate('Hostname'),
+ 'host_address' => $this->translate('Address'),
+ 'host_last_check' => $this->translate('Last Check')
));
$this->view->hosts = $query->paginate();
@@ -171,14 +165,12 @@ class Monitoring_ListController extends Controller
}
// Handle soft and hard states
- $stateType = $this->params->shift('stateType', 'soft');
- if ($stateType == 'hard') {
+ if (strtolower($this->params->shift('stateType', 'soft')) === 'hard') {
$stateColumn = 'service_hard_state';
$stateChangeColumn = 'service_last_hard_state_change';
} else {
$stateColumn = 'service_state';
$stateChangeColumn = 'service_last_state_change';
- $stateType = 'soft';
}
$this->addTitleTab('services', $this->translate('Services'));
@@ -192,6 +184,7 @@ class Monitoring_ListController extends Controller
$columns = array_merge(array(
'host_name',
+ 'host_display_name',
'host_state',
'host_state_type',
'host_last_state_change',
@@ -227,15 +220,17 @@ class Monitoring_ListController extends Controller
$query = $this->backend->select()->from('serviceStatus', $columns);
$this->filterQuery($query);
+
+ $this->applyRestriction('monitoring/services/filter', $query);
+
$this->setupSortControl(array(
- 'service_last_check' => $this->translate('Last Service Check'),
- 'service_severity' => $this->translate('Severity'),
+ 'service_severity' => $this->translate('Service Severity'),
'service_state' => $this->translate('Current Service State'),
- 'service_description' => $this->translate('Service Name'),
- 'service_state_type' => $this->translate('Hard State'),
+ 'service_display_name' => $this->translate('Service Name'),
+ 'service_last_check' => $this->translate('Last Service Check'),
'host_severity' => $this->translate('Host Severity'),
'host_state' => $this->translate('Current Host State'),
- 'host_name' => $this->translate('Host Name'),
+ 'host_display_name' => $this->translate('Hostname'),
'host_address' => $this->translate('Host Address'),
'host_last_check' => $this->translate('Last Host Check')
));
@@ -295,26 +290,31 @@ class Monitoring_ListController extends Controller
'host' => 'downtime_host',
'service' => 'downtime_service',
'host_state' => 'downtime_host_state',
- 'service_state' => 'downtime_service_state'
- ))->order('downtime_is_in_effect', 'DESC')
- ->order('downtime_scheduled_start', 'DESC');
+ 'service_state' => 'downtime_service_state',
+ 'host_display_name',
+ 'service_display_name'
+ ));
$this->filterQuery($query);
$this->setupSortControl(array(
- 'downtime_is_in_effect' => $this->translate('Is In Effect'),
- 'downtime_host' => $this->translate('Host / Service'),
- 'downtime_entry_time' => $this->translate('Entry Time'),
- 'downtime_author' => $this->translate('Author'),
- 'downtime_start' => $this->translate('Start Time'),
- 'downtime_start' => $this->translate('End Time'),
- 'downtime_scheduled_start' => $this->translate('Scheduled Start'),
- 'downtime_scheduled_end' => $this->translate('Scheduled End'),
- 'downtime_duration' => $this->translate('Duration'),
+ 'downtime_is_in_effect' => $this->translate('Is In Effect'),
+ 'host_display_name' => $this->translate('Host'),
+ 'service_display_name' => $this->translate('Service'),
+ 'downtime_entry_time' => $this->translate('Entry Time'),
+ 'downtime_author' => $this->translate('Author'),
+ 'downtime_start' => $this->translate('Start Time'),
+ 'downtime_end' => $this->translate('End Time'),
+ 'downtime_scheduled_start' => $this->translate('Scheduled Start'),
+ 'downtime_scheduled_end' => $this->translate('Scheduled End'),
+ 'downtime_duration' => $this->translate('Duration')
));
$this->view->downtimes = $query->paginate();
- $this->view->delDowntimeForm = new DeleteDowntimeCommandForm();
+
+ if ($this->Auth()->hasPermission('monitoring/command/downtime/delete')) {
+ $this->view->delDowntimeForm = new DeleteDowntimeCommandForm();
+ }
}
/**
@@ -333,7 +333,9 @@ class Monitoring_ListController extends Controller
'notification_output',
'notification_contact',
'notification_start_time',
- 'notification_state'
+ 'notification_state',
+ 'host_display_name',
+ 'service_display_name'
));
$this->filterQuery($query);
$this->view->notifications = $query->paginate();
@@ -471,20 +473,26 @@ class Monitoring_ListController extends Controller
'persistent' => 'comment_is_persistent',
'expiration' => 'comment_expiration',
'host' => 'comment_host',
- 'service' => 'comment_service'
+ 'service' => 'comment_service',
+ 'host_display_name',
+ 'service_display_name'
));
$this->filterQuery($query);
$this->view->comments = $query->paginate();
$this->setupSortControl(
array(
- 'comment_timestamp' => $this->translate('Comment Timestamp'),
- 'comment_host' => $this->translate('Host / Service'),
- 'comment_type' => $this->translate('Comment Type'),
- 'comment_expiration' => $this->translate('Expiration'),
+ 'comment_timestamp' => $this->translate('Comment Timestamp'),
+ 'host_display_name' => $this->translate('Host'),
+ 'service_display_name' => $this->translate('Service'),
+ 'comment_type' => $this->translate('Comment Type'),
+ 'comment_expiration' => $this->translate('Expiration')
)
);
- $this->view->delCommentForm = new DeleteCommentCommandForm();
+
+ if ($this->Auth()->hasPermission('monitoring/command/comment/delete')) {
+ $this->view->delCommentForm = new DeleteCommentCommandForm();
+ }
}
public function servicegroupsAction()
@@ -496,6 +504,7 @@ class Monitoring_ListController extends Controller
$this->setAutorefreshInterval(12);
$query = $this->backend->select()->from('groupsummary', array(
'servicegroup',
+ 'servicegroup_alias',
'hosts_up',
'hosts_unreachable_handled',
'hosts_unreachable_unhandled',
@@ -519,18 +528,20 @@ class Monitoring_ListController extends Controller
'services_critical_last_state_change_unhandled',
'services_unknown_last_state_change_unhandled',
'services_total'
- ));
+ ))->order('services_severity')->order('servicegroup_alias');
+ // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and
+ // service groups. We should separate them.
$this->filterQuery($query);
$this->view->servicegroups = $query->paginate();
$this->setupSortControl(array(
- 'services_severity' => $this->translate('Severity'),
- 'servicegroup' => $this->translate('Service Group Name'),
- 'services_total' => $this->translate('Total Services'),
- 'services_ok' => $this->translate('Services OK'),
- 'services_unknown' => $this->translate('Services UNKNOWN'),
- 'services_critical' => $this->translate('Services CRITICAL'),
- 'services_warning' => $this->translate('Services WARNING'),
- 'services_pending' => $this->translate('Services PENDING')
+ 'services_severity' => $this->translate('Severity'),
+ 'servicegroup_alias' => $this->translate('Service Group Name'),
+ 'services_total' => $this->translate('Total Services'),
+ 'services_ok' => $this->translate('Services OK'),
+ 'services_unknown' => $this->translate('Services UNKNOWN'),
+ 'services_critical' => $this->translate('Services CRITICAL'),
+ 'services_warning' => $this->translate('Services WARNING'),
+ 'services_pending' => $this->translate('Services PENDING')
));
}
@@ -543,6 +554,7 @@ class Monitoring_ListController extends Controller
$this->setAutorefreshInterval(12);
$query = $this->backend->select()->from('groupsummary', array(
'hostgroup',
+ 'hostgroup_alias',
'hosts_up',
'hosts_unreachable_handled',
'hosts_unreachable_unhandled',
@@ -566,12 +578,14 @@ class Monitoring_ListController extends Controller
'services_critical_last_state_change_unhandled',
'services_unknown_last_state_change_unhandled',
'services_total'
- ));
+ ))->order('services_severity')->order('hostgroup_alias');
+ // TODO(el): Can't default to the sort rules of the data view because it's meant for both host groups and
+ // service groups. We should separate them.
$this->filterQuery($query);
$this->view->hostgroups = $query->paginate();
$this->setupSortControl(array(
'services_severity' => $this->translate('Severity'),
- 'hostgroup' => $this->translate('Host Group Name'),
+ 'hostgroup_alias' => $this->translate('Host Group Name'),
'services_total' => $this->translate('Total Services'),
'services_ok' => $this->translate('Services OK'),
'services_unknown' => $this->translate('Services UNKNOWN'),
@@ -590,7 +604,9 @@ class Monitoring_ListController extends Controller
$query = $this->backend->select()->from('eventHistory', array(
'host_name',
+ 'host_display_name',
'service_description',
+ 'service_display_name',
'object_type',
'timestamp',
'state',
@@ -605,7 +621,7 @@ class Monitoring_ListController extends Controller
$this->filterQuery($query);
$this->setupSortControl(array(
- 'timestamp' => 'Occurence'
+ 'timestamp' => $this->translate('Occurence')
));
$this->view->history = $query->paginate();
}
@@ -650,22 +666,10 @@ class Monitoring_ListController extends Controller
if ($sort = $this->params->get('sort')) {
$query->order($sort, $this->params->get('dir'));
}
- $this->applyRestrictions($query);
$this->handleFormatRequest($query);
return $query;
}
- /**
- * Apply current user's `monitoring/filter' restrictions on the given data view
- */
- protected function applyRestrictions($query)
- {
- foreach ($this->getRestrictions('monitoring/filter') as $restriction) {
- // TODO: $query->applyFilter(Filter::fromQueryString());
- }
- return $query;
- }
-
protected function extraColumns()
{
$columns = preg_split(
diff --git a/modules/monitoring/application/controllers/MultiController.php b/modules/monitoring/application/controllers/MultiController.php
deleted file mode 100644
index 52d927ffb..000000000
--- a/modules/monitoring/application/controllers/MultiController.php
+++ /dev/null
@@ -1,282 +0,0 @@
-backend->select()->from(
- 'hostStatus',
- array(
- 'host_name',
- 'host_in_downtime',
- 'host_passive_checks_enabled',
- 'host_obsessing',
- 'host_state',
- 'host_notifications_enabled',
- 'host_event_handler_enabled',
- 'host_flap_detection_enabled',
- 'host_active_checks_enabled',
- // columns intended for filter-request
- 'host_problem',
- 'host_handled'
- )
- )->getQuery();
- $this->applyQueryFilter($query);
- $hosts = $query->fetchAll();
-
- $comments = $this->backend->select()->from('comment', array(
- 'comment_internal_id',
- 'comment_host',
- ));
- $this->applyQueryFilter($comments);
- $uniqueComments = array_keys($this->getUniqueValues($comments->getQuery()->fetchAll(), 'comment_internal_id'));
-
- // Populate view
- $this->view->objects = $this->view->hosts = $hosts;
- $this->view->problems = $this->getProblems($hosts);
- $this->view->comments = $uniqueComments;
- $this->view->hostnames = $this->getProperties($hosts, 'host_name');
- $this->view->downtimes = $this->getDowntimes($hosts);
- $this->view->errors = $errors;
- $this->view->states = $this->countStates($hosts, 'host', 'host_name');
- $this->view->pie = $this->createPie(
- $this->view->states,
- $this->view->getHelper('MonitoringState')->getHostStateColors(),
- mt('monitoring', 'Host State')
- );
-
- // Handle configuration changes
- $this->handleConfigurationForm(array(
- 'host_passive_checks_enabled' => $this->translate('Passive Checks'),
- 'host_active_checks_enabled' => $this->translate('Active Checks'),
- 'host_notifications_enabled' => $this->translate('Notifications'),
- 'host_event_handler_enabled' => $this->translate('Event Handler'),
- 'host_flap_detection_enabled' => $this->translate('Flap Detection'),
- 'host_obsessing' => $this->translate('Obsessing')
- ));
- }
-
- public function serviceAction()
- {
- $errors = array();
- $query = $this->backend->select()->from('serviceStatus', array(
- 'host_name',
- 'host_state',
- 'service_description',
- 'service_handled',
- 'service_state',
- 'service_in_downtime',
- 'service_passive_checks_enabled',
- 'service_notifications_enabled',
- 'service_event_handler_enabled',
- 'service_flap_detection_enabled',
- 'service_active_checks_enabled',
- 'service_obsessing',
- // also accept all filter-requests from ListView
- 'service_problem',
- 'service_severity',
- 'service_last_check',
- 'service_state_type',
- 'host_severity',
- 'host_address',
- 'host_last_check'
- ));
-
- $this->applyQueryFilter($query);
- $services = $query->getQuery()->fetchAll();
-
- $comments = $this->backend->select()->from('comment', array(
- 'comment_internal_id',
- 'comment_host',
- 'comment_service'
- ));
- $this->applyQueryFilter($comments);
- $uniqueComments = array_keys($this->getUniqueValues($comments->getQuery()->fetchAll(), 'comment_internal_id'));
-
- // populate the view
- $this->view->objects = $this->view->services = $services;
- $this->view->problems = $this->getProblems($services);
- $this->view->comments = $uniqueComments;
- $this->view->hostnames = $this->getProperties($services, 'host_name');
- $this->view->servicenames = $this->getProperties($services, 'service_description');
- $this->view->downtimes = $this->getDowntimes($services);
- $this->view->service_states = $this->countStates($services, 'service');
- $this->view->host_states = $this->countStates($services, 'host', 'host_name');
- $this->view->service_pie = $this->createPie(
- $this->view->service_states,
- $this->view->getHelper('MonitoringState')->getServiceStateColors(),
- mt('monitoring', 'Service State')
- );
- $this->view->host_pie = $this->createPie(
- $this->view->host_states,
- $this->view->getHelper('MonitoringState')->getHostStateColors(),
- mt('monitoring', 'Host State')
- );
- $this->view->errors = $errors;
-
- $this->handleConfigurationForm(array(
- 'service_passive_checks_enabled' => $this->translate('Passive Checks'),
- 'service_active_checks_enabled' => $this->translate('Active Checks'),
- 'service_notifications_enabled' => $this->translate('Notifications'),
- 'service_event_handler_enabled' => $this->translate('Event Handler'),
- 'service_flap_detection_enabled' => $this->translate('Flap Detection'),
- 'service_obsessing' => $this->translate('Obsessing'),
- ));
- }
-
- protected function applyQueryFilter($query)
- {
- $params = clone $this->params;
- $modifyFilter = $params->shift('modifyFilter');
-
- $filter = Filter::fromQueryString((string) $params);
- if ($modifyFilter) {
- $this->view->filterWidget = Widget::create('filterEditor', array(
- 'filter' => $filter,
- 'query' => $query
- ));
- }
- $this->view->filter = $filter;
- $query->applyFilter($filter);
- return $query;
- }
-
- /**
- * Create an array with all unique values as keys.
- *
- * @param array $values The array containing the objects
- * @param $key The key to access
- *
- * @return array
- */
- private function getUniqueValues($values, $key)
- {
- $unique = array();
- foreach ($values as $value) {
- if (is_array($value)) {
- $unique[$value[$key]] = $value[$key];
- } else {
- $unique[$value->$key] = $value->$key;
- }
- }
- return $unique;
- }
-
- /**
- * Get the numbers of problems of the given objects
- *
- * @param $objects The objects containing the problems
- *
- * @return int The problem count
- */
- private function getProblems($objects)
- {
- $problems = 0;
- foreach ($objects as $object) {
- if (property_exists($object, 'host_unhandled_service_count')) {
- $problems += $object->host_unhandled_service_count;
- } else if (
- property_exists($object, 'service_handled') &&
- !$object->service_handled &&
- $object->service_state > 0
- ) {
- $problems++;
- }
- }
- return $problems;
- }
-
- private function countStates($objects, $type = 'host', $unique = null)
- {
- $known = array();
- if ($type === 'host') {
- $states = array_fill_keys($this->view->getHelper('MonitoringState')->getHostStateNames(), 0);
- } else {
- $states = array_fill_keys($this->view->getHelper('MonitoringState')->getServiceStateNames(), 0);
- }
- foreach ($objects as $object) {
- if (isset($unique)) {
- if (array_key_exists($object->$unique, $known)) {
- continue;
- }
- $known[$object->$unique] = true;
- }
- $states[$this->view->monitoringState($object, $type)]++;
- }
- return $states;
- }
-
- private function createPie($states, $colors, $title)
- {
- $chart = new InlinePie(array_values($states), $title, $colors);
- $chart->setLabel(array_keys($states))->setHeight(100)->setWidth(100);
- $chart->setTitle($title);
- return $chart;
- }
-
-
- private function getComments($objects)
- {
- $unique = array();
- foreach ($objects as $object) {
- $unique = array_merge($unique, $this->getUniqueValues($object->comments, 'comment_internal_id'));
- }
- return array_keys($unique);
- }
-
- private function getProperties($objects, $property)
- {
- $objectnames = array();
- foreach ($objects as $object) {
- $objectnames[] = $object->$property;
- }
- return $objectnames;
- }
-
- private function getDowntimes($objects)
- {
- $downtimes = array();
- foreach ($objects as $object)
- {
- if (
- (property_exists($object, 'host_in_downtime') && $object->host_in_downtime) ||
- (property_exists($object, 'service_in_downtime') && $object->service_in_downtime)
- ) {
- $downtimes[] = true;
- }
- }
- return $downtimes;
- }
-
-
- /**
- * Handle the form to edit configuration flags.
- *
- * @param $flags array The used flags.
- */
- private function handleConfigurationForm(array $flags)
- {
- $this->view->form = $form = new MultiCommandFlagForm($flags);
- $this->view->formElements = $form->buildCheckboxes();
- $form->setRequest($this->_request);
- if ($form->isSubmittedAndValid()) {
- // TODO: Handle commands
- $changed = $form->getChangedValues();
- }
- if ($this->_request->isPost() === false) {
- $this->view->form->initFromItems($this->view->objects);
- }
- }
-}
diff --git a/modules/monitoring/application/controllers/ProcessController.php b/modules/monitoring/application/controllers/ProcessController.php
index 62334d7e8..bb5a4e5c2 100644
--- a/modules/monitoring/application/controllers/ProcessController.php
+++ b/modules/monitoring/application/controllers/ProcessController.php
@@ -64,8 +64,9 @@ class Monitoring_ProcessController extends Controller
'process_performance_data'
)
)
- ->getQuery()
- ->fetchRow();
+ ->getQuery();
+ $this->handleFormatRequest($programStatus);
+ $programStatus = $programStatus->fetchRow();
if ($programStatus === false) {
return $this->render('not-running', true, null);
}
diff --git a/modules/monitoring/application/controllers/ServiceController.php b/modules/monitoring/application/controllers/ServiceController.php
index 06417cc6e..4e4e67402 100644
--- a/modules/monitoring/application/controllers/ServiceController.php
+++ b/modules/monitoring/application/controllers/ServiceController.php
@@ -26,20 +26,15 @@ class Monitoring_ServiceController extends MonitoredObjectController
public function init()
{
$service = new Service($this->backend, $this->params->get('host'), $this->params->get('service'));
+
+ $this->applyRestriction('monitoring/services/filter', $service);
+
if ($service->fetch() === false) {
throw new Zend_Controller_Action_Exception($this->translate('Service not found'));
}
$this->object = $service;
$this->createTabs();
- }
-
- /**
- * Show a service
- */
- public function showAction()
- {
$this->getTabs()->activate('service');
- parent::showAction();
}
/**
@@ -47,6 +42,8 @@ class Monitoring_ServiceController extends MonitoredObjectController
*/
public function acknowledgeProblemAction()
{
+ $this->assertPermission('monitoring/command/acknowledge-problem');
+
$this->view->title = $this->translate('Acknowledge Service Problem');
$this->handleCommandForm(new AcknowledgeProblemCommandForm());
}
@@ -56,6 +53,8 @@ class Monitoring_ServiceController extends MonitoredObjectController
*/
public function addCommentAction()
{
+ $this->assertPermission('monitoring/command/comment/add');
+
$this->view->title = $this->translate('Add Service Comment');
$this->handleCommandForm(new AddCommentCommandForm());
}
@@ -65,6 +64,8 @@ class Monitoring_ServiceController extends MonitoredObjectController
*/
public function rescheduleCheckAction()
{
+ $this->assertPermission('monitoring/command/schedule-check');
+
$this->view->title = $this->translate('Reschedule Service Check');
$this->handleCommandForm(new ScheduleServiceCheckCommandForm());
}
@@ -74,6 +75,8 @@ class Monitoring_ServiceController extends MonitoredObjectController
*/
public function scheduleDowntimeAction()
{
+ $this->assertPermission('monitoring/command/downtime/schedule');
+
$this->view->title = $this->translate('Schedule Service Downtime');
$this->handleCommandForm(new ScheduleServiceDowntimeCommandForm());
}
@@ -83,6 +86,8 @@ class Monitoring_ServiceController extends MonitoredObjectController
*/
public function processCheckResultAction()
{
+ $this->assertPermission('monitoring/command/process-check-result');
+
$this->view->title = $this->translate('Submit Passive Service Check Result');
$this->handleCommandForm(new ProcessCheckResultCommandForm());
}
diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php
index cdf86f460..dc7feb2da 100644
--- a/modules/monitoring/application/controllers/ServicesController.php
+++ b/modules/monitoring/application/controllers/ServicesController.php
@@ -74,8 +74,10 @@ class Monitoring_ServicesController extends Controller
'service_obsessing'*/
));
$unhandledObjects = array();
+ $unhandledFilterExpressions = array();
$acknowledgedObjects = array();
$objectsInDowntime = array();
+ $downtimeFilterExpressions = array();
$serviceStates = array(
Service::getStateText(Service::STATE_OK) => 0,
Service::getStateText(Service::STATE_WARNING) => 0,
@@ -94,12 +96,20 @@ class Monitoring_ServicesController extends Controller
/** @var Service $service */
if ((bool) $service->problem === true && (bool) $service->handled === false) {
$unhandledObjects[] = $service;
+ $unhandledFilterExpressions[] = Filter::matchAll(
+ Filter::where('host', $service->getHost()->getName()),
+ Filter::where('service', $service->getName())
+ );
}
if ((bool) $service->acknowledged === true) {
$acknowledgedObjects[] = $service;
}
if ((bool) $service->in_downtime === true) {
$objectsInDowntime[] = $service;
+ $downtimeFilterExpressions[] = Filter::matchAll(
+ Filter::where('downtime_host', $service->getHost()->getName()),
+ Filter::where('downtime_service', $service->getName())
+ );
}
++$serviceStates[$service::getStateText($service->state)];
if (! isset($knownHostStates[$service->getHost()->getName()])) {
@@ -125,16 +135,15 @@ class Monitoring_ServicesController extends Controller
$this->view->serviceStates = $serviceStates;
$this->view->objects = $this->serviceList;
$this->view->unhandledObjects = $unhandledObjects;
- $this->view->acknowledgeUnhandledLink = Url::fromRequest()
- ->setPath('monitoring/services/acknowledge-problem')
- ->addParams(array('service_problem' => 1, 'service_handled' => 0));
- $this->view->downtimeUnhandledLink = Url::fromRequest()
- ->setPath('monitoring/services/schedule-downtime')
- ->addParams(array('service_problem' => 1, 'service_handled' => 0));
+ $unhandledFilterQueryString = Filter::matchAny($unhandledFilterExpressions)->toQueryString();
+ $this->view->acknowledgeUnhandledLink = Url::fromPath('monitoring/services/acknowledge-problem')
+ ->setQueryString($unhandledFilterQueryString);
+ $this->view->downtimeUnhandledLink = Url::fromPath('monitoring/services/schedule-downtime')
+ ->setQueryString($unhandledFilterQueryString);
$this->view->acknowledgedObjects = $acknowledgedObjects;
$this->view->objectsInDowntime = $objectsInDowntime;
- $this->view->inDowntimeLink = Url::fromRequest()
- ->setPath('monitoring/list/downtimes');
+ $this->view->inDowntimeLink = Url::fromPath('monitoring/list/downtimes')
+ ->setQueryString(Filter::matchAny($downtimeFilterExpressions)->toQueryString());
$this->view->havingCommentsLink = Url::fromRequest()
->setPath('monitoring/list/comments');
$this->view->serviceStatesPieChart = $this->createPieChart(
@@ -153,10 +162,9 @@ class Monitoring_ServicesController extends Controller
{
$chart = new InlinePie(array_values($states), $title, $colors);
return $chart
- ->setLabel(array_map('strtoupper', array_keys($states)))
- ->setHeight(100)
- ->setWidth(100)
- ->setTitle($title);
+ ->setSize(75)
+ ->setTitle('')
+ ->setSparklineClass('sparkline-multi');
}
/**
diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php
index efec6665a..0b7a2f897 100644
--- a/modules/monitoring/application/controllers/ShowController.php
+++ b/modules/monitoring/application/controllers/ShowController.php
@@ -73,9 +73,8 @@ class Monitoring_ShowController extends Controller
public function historyAction()
{
$this->getTabs()->activate('history');
- //$this->view->object->populate();
$this->view->object->fetchEventHistory();
- $this->view->history = $this->view->object->eventhistory->paginate($this->params->get('limit', 50));
+ $this->view->history = $this->view->object->eventhistory->getQuery()->paginate($this->params->get('limit', 50));
$this->handleFormatRequest($this->view->object->eventhistory);
$this->fetchHostStats();
}
@@ -166,8 +165,10 @@ class Monitoring_ShowController extends Controller
'notification_output',
'notification_contact',
'notification_start_time',
- 'notification_state'
- ))->order('notification_start_time');
+ 'notification_state',
+ 'host_display_name',
+ 'service_display_name'
+ ));
$notifications->where('contact_object_id', $contact->contact_object_id);
diff --git a/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php b/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php
index 0e64a4b03..21d926b58 100644
--- a/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php
+++ b/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php
@@ -21,7 +21,7 @@ class DisableNotificationsExpireCommandForm extends CommandForm
*/
public function init()
{
- $this->setSubmitLabel(mt('monitoring', 'Disable Notifications'));
+ $this->setSubmitLabel($this->translate('Disable Notifications'));
}
/**
@@ -30,8 +30,7 @@ class DisableNotificationsExpireCommandForm extends CommandForm
*/
public function getHelp()
{
- return mt(
- 'monitoring',
+ return $this->translate(
'This command is used to disable host and service notifications for a specific time.'
);
}
@@ -49,8 +48,8 @@ class DisableNotificationsExpireCommandForm extends CommandForm
'expire_time',
array(
'required' => true,
- 'label' => mt('monitoring', 'Expire Time'),
- 'description' => mt('monitoring', 'Set the expire time.'),
+ 'label' => $this->translate('Expire Time'),
+ 'description' => $this->translate('Set the expire time.'),
'value' => $expireTime
)
);
@@ -67,7 +66,7 @@ class DisableNotificationsExpireCommandForm extends CommandForm
$disableNotifications
->setExpireTime($this->getElement('expire_time')->getValue()->getTimestamp());
$this->getTransport($this->request)->send($disableNotifications);
- Notification::success(mt('monitoring', 'Disabling host and service notifications..'));
+ Notification::success($this->translate('Disabling host and service notifications..'));
return true;
}
}
diff --git a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php
index 291619b2f..469c1b6eb 100644
--- a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php
+++ b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php
@@ -61,13 +61,13 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
if ((bool) $this->status->notifications_enabled) {
$notificationDescription = sprintf(
'%s',
- mt('monitoring', 'Disable notifications for a specific time on a program-wide basis'),
+ $this->translate('Disable notifications for a specific time on a program-wide basis'),
$this->getView()->href('monitoring/process/disable-notifications'),
- mt('monitoring', 'Disable temporarily')
+ $this->translate('Disable temporarily')
);
} elseif ($this->status->disable_notif_expire_time) {
$notificationDescription = sprintf(
- mt('monitoring', 'Notifications will be re-enabled in %s'),
+ $this->translate('Notifications will be re-enabled in %s'),
$this->getView()->timeUntil($this->status->disable_notif_expire_time)
);
} else {
@@ -78,7 +78,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox',
ToggleInstanceFeatureCommand::FEATURE_ACTIVE_HOST_CHECKS,
array(
- 'label' => mt('monitoring', 'Active Host Checks Being Executed'),
+ 'label' => $this->translate('Active Host Checks Being Executed'),
'autosubmit' => true
)
),
@@ -86,7 +86,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox',
ToggleInstanceFeatureCommand::FEATURE_ACTIVE_SERVICE_CHECKS,
array(
- 'label' => mt('monitoring', 'Active Service Checks Being Executed'),
+ 'label' => $this->translate('Active Service Checks Being Executed'),
'autosubmit' => true
)
),
@@ -94,7 +94,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox',
ToggleInstanceFeatureCommand::FEATURE_EVENT_HANDLERS,
array(
- 'label' => mt('monitoring', 'Event Handlers Enabled'),
+ 'label' => $this->translate('Event Handlers Enabled'),
'autosubmit' => true
)
),
@@ -102,7 +102,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox',
ToggleInstanceFeatureCommand::FEATURE_FLAP_DETECTION,
array(
- 'label' => mt('monitoring', 'Flap Detection Enabled'),
+ 'label' => $this->translate('Flap Detection Enabled'),
'autosubmit' => true
)
),
@@ -110,7 +110,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox',
ToggleInstanceFeatureCommand::FEATURE_NOTIFICATIONS,
array(
- 'label' => mt('monitoring', 'Notifications Enabled'),
+ 'label' => $this->translate('Notifications Enabled'),
'autosubmit' => true,
'description' => $notificationDescription,
'decorators' => array(
@@ -129,7 +129,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox',
ToggleInstanceFeatureCommand::FEATURE_HOST_OBSESSING,
array(
- 'label' => mt('monitoring', 'Obsessing Over Hosts'),
+ 'label' => $this->translate('Obsessing Over Hosts'),
'autosubmit' => true
)
),
@@ -137,7 +137,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox',
ToggleInstanceFeatureCommand::FEATURE_SERVICE_OBSESSING,
array(
- 'label' => mt('monitoring', 'Obsessing Over Services'),
+ 'label' => $this->translate('Obsessing Over Services'),
'autosubmit' => true
)
),
@@ -145,7 +145,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox',
ToggleInstanceFeatureCommand::FEATURE_PASSIVE_HOST_CHECKS,
array(
- 'label' => mt('monitoring', 'Passive Host Checks Being Accepted'),
+ 'label' => $this->translate('Passive Host Checks Being Accepted'),
'autosubmit' => true
)
),
@@ -153,7 +153,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox',
ToggleInstanceFeatureCommand::FEATURE_PASSIVE_SERVICE_CHECKS,
array(
- 'label' => mt('monitoring', 'Passive Service Checks Being Accepted'),
+ 'label' => $this->translate('Passive Service Checks Being Accepted'),
'autosubmit' => true
)
),
@@ -161,7 +161,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox',
ToggleInstanceFeatureCommand::FEATURE_PERFORMANCE_DATA,
array(
- 'label' => mt('monitoring', 'Performance Data Being Processed'),
+ 'label' => $this->translate('Performance Data Being Processed'),
'autosubmit' => true
)
)
@@ -198,7 +198,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
->setEnabled($enabled);
$this->getTransport($this->request)->send($toggleFeature);
}
- Notification::success(mt('monitoring', 'Toggling feature..'));
+ Notification::success($this->translate('Toggling feature..'));
return true;
}
}
diff --git a/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php b/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php
index 25ac76c25..df3731837 100644
--- a/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php
+++ b/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php
@@ -31,8 +31,7 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm
*/
public function getHelp()
{
- return mt(
- 'monitoring',
+ return $this->translate(
'This command is used to acknowledge host or service problems. When a problem is acknowledged,'
. ' future notifications about problems are temporarily disabled until the host or service'
. ' recovers.'
@@ -51,9 +50,8 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm
'comment',
array(
'required' => true,
- 'label' => mt('monitoring', 'Comment'),
- 'description' => mt(
- 'monitoring',
+ 'label' => $this->translate('Comment'),
+ 'description' => $this->translate(
'If you work with other administrators, you may find it useful to share information about the'
. ' the host or service that is having problems. Make sure you enter a brief description of'
. ' what you are doing.'
@@ -64,9 +62,8 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm
'checkbox',
'persistent',
array(
- 'label' => mt('monitoring', 'Persistent Comment'),
- 'description' => mt(
- 'monitoring',
+ 'label' => $this->translate('Persistent Comment'),
+ 'description' => $this->translate(
'If you would like the comment to remain even when the acknowledgement is removed, check this'
. ' option.'
)
@@ -76,8 +73,10 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm
'checkbox',
'expire',
array(
- 'label' => mt('monitoring', 'Use Expire Time'),
- 'description' => mt('monitoring', 'If the acknowledgement should expire, check this option.'),
+ 'label' => $this->translate('Use Expire Time'),
+ 'description' => $this->translate(
+ 'If the acknowledgement should expire, check this option.'
+ ),
'autosubmit' => true
)
)
@@ -89,10 +88,9 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm
'dateTimePicker',
'expire_time',
array(
- 'label' => mt('monitoring', 'Expire Time'),
+ 'label' => $this->translate('Expire Time'),
'value' => $expireTime,
- 'description' => mt(
- 'monitoring',
+ 'description' => $this->translate(
'Enter the expire date and time for this acknowledgement here. Icinga will delete the'
. ' acknowledgement after this time expired.'
)
@@ -114,10 +112,9 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm
'checkbox',
'sticky',
array(
- 'label' => mt('monitoring', 'Sticky Acknowledgement'),
+ 'label' => $this->translate('Sticky Acknowledgement'),
'value' => true,
- 'description' => mt(
- 'monitoring',
+ 'description' => $this->translate(
'If you want the acknowledgement to disable notifications until the host or service recovers,'
. ' check this option.'
)
@@ -127,10 +124,9 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm
'checkbox',
'notify',
array(
- 'label' => mt('monitoring', 'Send Notification'),
+ 'label' => $this->translate('Send Notification'),
'value' => true,
- 'description' => mt(
- 'monitoring',
+ 'description' => $this->translate(
'If you do not want an acknowledgement notification to be sent out to the appropriate contacts,'
. ' uncheck this option.'
)
diff --git a/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php b/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php
index f5adf6c71..e7f7e91f9 100644
--- a/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php
+++ b/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php
@@ -29,8 +29,7 @@ class AddCommentCommandForm extends ObjectsCommandForm
*/
public function getHelp()
{
- return mt(
- 'monitoring',
+ return $this->translate(
'This command is used to add host or service comments.'
);
}
@@ -47,9 +46,8 @@ class AddCommentCommandForm extends ObjectsCommandForm
'comment',
array(
'required' => true,
- 'label' => mt('monitoring', 'Comment'),
- 'description' => mt(
- 'monitoring',
+ 'label' => $this->translate('Comment'),
+ 'description' => $this->translate(
'If you work with other administrators, you may find it useful to share information about the'
. ' the host or service that is having problems. Make sure you enter a brief description of'
. ' what you are doing.'
@@ -60,10 +58,9 @@ class AddCommentCommandForm extends ObjectsCommandForm
'checkbox',
'persistent',
array(
- 'label' => mt('monitoring', 'Persistent'),
+ 'label' => $this->translate('Persistent'),
'value' => true,
- 'description' => mt(
- 'monitoring',
+ 'description' => $this->translate(
'If you uncheck this option, the comment will automatically be deleted the next time Icinga is'
. ' restarted.'
)
diff --git a/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php b/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php
index 01006683f..1054aae05 100644
--- a/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php
+++ b/modules/monitoring/application/forms/Command/Object/CheckNowCommandForm.php
@@ -35,8 +35,8 @@ class CheckNowCommandForm extends ObjectsCommandForm
array(
'ignore' => true,
'type' => 'submit',
- 'value' => mt('monitoring', 'Check now'),
- 'label' => ' ' . mt('monitoring', 'Check now'),
+ 'value' => $this->translate('Check now'),
+ 'label' => ' ' . $this->translate('Check now'),
'decorators' => array('ViewHelper'),
'escape' => false,
'class' => 'link-like'
diff --git a/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php
index 3d85afcec..0f7858ad9 100644
--- a/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php
+++ b/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php
@@ -55,7 +55,7 @@ class DeleteCommentCommandForm extends ObjectsCommandForm
array(
'ignore' => true,
'label' => 'X',
- 'title' => mt('monitoring', 'Delete comment'),
+ 'title' => $this->translate('Delete comment'),
'decorators' => array('ViewHelper')
)
);
@@ -80,7 +80,7 @@ class DeleteCommentCommandForm extends ObjectsCommandForm
if (! empty($redirect)) {
$this->setRedirectUrl($redirect);
}
- Notification::success(mt('monitoring', 'Deleting comment..'));
+ Notification::success($this->translate('Deleting comment..'));
return true;
}
}
diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php
index 1c7095b82..43ca52b05 100644
--- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php
+++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php
@@ -55,7 +55,7 @@ class DeleteDowntimeCommandForm extends ObjectsCommandForm
array(
'ignore' => true,
'label' => 'X',
- 'title' => mt('monitoring', 'Delete downtime'),
+ 'title' => $this->translate('Delete downtime'),
'decorators' => array('ViewHelper')
)
);
@@ -80,7 +80,7 @@ class DeleteDowntimeCommandForm extends ObjectsCommandForm
if (! empty($redirect)) {
$this->setRedirectUrl($redirect);
}
- Notification::success(mt('monitoring', 'Deleting downtime..'));
+ Notification::success($this->translate('Deleting downtime..'));
return true;
}
}
diff --git a/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php b/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php
index 48ee00ab3..44e248956 100644
--- a/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php
+++ b/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php
@@ -29,8 +29,7 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm
*/
public function getHelp()
{
- return mt(
- 'monitoring',
+ return $this->translate(
'This command is used to submit passive host or service check results.'
);
}
@@ -53,17 +52,17 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm
'status',
array(
'required' => true,
- 'label' => mt('monitoring', 'Status'),
- 'description' => mt('monitoring', 'The state this check result should report'),
+ 'label' => $this->translate('Status'),
+ 'description' => $this->translate('The state this check result should report'),
'multiOptions' => $object->getType() === $object::TYPE_HOST ? array(
- ProcessCheckResultCommand::HOST_UP => mt('monitoring', 'UP', 'icinga.state'),
- ProcessCheckResultCommand::HOST_DOWN => mt('monitoring', 'DOWN', 'icinga.state'),
- ProcessCheckResultCommand::HOST_UNREACHABLE => mt('monitoring', 'UNREACHABLE', 'icinga.state')
+ ProcessCheckResultCommand::HOST_UP => $this->translate('UP', 'icinga.state'),
+ ProcessCheckResultCommand::HOST_DOWN => $this->translate('DOWN', 'icinga.state'),
+ ProcessCheckResultCommand::HOST_UNREACHABLE => $this->translate('UNREACHABLE', 'icinga.state')
) : array(
- ProcessCheckResultCommand::SERVICE_OK => mt('monitoring', 'OK', 'icinga.state'),
- ProcessCheckResultCommand::SERVICE_WARNING => mt('monitoring', 'WARNING', 'icinga.state'),
- ProcessCheckResultCommand::SERVICE_CRITICAL => mt('monitoring', 'CRITICAL', 'icinga.state'),
- ProcessCheckResultCommand::SERVICE_UNKNOWN => mt('monitoring', 'UNKNOWN', 'icinga.state')
+ ProcessCheckResultCommand::SERVICE_OK => $this->translate('OK', 'icinga.state'),
+ ProcessCheckResultCommand::SERVICE_WARNING => $this->translate('WARNING', 'icinga.state'),
+ ProcessCheckResultCommand::SERVICE_CRITICAL => $this->translate('CRITICAL', 'icinga.state'),
+ ProcessCheckResultCommand::SERVICE_UNKNOWN => $this->translate('UNKNOWN', 'icinga.state')
)
)
);
@@ -72,8 +71,8 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm
'output',
array(
'required' => true,
- 'label' => mt('monitoring', 'Output'),
- 'description' => mt('monitoring', 'The plugin output of this check result')
+ 'label' => $this->translate('Output'),
+ 'description' => $this->translate('The plugin output of this check result')
)
);
$this->addElement(
@@ -81,9 +80,8 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm
'perfdata',
array(
'allowEmpty' => true,
- 'label' => mt('monitoring', 'Performance Data'),
- 'description' => mt(
- 'monitoring',
+ 'label' => $this->translate('Performance Data'),
+ 'description' => $this->translate(
'The performance data of this check result. Leave empty'
. ' if this check result has no performance data'
)
diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php
index 82a9b2e52..949ec33e1 100644
--- a/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php
+++ b/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php
@@ -24,9 +24,8 @@ class ScheduleHostCheckCommandForm extends ScheduleServiceCheckCommandForm
'checkbox',
'all_services',
array(
- 'label' => mt('monitoring', 'All Services'),
- 'description' => mt(
- 'monitoring',
+ 'label' => $this->translate('All Services'),
+ 'description' => $this->translate(
'Schedule check for all services on the hosts and the hosts themselves.'
)
)
diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php
index beb0793ef..f84069a9a 100644
--- a/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php
+++ b/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php
@@ -27,9 +27,8 @@ class ScheduleHostDowntimeCommandForm extends ScheduleServiceDowntimeCommandForm
'checkbox',
'all_services',
array(
- 'label' => mt('monitoring', 'All Services'),
- 'description' => mt(
- 'monitoring',
+ 'label' => $this->translate('All Services'),
+ 'description' => $this->translate(
'Schedule downtime for all services on the hosts and the hosts themselves.'
)
)
@@ -38,15 +37,14 @@ class ScheduleHostDowntimeCommandForm extends ScheduleServiceDowntimeCommandForm
'select',
'child_hosts',
array(
- 'label' => mt('monitoring', 'Child Hosts'),
+ 'label' => $this->translate('Child Hosts'),
'required' => true,
'multiOptions' => array(
- 0 => mt('monitoring', 'Do nothing with child hosts'),
- 1 => mt('monitoring', 'Schedule triggered downtime for all child hosts'),
- 2 => mt('monitoring', 'Schedule non-triggered downtime for all child hosts')
+ 0 => $this->translate('Do nothing with child hosts'),
+ 1 => $this->translate('Schedule triggered downtime for all child hosts'),
+ 2 => $this->translate('Schedule non-triggered downtime for all child hosts')
),
- 'description' => mt(
- 'monitoring',
+ 'description' => $this->translate(
'Define what should be done with the child hosts of the hosts.'
)
)
diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php
index 9e04a2254..b34472d49 100644
--- a/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php
+++ b/modules/monitoring/application/forms/Command/Object/ScheduleServiceCheckCommandForm.php
@@ -32,8 +32,7 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm
*/
public function getHelp()
{
- return mt(
- 'monitoring',
+ return $this->translate(
'This command is used to schedule the next check of hosts or services. Icinga will re-queue the'
. ' hosts or services to be checked at the time you specify.'
);
@@ -52,8 +51,7 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm
'note',
'command-info',
array(
- 'value' => mt(
- 'monitoring',
+ 'value' => $this->translate(
'This command is used to schedule the next check of hosts or services. Icinga will re-queue the'
. ' hosts or services to be checked at the time you specify.'
)
@@ -64,8 +62,10 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm
'check_time',
array(
'required' => true,
- 'label' => mt('monitoring', 'Check Time'),
- 'description' => mt('monitoring', 'Set the date and time when the check should be scheduled.'),
+ 'label' => $this->translate('Check Time'),
+ 'description' => $this->translate(
+ 'Set the date and time when the check should be scheduled.'
+ ),
'value' => $checkTime
)
),
@@ -73,9 +73,8 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm
'checkbox',
'force_check',
array(
- 'label' => mt('monitoring', 'Force Check'),
- 'description' => mt(
- 'monitoring',
+ 'label' => $this->translate('Force Check'),
+ 'description' => $this->translate(
'If you select this option, Icinga will force a check regardless of both what time the'
. ' scheduled check occurs and whether or not checks are enabled.'
)
diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php
index 9961d4b65..4f66898f6 100644
--- a/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php
+++ b/modules/monitoring/application/forms/Command/Object/ScheduleServiceDowntimeCommandForm.php
@@ -42,8 +42,7 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm
*/
public function getHelp()
{
- return mt(
- 'monitoring',
+ return $this->translate(
'This command is used to schedule host and service downtimes. During the specified downtime,'
. ' Icinga will not send notifications out about the hosts and services. When the scheduled'
. ' downtime expires, Icinga will send out notifications for the hosts and services as it'
@@ -67,9 +66,8 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm
'comment',
array(
'required' => true,
- 'label' => mt('monitoring', 'Comment'),
- 'description' => mt(
- 'monitoring',
+ 'label' => $this->translate('Comment'),
+ 'description' => $this->translate(
'If you work with other administrators, you may find it useful to share information about the'
. ' the host or service that is having problems. Make sure you enter a brief description of'
. ' what you are doing.'
@@ -81,8 +79,8 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm
'start',
array(
'required' => true,
- 'label' => mt('monitoring', 'Start Time'),
- 'description' => mt('monitoring', 'Set the start date and time for the downtime.'),
+ 'label' => $this->translate('Start Time'),
+ 'description' => $this->translate('Set the start date and time for the downtime.'),
'value' => $start
)
),
@@ -91,8 +89,8 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm
'end',
array(
'required' => true,
- 'label' => mt('monitoring', 'End Time'),
- 'description' => mt('monitoring', 'Set the end date and time for the downtime.'),
+ 'label' => $this->translate('End Time'),
+ 'description' => $this->translate('Set the end date and time for the downtime.'),
'value' => $end
)
),
@@ -102,17 +100,16 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm
array(
'required' => true,
'autosubmit' => true,
- 'label' => mt('monitoring', 'Type'),
- 'description' => mt(
- 'monitoring',
+ 'label' => $this->translate('Type'),
+ 'description' => $this->translate(
'If you select the fixed option, the downtime will be in effect between the start and end'
. ' times you specify whereas a flexible downtime starts when the host or service enters a'
. ' problem state sometime between the start and end times you specified and lasts as long'
. ' as the duration time you enter. The duration fields do not apply for fixed downtimes.'
),
'multiOptions' => array(
- self::FIXED => mt('monitoring', 'Fixed'),
- self::FLEXIBLE => mt('monitoring', 'Flexible')
+ self::FIXED => $this->translate('Fixed'),
+ self::FLEXIBLE => $this->translate('Flexible')
),
'validators' => array(
array(
@@ -141,7 +138,7 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm
'hours',
array(
'required' => true,
- 'label' => mt('monitoring', 'Hours'),
+ 'label' => $this->translate('Hours'),
'value' => 2,
'min' => -1
)
@@ -151,7 +148,7 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm
'minutes',
array(
'required' => true,
- 'label' => mt('monitoring', 'Minutes'),
+ 'label' => $this->translate('Minutes'),
'value' => 0,
'min' => -1
)
@@ -161,9 +158,8 @@ class ScheduleServiceDowntimeCommandForm extends ObjectsCommandForm
array('hours', 'minutes'),
'duration',
array(
- 'legend' => mt('monitoring', 'Flexible Duration'),
- 'description' => mt(
- 'monitoring',
+ 'legend' => $this->translate('Flexible Duration'),
+ 'description' => $this->translate(
'Enter here the duration of the downtime. The downtime will be automatically deleted after this'
. ' time expired.'
),
diff --git a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php
index c33527895..bf0a1d8b1 100644
--- a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php
+++ b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php
@@ -33,7 +33,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm
'checkbox',
ToggleObjectFeatureCommand::FEATURE_ACTIVE_CHECKS,
array(
- 'label' => mt('monitoring', 'Active Checks'),
+ 'label' => $this->translate('Active Checks'),
'autosubmit' => true
)
),
@@ -41,7 +41,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm
'checkbox',
ToggleObjectFeatureCommand::FEATURE_PASSIVE_CHECKS,
array(
- 'label' => mt('monitoring', 'Passive Checks'),
+ 'label' => $this->translate('Passive Checks'),
'autosubmit' => true
)
),
@@ -49,7 +49,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm
'checkbox',
ToggleObjectFeatureCommand::FEATURE_OBSESSING,
array(
- 'label' => mt('monitoring', 'Obsessing'),
+ 'label' => $this->translate('Obsessing'),
'autosubmit' => true
)
),
@@ -57,7 +57,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm
'checkbox',
ToggleObjectFeatureCommand::FEATURE_NOTIFICATIONS,
array(
- 'label' => mt('monitoring', 'Notifications'),
+ 'label' => $this->translate('Notifications'),
'autosubmit' => true
)
),
@@ -65,7 +65,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm
'checkbox',
ToggleObjectFeatureCommand::FEATURE_EVENT_HANDLER,
array(
- 'label' => mt('monitoring', 'Event Handler'),
+ 'label' => $this->translate('Event Handler'),
'autosubmit' => true
)
),
@@ -73,7 +73,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm
'checkbox',
ToggleObjectFeatureCommand::FEATURE_FLAP_DETECTION,
array(
- 'label' => mt('monitoring', 'Flap Detection'),
+ 'label' => $this->translate('Flap Detection'),
'autosubmit' => true
)
)
@@ -95,7 +95,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm
$element = $this->getElement($feature);
$element->setChecked($object->{$feature});
if ((bool) $object->{$feature . '_changed'} === true) {
- $element->setDescription(mt('monitoring', 'changed'));
+ $element->setDescription($this->translate('changed'));
}
}
return $this;
@@ -120,7 +120,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm
}
}
}
- Notification::success(mt('monitoring', 'Toggling feature..'));
+ Notification::success($this->translate('Toggling feature..'));
return true;
}
}
diff --git a/modules/monitoring/application/forms/Config/BackendConfigForm.php b/modules/monitoring/application/forms/Config/BackendConfigForm.php
index 4b1aa65b6..ca45c068b 100644
--- a/modules/monitoring/application/forms/Config/BackendConfigForm.php
+++ b/modules/monitoring/application/forms/Config/BackendConfigForm.php
@@ -5,10 +5,10 @@
namespace Icinga\Module\Monitoring\Forms\Config;
use InvalidArgumentException;
-use Icinga\Web\Notification;
-use Icinga\Forms\ConfigForm;
use Icinga\Application\Config;
use Icinga\Exception\ConfigurationError;
+use Icinga\Forms\ConfigForm;
+use Icinga\Web\Notification;
/**
* Form class for creating/modifying monitoring backends
@@ -18,7 +18,7 @@ class BackendConfigForm extends ConfigForm
/**
* The available monitoring backend resources split by type
*
- * @var array
+ * @type array
*/
protected $resources;
@@ -28,15 +28,15 @@ class BackendConfigForm extends ConfigForm
public function init()
{
$this->setName('form_config_monitoring_backends');
- $this->setSubmitLabel(mt('monitoring', 'Save Changes'));
+ $this->setSubmitLabel($this->translate('Save Changes'));
}
/**
* Set the resource configuration to use
*
- * @param Config $resources The resource configuration
+ * @param Config $resourceConfig The resource configuration
*
- * @return self
+ * @return $this
*
* @throws ConfigurationError In case there are no valid monitoring backend resources
*/
@@ -50,7 +50,7 @@ class BackendConfigForm extends ConfigForm
}
if (empty($resources)) {
- throw new ConfigurationError(mt('monitoring', 'Could not find any valid monitoring backend resources'));
+ throw new ConfigurationError($this->translate('Could not find any valid monitoring backend resources'));
}
$this->resources = $resources;
@@ -64,7 +64,7 @@ class BackendConfigForm extends ConfigForm
*
* @param array $values The values to extend the configuration with
*
- * @return self
+ * @return $this
*
* @throws InvalidArgumentException In case the backend does already exist
*/
@@ -72,9 +72,9 @@ class BackendConfigForm extends ConfigForm
{
$name = isset($values['name']) ? $values['name'] : '';
if (! $name) {
- throw new InvalidArgumentException(mt('monitoring', 'Monitoring backend name missing'));
+ throw new InvalidArgumentException($this->translate('Monitoring backend name missing'));
} elseif ($this->config->hasSection($name)) {
- throw new InvalidArgumentException(mt('monitoring', 'Monitoring backend already exists'));
+ throw new InvalidArgumentException($this->translate('Monitoring backend already exists'));
}
unset($values['name']);
@@ -95,11 +95,11 @@ class BackendConfigForm extends ConfigForm
public function edit($name, array $values)
{
if (! $name) {
- throw new InvalidArgumentException(mt('monitoring', 'Old monitoring backend name missing'));
+ throw new InvalidArgumentException($this->translate('Old monitoring backend name missing'));
} elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) {
- throw new InvalidArgumentException(mt('monitoring', 'New monitoring backend name missing'));
+ throw new InvalidArgumentException($this->translate('New monitoring backend name missing'));
} elseif (! $this->config->hasSection($name)) {
- throw new InvalidArgumentException(mt('monitoring', 'Unknown monitoring backend provided'));
+ throw new InvalidArgumentException($this->translate('Unknown monitoring backend provided'));
}
unset($values['name']);
@@ -119,9 +119,9 @@ class BackendConfigForm extends ConfigForm
public function remove($name)
{
if (! $name) {
- throw new InvalidArgumentException(mt('monitoring', 'Monitoring backend name missing'));
+ throw new InvalidArgumentException($this->translate('Monitoring backend name missing'));
} elseif (! $this->config->hasSection($name)) {
- throw new InvalidArgumentException(mt('monitoring', 'Unknown monitoring backend provided'));
+ throw new InvalidArgumentException($this->translate('Unknown monitoring backend provided'));
}
$backendConfig = $this->config->getSection($name);
@@ -131,23 +131,21 @@ class BackendConfigForm extends ConfigForm
/**
* Add or edit a monitoring backend and save the configuration
- *
- * @see Form::onSuccess()
*/
public function onSuccess()
{
$monitoringBackend = $this->request->getQuery('backend');
try {
- if ($monitoringBackend === null) { // create new backend
+ if ($monitoringBackend === null) { // Create new backend
$this->add($this->getValues());
- $message = mt('monitoring', 'Monitoring backend "%s" has been successfully created');
- } else { // edit existing backend
+ $message = $this->translate('Monitoring backend "%s" has been successfully created');
+ } else { // Edit existing backend
$this->edit($monitoringBackend, $this->getValues());
- $message = mt('monitoring', 'Monitoring backend "%s" has been successfully changed');
+ $message = $this->translate('Monitoring backend "%s" has been successfully changed');
}
} catch (InvalidArgumentException $e) {
Notification::error($e->getMessage());
- return;
+ return null;
}
if ($this->save()) {
@@ -160,18 +158,16 @@ class BackendConfigForm extends ConfigForm
/**
* Populate the form in case a monitoring backend is being edited
*
- * @see Form::onRequest()
- *
- * @throws ConfigurationError In case the backend name is missing in the request or is invalid
+ * @throws ConfigurationError In case the backend name is missing in the request or is invalid
*/
public function onRequest()
{
$monitoringBackend = $this->request->getQuery('backend');
if ($monitoringBackend !== null) {
if ($monitoringBackend === '') {
- throw new ConfigurationError(mt('monitoring', 'Monitoring backend name missing'));
+ throw new ConfigurationError($this->translate('Monitoring backend name missing'));
} elseif (! $this->config->hasSection($monitoringBackend)) {
- throw new ConfigurationError(mt('monitoring', 'Unknown monitoring backend provided'));
+ throw new ConfigurationError($this->translate('Unknown monitoring backend provided'));
}
$backendConfig = $this->config->getSection($monitoringBackend)->toArray();
@@ -181,7 +177,8 @@ class BackendConfigForm extends ConfigForm
}
/**
- * @see Form::createElements()
+ * (non-PHPDoc)
+ * @see Form::createElements() For the method documentation.
*/
public function createElements(array $formData)
{
@@ -200,7 +197,7 @@ class BackendConfigForm extends ConfigForm
'disabled',
array(
'required' => true,
- 'label' => mt('monitoring', 'Disable This Backend')
+ 'label' => $this->translate('Disable This Backend')
)
);
$this->addElement(
@@ -208,8 +205,8 @@ class BackendConfigForm extends ConfigForm
'name',
array(
'required' => true,
- 'label' => mt('monitoring', 'Backend Name'),
- 'description' => mt('monitoring', 'The identifier of this backend')
+ 'label' => $this->translate('Backend Name'),
+ 'description' => $this->translate('The identifier of this backend')
)
);
$this->addElement(
@@ -218,8 +215,8 @@ class BackendConfigForm extends ConfigForm
array(
'required' => true,
'autosubmit' => true,
- 'label' => mt('monitoring', 'Backend Type'),
- 'description' => mt('monitoring', 'The data source used for retrieving monitoring information'),
+ 'label' => $this->translate('Backend Type'),
+ 'description' => $this->translate('The data source used for retrieving monitoring information'),
'multiOptions' => $resourceTypes,
'value' => $resourceType
)
@@ -230,8 +227,8 @@ class BackendConfigForm extends ConfigForm
'resource',
array(
'required' => true,
- 'label' => mt('monitoring', 'Resource'),
- 'description' => mt('monitoring', 'The resource to use'),
+ 'label' => $this->translate('Resource'),
+ 'description' => $this->translate('The resource to use'),
'multiOptions' => $this->resources[$resourceType],
'autosubmit' => true
)
@@ -253,8 +250,8 @@ class BackendConfigForm extends ConfigForm
array(
'value' => sprintf(
'%s',
- $this->getView()->href('/icingaweb/config/editresource', array('resource' => $resourceName)),
- mt('monitoring', 'Show resource configuration')
+ $this->getView()->url('config/editresource', array('resource' => $resourceName)),
+ $this->translate('Show resource configuration')
),
'escape' => false
)
diff --git a/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php b/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php
index daabe7e02..405bac144 100644
--- a/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php
+++ b/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php
@@ -28,9 +28,9 @@ class LocalInstanceForm extends Form
'path',
array(
'required' => true,
- 'label' => mt('monitoring', 'Command File'),
+ 'label' => $this->translate('Command File'),
'value' => '/var/run/icinga2/cmd/icinga2.cmd',
- 'description' => mt('monitoring', 'Path to the local Icinga command file')
+ 'description' => $this->translate('Path to the local Icinga command file')
)
);
return $this;
diff --git a/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php b/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php
index 7c55f655a..47b2a0316 100644
--- a/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php
+++ b/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php
@@ -29,8 +29,8 @@ class RemoteInstanceForm extends Form
'host',
array(
'required' => true,
- 'label' => mt('monitoring', 'Host'),
- 'description' => mt('monitoring',
+ 'label' => $this->translate('Host'),
+ 'description' => $this->translate(
'Hostname or address of the remote Icinga instance'
)
)
@@ -40,8 +40,8 @@ class RemoteInstanceForm extends Form
'port',
array(
'required' => true,
- 'label' => mt('monitoring', 'Port'),
- 'description' => mt('monitoring', 'SSH port to connect to on the remote Icinga instance'),
+ 'label' => $this->translate('Port'),
+ 'description' => $this->translate('SSH port to connect to on the remote Icinga instance'),
'value' => 22
)
),
@@ -50,8 +50,8 @@ class RemoteInstanceForm extends Form
'user',
array(
'required' => true,
- 'label' => mt('monitoring', 'User'),
- 'description' => mt('monitoring',
+ 'label' => $this->translate('User'),
+ 'description' => $this->translate(
'User to log in as on the remote Icinga instance. Please note that key-based SSH login must be'
. ' possible for this user'
)
@@ -62,9 +62,9 @@ class RemoteInstanceForm extends Form
'path',
array(
'required' => true,
- 'label' => mt('monitoring', 'Command File'),
+ 'label' => $this->translate('Command File'),
'value' => '/var/run/icinga2/cmd/icinga2.cmd',
- 'description' => mt('monitoring', 'Path to the Icinga command file on the remote Icinga instance')
+ 'description' => $this->translate('Path to the Icinga command file on the remote Icinga instance')
)
)
));
diff --git a/modules/monitoring/application/forms/Config/InstanceConfigForm.php b/modules/monitoring/application/forms/Config/InstanceConfigForm.php
index b89e48c0a..5618f27ee 100644
--- a/modules/monitoring/application/forms/Config/InstanceConfigForm.php
+++ b/modules/monitoring/application/forms/Config/InstanceConfigForm.php
@@ -25,7 +25,7 @@ class InstanceConfigForm extends ConfigForm
public function init()
{
$this->setName('form_config_monitoring_instance');
- $this->setSubmitLabel(mt('monitoring', 'Save Changes'));
+ $this->setSubmitLabel($this->translate('Save Changes'));
}
/**
@@ -48,7 +48,7 @@ class InstanceConfigForm extends ConfigForm
break;
default:
throw new InvalidArgumentException(
- sprintf(mt('monitoring', 'Invalid instance type "%s" given'), $type)
+ sprintf($this->translate('Invalid instance type "%s" given'), $type)
);
}
return $form;
@@ -69,10 +69,10 @@ class InstanceConfigForm extends ConfigForm
{
$name = isset($values['name']) ? $values['name'] : '';
if (! $name) {
- throw new InvalidArgumentException(mt('monitoring', 'Instance name missing'));
+ throw new InvalidArgumentException($this->translate('Instance name missing'));
}
if ($this->config->hasSection($name)) {
- throw new InvalidArgumentException(mt('monitoring', 'Instance already exists'));
+ throw new InvalidArgumentException($this->translate('Instance already exists'));
}
unset($values['name']);
@@ -93,11 +93,11 @@ class InstanceConfigForm extends ConfigForm
public function edit($name, array $values)
{
if (! $name) {
- throw new InvalidArgumentException(mt('monitoring', 'Old instance name missing'));
+ throw new InvalidArgumentException($this->translate('Old instance name missing'));
} elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) {
- throw new InvalidArgumentException(mt('monitoring', 'New instance name missing'));
+ throw new InvalidArgumentException($this->translate('New instance name missing'));
} elseif (! $this->config->hasSection($name)) {
- throw new InvalidArgumentException(mt('monitoring', 'Unknown instance name provided'));
+ throw new InvalidArgumentException($this->translate('Unknown instance name provided'));
}
unset($values['name']);
@@ -117,9 +117,9 @@ class InstanceConfigForm extends ConfigForm
public function remove($name)
{
if (! $name) {
- throw new InvalidArgumentException(mt('monitoring', 'Instance name missing'));
+ throw new InvalidArgumentException($this->translate('Instance name missing'));
} elseif (! $this->config->hasSection($name)) {
- throw new InvalidArgumentException(mt('monitoring', 'Unknown instance name provided'));
+ throw new InvalidArgumentException($this->translate('Unknown instance name provided'));
}
$instanceConfig = $this->config->getSection($name);
@@ -136,10 +136,10 @@ class InstanceConfigForm extends ConfigForm
$instanceName = $this->request->getQuery('instance');
if ($instanceName !== null) {
if (! $instanceName) {
- throw new ConfigurationError(mt('monitoring', 'Instance name missing'));
+ throw new ConfigurationError($this->translate('Instance name missing'));
}
if (! $this->config->hasSection($instanceName)) {
- throw new ConfigurationError(mt('monitoring', 'Unknown instance name given'));
+ throw new ConfigurationError($this->translate('Unknown instance name given'));
}
$instanceConfig = $this->config->getSection($instanceName)->toArray();
@@ -158,10 +158,10 @@ class InstanceConfigForm extends ConfigForm
try {
if ($instanceName === null) { // create new instance
$this->add($this->getValues());
- $message = mt('monitoring', 'Instance "%s" created successfully.');
+ $message = $this->translate('Instance "%s" created successfully.');
} else { // edit existing instance
$this->edit($instanceName, $this->getValues());
- $message = mt('monitoring', 'Instance "%s" edited successfully.');
+ $message = $this->translate('Instance "%s" edited successfully.');
}
} catch (InvalidArgumentException $e) {
Notification::error($e->getMessage());
@@ -189,7 +189,7 @@ class InstanceConfigForm extends ConfigForm
'name',
array(
'required' => true,
- 'label' => mt('monitoring', 'Instance Name')
+ 'label' => $this->translate('Instance Name')
)
),
array(
@@ -198,10 +198,10 @@ class InstanceConfigForm extends ConfigForm
array(
'required' => true,
'autosubmit' => true,
- 'label' => mt('monitoring', 'Instance Type'),
+ 'label' => $this->translate('Instance Type'),
'multiOptions' => array(
- LocalCommandFile::TRANSPORT => mt('monitoring', 'Local Command File'),
- RemoteCommandFile::TRANSPORT => mt('monitoring', 'Remote Command File')
+ LocalCommandFile::TRANSPORT => $this->translate('Local Command File'),
+ RemoteCommandFile::TRANSPORT => $this->translate('Remote Command File')
),
'value' => $instanceType
)
diff --git a/modules/monitoring/application/forms/Config/SecurityConfigForm.php b/modules/monitoring/application/forms/Config/SecurityConfigForm.php
index 40c0b7b8c..b202f5938 100644
--- a/modules/monitoring/application/forms/Config/SecurityConfigForm.php
+++ b/modules/monitoring/application/forms/Config/SecurityConfigForm.php
@@ -18,7 +18,7 @@ class SecurityConfigForm extends ConfigForm
public function init()
{
$this->setName('form_config_monitoring_security');
- $this->setSubmitLabel(mt('monitoring', 'Save Changes'));
+ $this->setSubmitLabel($this->translate('Save Changes'));
}
/**
@@ -29,7 +29,7 @@ class SecurityConfigForm extends ConfigForm
$this->config->setSection('security', $this->getValues());
if ($this->save()) {
- Notification::success(mt('monitoring', 'New security configuration has successfully been stored'));
+ Notification::success($this->translate('New security configuration has successfully been stored'));
} else {
return false;
}
@@ -54,8 +54,8 @@ class SecurityConfigForm extends ConfigForm
array(
'allowEmpty' => true,
'value' => '*pw*,*pass*,community',
- 'label' => mt('monitoring', 'Protected Custom Variables'),
- 'description' => mt('monitoring',
+ 'label' => $this->translate('Protected Custom Variables'),
+ 'description' => $this->translate(
'Comma separated case insensitive list of protected custom variables.'
. ' Use * as a placeholder for zero or more wildcard characters.'
. ' Existance of those custom variables will be shown, but their values will be masked.'
diff --git a/modules/monitoring/application/forms/EventOverviewForm.php b/modules/monitoring/application/forms/EventOverviewForm.php
index 25d268f76..dc697b940 100644
--- a/modules/monitoring/application/forms/EventOverviewForm.php
+++ b/modules/monitoring/application/forms/EventOverviewForm.php
@@ -44,7 +44,7 @@ class EventOverviewForm extends Form
'checkbox',
'statechange',
array(
- 'label' => t('State Changes'),
+ 'label' => $this->translate('State Changes'),
'class' => 'autosubmit',
'decorators' => $decorators,
'value' => strpos($url, $this->stateChangeFilter()->toQueryString()) === false ? 0 : 1
@@ -54,7 +54,7 @@ class EventOverviewForm extends Form
'checkbox',
'downtime',
array(
- 'label' => t('Downtimes'),
+ 'label' => $this->translate('Downtimes'),
'class' => 'autosubmit',
'decorators' => $decorators,
'value' => strpos($url, $this->downtimeFilter()->toQueryString()) === false ? 0 : 1
@@ -64,7 +64,7 @@ class EventOverviewForm extends Form
'checkbox',
'comment',
array(
- 'label' => t('Comments'),
+ 'label' => $this->translate('Comments'),
'class' => 'autosubmit',
'decorators' => $decorators,
'value' => strpos($url, $this->commentFilter()->toQueryString()) === false ? 0 : 1
@@ -74,7 +74,7 @@ class EventOverviewForm extends Form
'checkbox',
'notification',
array(
- 'label' => t('Notifications'),
+ 'label' => $this->translate('Notifications'),
'class' => 'autosubmit',
'decorators' => $decorators,
'value' => strpos($url, $this->notificationFilter()->toQueryString()) === false ? 0 : 1
@@ -84,7 +84,7 @@ class EventOverviewForm extends Form
'checkbox',
'flapping',
array(
- 'label' => t('Flapping'),
+ 'label' => $this->translate('Flapping'),
'class' => 'autosubmit',
'decorators' => $decorators,
'value' => strpos($url, $this->flappingFilter()->toQueryString()) === false ? 0 : 1
diff --git a/modules/monitoring/application/forms/Setup/BackendPage.php b/modules/monitoring/application/forms/Setup/BackendPage.php
index 1f6ef6894..b5ab2ffd6 100644
--- a/modules/monitoring/application/forms/Setup/BackendPage.php
+++ b/modules/monitoring/application/forms/Setup/BackendPage.php
@@ -20,7 +20,7 @@ class BackendPage extends Form
'note',
'title',
array(
- 'value' => mt('monitoring', 'Monitoring Backend', 'setup.page.title'),
+ 'value' => $this->translate('Monitoring Backend', 'setup.page.title'),
'decorators' => array(
'ViewHelper',
array('HtmlTag', array('tag' => 'h2'))
@@ -31,8 +31,7 @@ class BackendPage extends Form
'note',
'description',
array(
- 'value' => mt(
- 'monitoring',
+ 'value' => $this->translate(
'Please configure below how Icinga Web 2 should retrieve monitoring information.'
)
)
@@ -44,8 +43,8 @@ class BackendPage extends Form
array(
'required' => true,
'value' => 'icinga',
- 'label' => mt('monitoring', 'Backend Name'),
- 'description' => mt('monitoring', 'The identifier of this backend')
+ 'label' => $this->translate('Backend Name'),
+ 'description' => $this->translate('The identifier of this backend')
)
);
@@ -60,8 +59,10 @@ class BackendPage extends Form
'type',
array(
'required' => true,
- 'label' => mt('monitoring', 'Backend Type'),
- 'description' => mt('monitoring', 'The data source used for retrieving monitoring information'),
+ 'label' => $this->translate('Backend Type'),
+ 'description' => $this->translate(
+ 'The data source used for retrieving monitoring information'
+ ),
'multiOptions' => $resourceTypes
)
);
diff --git a/modules/monitoring/application/forms/Setup/IdoResourcePage.php b/modules/monitoring/application/forms/Setup/IdoResourcePage.php
index 189d65fea..c28b52e6b 100644
--- a/modules/monitoring/application/forms/Setup/IdoResourcePage.php
+++ b/modules/monitoring/application/forms/Setup/IdoResourcePage.php
@@ -28,7 +28,7 @@ class IdoResourcePage extends Form
'note',
'title',
array(
- 'value' => mt('monitoring', 'Monitoring IDO Resource', 'setup.page.title'),
+ 'value' => $this->translate('Monitoring IDO Resource', 'setup.page.title'),
'decorators' => array(
'ViewHelper',
array('HtmlTag', array('tag' => 'h2'))
@@ -39,8 +39,7 @@ class IdoResourcePage extends Form
'note',
'description',
array(
- 'value' => mt(
- 'monitoring',
+ 'value' => $this->translate(
'Please fill out the connection details below to access'
. ' the IDO database of your monitoring environment.'
)
@@ -91,8 +90,10 @@ class IdoResourcePage extends Form
'skip_validation',
array(
'required' => true,
- 'label' => t('Skip Validation'),
- 'description' => t('Check this to not to validate connectivity with the given database server')
+ 'label' => $this->translate('Skip Validation'),
+ 'description' => $this->translate(
+ 'Check this to not to validate connectivity with the given database server'
+ )
)
);
}
diff --git a/modules/monitoring/application/forms/Setup/InstancePage.php b/modules/monitoring/application/forms/Setup/InstancePage.php
index dccfd1d91..8f151554d 100644
--- a/modules/monitoring/application/forms/Setup/InstancePage.php
+++ b/modules/monitoring/application/forms/Setup/InstancePage.php
@@ -20,7 +20,7 @@ class InstancePage extends Form
'note',
'title',
array(
- 'value' => mt('monitoring', 'Monitoring Instance', 'setup.page.title'),
+ 'value' => $this->translate('Monitoring Instance', 'setup.page.title'),
'decorators' => array(
'ViewHelper',
array('HtmlTag', array('tag' => 'h2'))
@@ -31,8 +31,7 @@ class InstancePage extends Form
'note',
'description',
array(
- 'value' => mt(
- 'monitoring',
+ 'value' => $this->translate(
'Please define the settings specific to your monitoring instance below.'
)
)
diff --git a/modules/monitoring/application/forms/Setup/LivestatusResourcePage.php b/modules/monitoring/application/forms/Setup/LivestatusResourcePage.php
index 4faa17416..245d2abcc 100644
--- a/modules/monitoring/application/forms/Setup/LivestatusResourcePage.php
+++ b/modules/monitoring/application/forms/Setup/LivestatusResourcePage.php
@@ -28,7 +28,7 @@ class LivestatusResourcePage extends Form
'note',
'title',
array(
- 'value' => mt('monitoring', 'Monitoring Livestatus Resource', 'setup.page.title'),
+ 'value' => $this->translate('Monitoring Livestatus Resource', 'setup.page.title'),
'decorators' => array(
'ViewHelper',
array('HtmlTag', array('tag' => 'h2'))
@@ -39,8 +39,7 @@ class LivestatusResourcePage extends Form
'note',
'description',
array(
- 'value' => mt(
- 'monitoring',
+ 'value' => $this->translate(
'Please fill out the connection details below to access the Livestatus'
. ' socket interface for your monitoring environment.'
)
@@ -91,8 +90,10 @@ class LivestatusResourcePage extends Form
'skip_validation',
array(
'required' => true,
- 'label' => t('Skip Validation'),
- 'description' => t('Check this to not to validate connectivity with the given Livestatus socket')
+ 'label' => $this->translate('Skip Validation'),
+ 'description' => $this->translate(
+ 'Check this to not to validate connectivity with the given Livestatus socket'
+ )
)
);
}
diff --git a/modules/monitoring/application/forms/Setup/SecurityPage.php b/modules/monitoring/application/forms/Setup/SecurityPage.php
index 0c7d3d1de..ba8083e50 100644
--- a/modules/monitoring/application/forms/Setup/SecurityPage.php
+++ b/modules/monitoring/application/forms/Setup/SecurityPage.php
@@ -20,7 +20,7 @@ class SecurityPage extends Form
'note',
'title',
array(
- 'value' => mt('monitoring', 'Monitoring Security', 'setup.page.title'),
+ 'value' => $this->translate('Monitoring Security', 'setup.page.title'),
'decorators' => array(
'ViewHelper',
array('HtmlTag', array('tag' => 'h2'))
@@ -31,8 +31,7 @@ class SecurityPage extends Form
'note',
'description',
array(
- 'value' => mt(
- 'monitoring',
+ 'value' => $this->translate(
'To protect your monitoring environment against prying eyes please fill out the settings below.'
)
)
diff --git a/modules/monitoring/application/forms/Setup/WelcomePage.php b/modules/monitoring/application/forms/Setup/WelcomePage.php
index d910e2e01..f79eb6c62 100644
--- a/modules/monitoring/application/forms/Setup/WelcomePage.php
+++ b/modules/monitoring/application/forms/Setup/WelcomePage.php
@@ -19,10 +19,7 @@ class WelcomePage extends Form
'note',
'welcome',
array(
- 'value' => mt(
- 'monitoring',
- 'Welcome to the configuration of the monitoring module for Icinga Web 2!'
- ),
+ 'value' => $this->translate('Welcome to the configuration of the monitoring module for Icinga Web 2!'),
'decorators' => array(
'ViewHelper',
array('HtmlTag', array('tag' => 'h2'))
@@ -34,7 +31,7 @@ class WelcomePage extends Form
'note',
'core_hint',
array(
- 'value' => mt('monitoring', 'This is the core module for Icinga Web 2.')
+ 'value' => $this->translate('This is the core module for Icinga Web 2.')
)
);
@@ -42,8 +39,7 @@ class WelcomePage extends Form
'note',
'description',
array(
- 'value' => mt(
- 'monitoring',
+ 'value' => $this->translate(
'It offers various status and reporting views with powerful filter capabilities that allow'
. ' you to keep track of the most important events in your monitoring environment.'
)
diff --git a/modules/monitoring/application/forms/StatehistoryForm.php b/modules/monitoring/application/forms/StatehistoryForm.php
index 9fa1bdc26..d859f5815 100644
--- a/modules/monitoring/application/forms/StatehistoryForm.php
+++ b/modules/monitoring/application/forms/StatehistoryForm.php
@@ -19,7 +19,7 @@ class StatehistoryForm extends Form
public function init()
{
$this->setName('form_event_overview');
- $this->setSubmitLabel(mt('monitoring', 'Apply'));
+ $this->setSubmitLabel($this->translate('Apply'));
}
/**
@@ -65,14 +65,14 @@ class StatehistoryForm extends Form
'select',
'from',
array(
- 'label' => mt('monitoring', 'From'),
+ 'label' => $this->translate('From'),
'value' => $this->getRequest()->getParam('from', strtotime('3 months ago')),
'multiOptions' => array(
- strtotime('midnight 3 months ago') => mt('monitoring', '3 Months'),
- strtotime('midnight 4 months ago') => mt('monitoring', '4 Months'),
- strtotime('midnight 8 months ago') => mt('monitoring', '8 Months'),
- strtotime('midnight 12 months ago') => mt('monitoring', '1 Year'),
- strtotime('midnight 24 months ago') => mt('monitoring', '2 Years')
+ strtotime('midnight 3 months ago') => $this->translate('3 Months'),
+ strtotime('midnight 4 months ago') => $this->translate('4 Months'),
+ strtotime('midnight 8 months ago') => $this->translate('8 Months'),
+ strtotime('midnight 12 months ago') => $this->translate('1 Year'),
+ strtotime('midnight 24 months ago') => $this->translate('2 Years')
),
'class' => 'autosubmit'
)
@@ -81,10 +81,10 @@ class StatehistoryForm extends Form
'select',
'to',
array(
- 'label' => mt('monitoring', 'To'),
+ 'label' => $this->translate('To'),
'value' => $this->getRequest()->getParam('to', time()),
'multiOptions' => array(
- time() => mt('monitoring', 'Today')
+ time() => $this->translate('Today')
),
'class' => 'autosubmit'
)
@@ -95,11 +95,11 @@ class StatehistoryForm extends Form
'select',
'objecttype',
array(
- 'label' => mt('monitoring', 'Object type'),
+ 'label' => $this->translate('Object type'),
'value' => $objectType,
'multiOptions' => array(
- 'services' => mt('monitoring', 'Services'),
- 'hosts' => mt('monitoring', 'Hosts')
+ 'services' => $this->translate('Services'),
+ 'hosts' => $this->translate('Hosts')
),
'class' => 'autosubmit'
)
@@ -113,13 +113,13 @@ class StatehistoryForm extends Form
'select',
'state',
array(
- 'label' => mt('monitoring', 'State'),
+ 'label' => $this->translate('State'),
'value' => $serviceState,
'multiOptions' => array(
- 'cnt_critical_hard' => mt('monitoring', 'Critical'),
- 'cnt_warning_hard' => mt('monitoring', 'Warning'),
- 'cnt_unknown_hard' => mt('monitoring', 'Unknown'),
- 'cnt_ok' => mt('monitoring', 'Ok')
+ 'cnt_critical_hard' => $this->translate('Critical'),
+ 'cnt_warning_hard' => $this->translate('Warning'),
+ 'cnt_unknown_hard' => $this->translate('Unknown'),
+ 'cnt_ok' => $this->translate('Ok')
),
'class' => 'autosubmit'
)
@@ -133,12 +133,12 @@ class StatehistoryForm extends Form
'select',
'state',
array(
- 'label' => mt('monitoring', 'State'),
+ 'label' => $this->translate('State'),
'value' => $hostState,
'multiOptions' => array(
- 'cnt_up' => mt('monitoring', 'Up'),
- 'cnt_down_hard' => mt('monitoring', 'Down'),
- 'cnt_unreachable_hard' => mt('monitoring', 'Unreachable')
+ 'cnt_up' => $this->translate('Up'),
+ 'cnt_down_hard' => $this->translate('Down'),
+ 'cnt_unreachable_hard' => $this->translate('Unreachable')
),
'class' => 'autosubmit'
)
diff --git a/modules/monitoring/application/views/helpers/Link.php b/modules/monitoring/application/views/helpers/Link.php
new file mode 100644
index 000000000..0d8c35861
--- /dev/null
+++ b/modules/monitoring/application/views/helpers/Link.php
@@ -0,0 +1,59 @@
+view->qlink(
+ $linkText,
+ $this->view->href('monitoring/host/show', array('host' => $host))
+ );
+ }
+
+ /**
+ * Create a service link
+ *
+ * @param string $service Service name
+ * @param string $serviceLinkText Text for the service link, e.g. the service's display name
+ * @param string $host Hostname
+ * @param string $hostLinkText Text for the host link, e.g. the host's display name
+ *
+ * @return string
+ */
+ public function service($service, $serviceLinkText, $host, $hostLinkText)
+ {
+ return sprintf(
+ $this->view->translate('%s on %s', 'Service running on host'),
+ $this->view->qlink(
+ $serviceLinkText,
+ $this->view->href('monitoring/service/show', array('host' => $host, 'service' => $service))
+ ),
+ $this->host($host, $hostLinkText)
+ );
+ }
+}
diff --git a/modules/monitoring/application/views/helpers/MonitoringState.php b/modules/monitoring/application/views/helpers/MonitoringState.php
deleted file mode 100644
index 13bd93ea7..000000000
--- a/modules/monitoring/application/views/helpers/MonitoringState.php
+++ /dev/null
@@ -1,108 +0,0 @@
- 'pending', null => 'pending');
- private $hoststates = array('up', 'down', 'unreachable', 99 => 'pending', null => 'pending');
-
- /**
- * @deprecated Not used anywhere.
- */
- public function monitoringState($object, $type = 'service')
- {
- if ($type === 'service') {
- return $this->servicestates[$object->service_state];
- } elseif ($type === 'host') {
- return $this->hoststates[$object->host_state];
- }
- }
-
- /**
- * @deprecated Not used anywhere.
- */
- public function monitoringStateById($id, $type = 'service')
- {
- if ($type === 'service') {
- return $this->servicestates[$id];
- } elseif ($type === 'host') {
- return $this->hoststates[$id];
- }
- }
-
- /**
- * @deprecated Monitoring colors are clustered.
- */
- public function getServiceStateColors()
- {
- return array('#44bb77', '#FFCC66', '#FF5566', '#E066FF', '#77AAFF');
- }
-
- /**
- * @deprecated Monitoring colors are clustered.
- */
- public function getHostStateColors()
- {
- return array('#44bb77', '#FF5566', '#E066FF', '#77AAFF');
- }
-
- /**
- * @deprecated The service object must know about it's possible states.
- */
- public function getServiceStateNames()
- {
- return array_values($this->servicestates);
- }
-
- /**
- * @deprecated The host object must know about it's possible states.
- */
- public function getHostStateNames()
- {
- return array_values($this->hoststates);
- }
-
- /**
- * @deprecated Not used anywhere.
- */
- public function getStateFlags($object, $type = 'service')
- {
- $state_classes = array();
- if ($type === 'host') {
- $state_classes[] = $this->monitoringState($object, "host");
- if ($object->host_acknowledged || $object->host_in_downtime) {
- $state_classes[] = 'handled';
- }
- if ($object->host_last_state_change > (time() - 600)) {
- $state_classes[] = 'new';
- }
- } else {
- $state_classes[] = $this->monitoringState($object, "service");
- if ($object->service_acknowledged || $object->service_in_downtime) {
- $state_classes[] = 'handled';
- }
- if ($object->service_last_state_change > (time() - 600)) {
- $state_classes[] = 'new';
- }
- }
-
- return $state_classes;
- }
-
- /**
- * @deprecated Not used anywhere.
- */
- public function getStateTitle($object, $type)
- {
- return sprintf(
- '%s %s %s',
- $this->view->translate(strtoupper($this->monitoringState($object, $type))),
- $this->view->translate('since'),
- date('Y-m-d H:i:s', $object->{$type.'_last_state_change'})
- );
- }
-}
diff --git a/modules/monitoring/application/views/helpers/Perfdata.php b/modules/monitoring/application/views/helpers/Perfdata.php
index eb649e77d..4c2bee89a 100644
--- a/modules/monitoring/application/views/helpers/Perfdata.php
+++ b/modules/monitoring/application/views/helpers/Perfdata.php
@@ -8,34 +8,52 @@ use Icinga\Module\Monitoring\Plugin\Perfdata;
use Icinga\Module\Monitoring\Plugin\PerfdataSet;
class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
-{
- public function perfdata($perfdataStr, $compact = false)
+{#
+
+ /**
+ * Display the given perfdata string to the user
+ *
+ * @param $perfdataStr The perfdata string
+ * @param bool $compact Whether to display the perfdata in compact mode
+ * @param $color The color indicating the perfdata state
+ *
+ * @return string
+ */
+ public function perfdata($perfdataStr, $compact = false, $color = Perfdata::PERFDATA_OK)
{
- $pset = PerfdataSet::fromString($perfdataStr)->asArray();
- $onlyPieChartData = array_filter($pset, function ($e) { return $e->getPercentage() > 0; });
- if ($compact) {
- $onlyPieChartData = array_slice($onlyPieChartData, 0, 5);
- } else {
- $nonPieChartData = array_filter($pset, function ($e) { return $e->getPercentage() == 0; });
- }
+ $pieChartData = PerfdataSet::fromString($perfdataStr)->asArray();
$result = '';
- $table = array();
- foreach ($onlyPieChartData as $perfdata) {
- $pieChart = $this->createInlinePie($perfdata);
- if ($compact) {
- $result .= $pieChart->render();
+ $table = array(
+ '' . implode(
+ ' ',
+ array('', t('Label'), t('Value'), t('Min'), t('Max'), t('Warning'), t('Critical'))
+ ) . ' '
+ );
+ foreach ($pieChartData as $perfdata) {
+
+ if ($compact && $perfdata->isVisualizable()) {
+ $result .= $perfdata->asInlinePie($color)->render();
} else {
- if (! $perfdata->isPercentage()) {
- // TODO: Should we trust sprintf-style placeholders in perfdata titles?
- $pieChart->setTooltipFormat('{{label}}: {{formatted}} ({{percent}}%)');
+ $row = '';
+
+ $row .= '';
+ if ($perfdata->isVisualizable()) {
+ $row .= $perfdata->asInlinePie($color)->render() . ' ';
}
- // $pieChart->setStyle('margin: 0.2em 0.5em 0.2em 0.5em;');
- $table[] = ' ' . $pieChart->render()
- . htmlspecialchars($perfdata->getLabel())
- . ' '
- . htmlspecialchars($this->formatPerfdataValue($perfdata)) .
- ' ';
+ $row .= '
\n", $nonPieChartData); + return $pieCharts; } } - - protected function calculatePieChartData(Perfdata $perfdata) - { - $rawValue = $perfdata->getValue(); - $minValue = $perfdata->getMinimumValue() !== null ? $perfdata->getMinimumValue() : 0; - $maxValue = $perfdata->getMaximumValue(); - $usedValue = ($rawValue - $minValue); - $unusedValue = ($maxValue - $minValue) - $usedValue; - - $gray = $unusedValue; - $green = $orange = $red = 0; - // TODO(#6122): Add proper treshold parsing. - if ($perfdata->getCriticalThreshold() && $perfdata->getValue() > $perfdata->getCriticalThreshold()) { - $red = $usedValue; - } elseif ($perfdata->getWarningThreshold() && $perfdata->getValue() > $perfdata->getWarningThreshold()) { - $orange = $usedValue; - } else { - $green = $usedValue; - } - - return array($green, $orange, $red, $gray); - } - - protected function formatPerfdataValue(Perfdata $perfdata) - { - if ($perfdata->isBytes()) { - return Format::bytes($perfdata->getValue()); - } elseif ($perfdata->isSeconds()) { - return Format::seconds($perfdata->getValue()); - } elseif ($perfdata->isPercentage()) { - return $perfdata->getValue() . '%'; - } - - return $perfdata->getValue(); - } - - protected function createInlinePie(Perfdata $perfdata) - { - $pieChart = new InlinePie($this->calculatePieChartData($perfdata), $perfdata->getLabel()); - $pieChart->setLabel(htmlspecialchars($perfdata->getLabel())); - $pieChart->setHideEmptyLabel(); - - //$pieChart->setHeight(32)->setWidth(32); - if ($perfdata->isBytes()) { - $pieChart->setTooltipFormat('{{label}}: {{formatted}} ({{percent}}%)'); - $pieChart->setNumberFormat(InlinePie::NUMBER_FORMAT_BYTES); - } else if ($perfdata->isSeconds()) { - $pieChart->setTooltipFormat('{{label}}: {{formatted}} ({{percent}}%)'); - $pieChart->setNumberFormat(InlinePie::NUMBER_FORMAT_TIME); - } else { - $pieChart->setTooltipFormat('{{label}}: {{formatted}}%'); - $pieChart->setNumberFormat(InlinePie::NUMBER_FORMAT_RATIO); - $pieChart->setHideEmptyLabel(); - } - return $pieChart; - } } diff --git a/modules/monitoring/application/views/helpers/_RenderServicePerfdata.php b/modules/monitoring/application/views/helpers/_RenderServicePerfdata.php deleted file mode 100644 index d7612ac30..000000000 --- a/modules/monitoring/application/views/helpers/_RenderServicePerfdata.php +++ /dev/null @@ -1,25 +0,0 @@ - array("self::renderDiskPie") - ); - - public function renderServicePerfdata($service) - { - if (isset(self::$RENDERMAP[$service->check_command])) { - $fn = self::$RENDERMAP[$service->check_command]; - $fn($service); - } - } - - public static function renderDiskPie($service) { - $perfdata = $service->performance_data; - if(!$perfdata) - return ""; - - } -} diff --git a/modules/monitoring/application/views/scripts/alertsummary/index.phtml b/modules/monitoring/application/views/scripts/alertsummary/index.phtml index 624b942b3..dbfff6433 100644 --- a/modules/monitoring/application/views/scripts/alertsummary/index.phtml +++ b/modules/monitoring/application/views/scripts/alertsummary/index.phtml @@ -1,6 +1,3 @@ -getHelper('MonitoringState'); -?>
= mt('monitoring', 'List Of Supported Commands'); ?>
--
- commands as $command): ?>
-
- - - = $this->escape($command); ?> - - - -
= $this->icon('host') ?> Host | -= $this->icon('conf') ?> Service | -
---|---|
= $object->host_name; ?> | -= (isset($object->service_description) ? $object->service_description : '') ?> | -
= $this->translate('Monitoring Backends') ?>
', strtoupper($text), $count); + echo sprintf('%s: %u
', $this->translate(strtoupper($text)), $count); } ?>
- = sprintf($this->translate('%u Hosts'), - count($objects)) - ?> + = sprintf( + $this->translatePlural( + '%u Host', + '%u Hosts', + $hostCount + ), + $hostCount + ) ?>
+ = sprintf( $this->translatePlural( '%u Unhandled Host Problem', '%u Unhandled Host Problems', - count($unhandledObjects) + $unhandledCount ), - count($unhandledObjects) + $unhandledCount ) ?>
+ = sprintf( $this->translatePlural( '%u Acknowledged Host Problem', '%u Acknowledged Host Problems', - count($acknowledgedObjects) + $acknowledgedCount ), - count($acknowledgedObjects) + $acknowledgedCount ) ?>
+ = $this->icon('plug') ?> - translatePlural( '%u host is in downtime', '%u hosts are in downtime', - count($objectsInDowntime) + $inDowntimeCount ), - count($objectsInDowntime) - ); ?> + $inDowntimeCount + ) ?>
- getComments())): ?> + getComments()) ?> += $this->icon('comment') ?> - = $this->translate(sprintf('%u comments', count($objects->getComments()))) ?> + = sprintf( + $this->translatePlural( + '%u comment', + '%u comments', + $havingCommentsCount + ), + $havingCommentsCount + ) ?>
diff --git a/modules/monitoring/application/views/scripts/layout/topbar.phtml b/modules/monitoring/application/views/scripts/layout/topbar.phtml deleted file mode 100644 index f7c58db85..000000000 --- a/modules/monitoring/application/views/scripts/layout/topbar.phtml +++ /dev/null @@ -1,65 +0,0 @@ - - - diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index 677010f1b..857017b4d 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -50,21 +50,13 @@= $this->icon('comment'); ?> = isset($comment->author) @@ -83,18 +75,20 @@ date('H:i', $comment->expiration) ) : $this->translate('This comment does not expire.'); ?>
- = $this->icon('comment'); ?> [= $downtime->author; ?>] = $downtime->comment; ?> + = $this->icon('comment') ?> [= $this->escape($downtime->author) ?>] = $this->escape($downtime->comment) ?>
is_flexible): ?> is_in_effect): ?> = sprintf( - $this->translate('This flexible downtime was started on %s at %s and lasts for %s until %s at %s.'), + isset($downtime->service) + ? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.') + : $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'), date('d.m.y', $downtime->start), date('H:i', $downtime->start), $this->format()->duration($downtime->duration), @@ -85,7 +81,9 @@ use Icinga\Module\Monitoring\Object\Service; ); ?> = sprintf( - $this->translate('This flexible downtime has been scheduled to start between %s - %s and to last for %s.'), + isset($downtime->service) + ? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.') + : $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'), date('d.m.y H:i', $downtime->scheduled_start), date('d.m.y H:i', $downtime->scheduled_end), $this->format()->duration($downtime->duration) @@ -94,7 +92,9 @@ use Icinga\Module\Monitoring\Object\Service; is_in_effect): ?> = sprintf( - $this->translate('This fixed downtime was started on %s at %s and expires on %s at %s.'), + isset($downtime->service) + ? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.') + : $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'), date('d.m.y', $downtime->start), date('H:i', $downtime->start), date('d.m.y', $downtime->end), @@ -102,7 +102,9 @@ use Icinga\Module\Monitoring\Object\Service; ); ?> = sprintf( - $this->translate('This fixed downtime has been scheduled to start on %s at %s and to end on %s at %s.'), + isset($downtime->service) + ? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.') + : $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'), date('d.m.y', $downtime->scheduled_start), date('H:i', $downtime->scheduled_start), date('d.m.y', $downtime->scheduled_end), @@ -112,6 +114,7 @@ use Icinga\Module\Monitoring\Object\Service;
+ = Host::getStateText($host->host_state, true); ?>
host_state !== 99): ?> = $this->prefixedTimeSince($host->host_last_state_change, true) ?> host_state > 0 && (int) $host->host_state_type === 0): ?> @@ -98,7 +96,7 @@ if ($hosts->count() === 0) { = $this->icon($this->resolveMacros($host->host_icon_image, $host)) ?> = implode(' ', $icons) ?> - = $host->host_name ?> + = $this->escape($host->host_display_name) ?> host_unhandled_services) && $host->host_unhandled_services > 0): ?> host_unhandled_services), @@ -110,15 +108,14 @@ if ($hosts->count() === 0) { $host->host_unhandled_services), 'monitoring/show/services', array( - 'host' => $host->host_name, - 'service_problem' => 1, - 'service_acknowledged' => 0, - 'service_in_downtime' => 0 + 'host' => $host->host_name, + 'service_problem' => 1, + 'service_handled' => 0 ), array('style' => 'font-weight: normal') ) ?>) -
= $this->escape(substr(strip_tags($host->host_output), 0, 10000)) ?>
+= $this->escape($this->ellipsis($host->host_output, 10000)) ?>
- = $this->dateTimeRenderer($notification->notification_start_time)->render( - $this->translate('on %s', 'datetime'), - $this->translate('at %s', 'time'), - $this->translate('%s ago', 'timespan') - ); - ?> - | -
-
- = $notification->service ?> on = $notification->host ?>
-
- = $notification->host ?>
-
- - = $this->escape(substr(strip_tags($notification->notification_output), 0, 10000)); ?> - - contact): ?> - - Sent to = $this->escape($notification->notification_contact) ?> - - - |
-
+ = $this->dateTimeRenderer($notification->notification_start_time)->render( + $this->translate('on %s', 'datetime'), + $this->translate('at %s', 'time'), + $this->translate('%s ago', 'timespan') + ) ?> + | +
+
+ = $this->icon('service') ?>
+ = $this->link()->service(
+ $notification->service,
+ $notification->service_display_name,
+ $notification->host,
+ $notification->host_display_name
+ ) ?>
+
+ = $this->icon('host') ?>
+ = $this->link()->host($notification->host, $notification->host_display_name) ?>
+
+ + = $this->escape($this->ellipsis($notification->notification_output, 10000)) ?> + + contact): ?> + + = sprintf( + $this->translate('Sent to %s'), + $this->qlink( + $notification->notification_contact, + 'monitoring/show/contact', + array('contact' => $notification->notification_contact) + ) + ) ?> + + + |
+
+ = Service::getStateText($service->service_state, true); ?>
compact): ?>= $this->prefixedTimeSince($service->service_last_state_change); ?>= $this->timeSince($service->service_last_state_change); ?> service_state > 0 && (int) $service->service_state_type === 0): ?>
@@ -106,12 +104,12 @@ foreach ($services as $service): service_icon_image && ! preg_match('/[\'"]/', $service->service_icon_image)): ?> = $this->icon($this->resolveMacros($service->service_icon_image, $service)) ?> -= $service->service_display_name ?>showHost): ?> on = $service->host_name; ?> += $this->escape($service->service_display_name) ?>showHost): ?> on = $this->escape($service->host_display_name) ?> host_state != 0): ?> - (= strtoupper(Host::getStateText($service->host_state, true)); ?>) + (= Host::getStateText($service->host_state, true); ?>)
-
= $this->escape(substr(strip_tags($service->service_output), 0, 10000)); ?>
+= $this->escape($this->ellipsis($service->service_output, 10000)); ?>
- = - $this->icon('bell-off-empty') - ?> = $this->translate('Delay Notifications') ?>
- - = $this->icon('ok') ?> Acknowledge - -
- = - $this->icon('plug') - ?> Schedule Downtimes -
- = - $this->icon('reschedule') - ?> Reschedule
-
- = - $this->icon('remove_petrol.png') ?> Remove Acknowledgements -
Summary for = count($objects) ?> hosts
- = $this->render('multi/components/objectlist.phtml'); ?> -
- = array_sum(array_values($states)) ?> Hosts- |
- - | |
---|---|---|
- = $this->pie->render(); ?> - | -
- $count) {
- if ($count > 0) {
- echo ucfirst($state) . ': ' . $count . ' '; - } - } - ?> - |
- - |
=$this->icon('host')?> Host Actions
- -Summary for = count($objects) ?> services
- -= array_sum(array_values($service_states)) ?> Services | -= array_sum(array_values($host_states)) ?> Hosts | -||
---|---|---|---|
= $this->service_pie->render() ?> | - $count) {
- if ($count > 0) {
- echo ucfirst($state) . ': ' . $count . ' '; - } - } - - ?> |
- = $this->host_pie->render() ?> | - $count) {
- if ($count > 0) {
- echo ucfirst($state) . ': ' . $count . ' '; - } - } - ?> |
-
=$this->icon('conf')?> Service Actions
- -= $title ?> = /** @var \Icinga\Module\Monitoring\Forms\Command\CommandForm $form */ $this->icon('help', $form->getHelp()) ?>
diff --git a/modules/monitoring/application/views/scripts/process/info.phtml b/modules/monitoring/application/views/scripts/process/info.phtml index 02b8eeb80..92bb6cb63 100644 --- a/modules/monitoring/application/views/scripts/process/info.phtml +++ b/modules/monitoring/application/views/scripts/process/info.phtml @@ -26,11 +26,11 @@ $cp = $this->checkPerformance()->create($this->checkperformance);', strtoupper($text), $count); + echo sprintf(' %s: %u
', $this->translate(strtoupper($text)), $count); } ?>
', strtoupper($text), $count); + echo sprintf('%s: %u
', $this->translate(strtoupper($text)), $count); } ?>
+ = sprintf( $this->translatePlural( '%u Unhandled Service Problem', '%u Unhandled Service Problems', - count($unhandledObjects) + $unhandledCount ), - count($unhandledObjects) + $unhandledCount ) ?>
+ = sprintf( $this->translatePlural( '%u Acknowledged Service Problem', '%u Acknowledged Service Problems', - count($acknowledgedObjects) + $acknowledgedCount ), - count($acknowledgedObjects) + $acknowledgedCount ) ?>
+ = $this->icon('plug') ?> - = $this->translate(sprintf('%u services are in downtime', count($objectsInDowntime))) ?> + = sprintf( + $this->translatePlural( + '%u service is in downtime', + '%u services are in downtime', + $inDowntimeCount + ), + $inDowntimeCount + ) ?>
- getComments())): ?> + getComments()) ?> += $this->icon('comment') ?> - = $this->translate(sprintf('%u comments', count($objects->getComments()))) ?> + = sprintf( + $this->translatePlural( + '%u comment', + '%u comments', + $havingCommentsCount + ), + $havingCommentsCount + ) ?>
diff --git a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml index 9b323e2f5..8da35590f 100644 --- a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml +++ b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml @@ -7,33 +7,40 @@ if (in_array((int) $object->state, array(0, 99))) { return; } -if ($object->getType() === $object::TYPE_HOST) { - $ackLink = $this->href( - 'monitoring/host/acknowledge-problem', - array('host' => $object->getName()) - ); -} else { - $ackLink = $this->href( - 'monitoring/service/acknowledge-problem', - array('host' => $object->getHost()->getName(), 'service' => $object->getName()) - ); -} - if ($object->acknowledged): ?>- = $form ?> (= ucfirst($comment->type) ?>): + populate(array('comment_id' => $comment->id)); + echo $delCommentForm; + } ?> + (= ucfirst($comment->type) ?>): |
- = str_replace(array('\r\n', '\n'), ' ', $text) ?> + = nl2br($commentText) ?> |
- = $form ?> = $state ?> + populate(array('downtime_id' => $downtime->id)); + echo $delDowntimeForm; + } ?> + = $state ?> |
- = str_replace(array('\r\n', '\n'), ' ', $text) ?> + = nl2br($commentText) ?> |
>
- = strtoupper(Host::getStateText($object->host_state, true)); ?> - = $this->prefixedTimeSince($object->host_last_state_change, true) ?> - |
- = $this->escape($object->host_name) ?>host_address && $object->host_address !== $object->host_name): ?>
- = $this->escape($object->host_address) ?> - - |
+ >
+ = Host::getStateText($object->host_state, true); ?> + = $this->prefixedTimeSince($object->host_last_state_change, true) ?> + |
+
+ = $this->escape($object->host_display_name) ?>
+ host_display_name !== $object->host_name): ?>
+ (= $this->escape($object->host_name) ?>)
+
+ host_address && $object->host_address !== $object->host_name): ?>
+ + = $this->escape($object->host_address) ?> + + |
+
+ = Service::getStateText($object->service_state, true); ?> + = $this->prefixedTimeSince($object->service_last_state_change, true) ?> + |
+ + = $this->translate('Service') ?>: = $this->escape($object->service_display_name) ?> + service_display_name !== $object->service_description): ?> + (= $this->escape($object->service_description) ?>) + + = $this->render('show/components/statusIcons.phtml') ?> + | ||
- = strtoupper(Service::getStateText($object->service_state, true)); ?> - = $this->prefixedTimeSince($object->service_last_state_change, true) ?> - |
- = $this->translate('Service') ?>: = $this->escape($object->service_description) ?> - - = $this->render('show/components/statusIcons.phtml') ?> - - | -||