mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-24 10:27:46 +02:00
parent
d5b8a850ea
commit
0de38c25eb
@ -1,4 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// @codingStandardsIgnoreStart
|
||||||
|
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring frontends
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to generate a text input with a datepicker being attached
|
* Helper to generate a text input with a datepicker being attached
|
||||||
@ -27,4 +52,4 @@ class Zend_View_Helper_FormDate extends \Zend_View_Helper_FormText
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
// @codingStandardsIgnoreStop
|
55
application/views/helpers/FormDateTime.php
Normal file
55
application/views/helpers/FormDateTime.php
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
// @codingStandardsIgnoreStart
|
||||||
|
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring frontends
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper to generate a text input with a datepicker being attached
|
||||||
|
*/
|
||||||
|
class Zend_View_Helper_FormDateTime extends \Zend_View_Helper_FormText
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Generates a html date input
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*
|
||||||
|
* @param string $name The element name.
|
||||||
|
* @param string $value The default value.
|
||||||
|
* @param array $attribs Attributes which should be added to the input tag.
|
||||||
|
*
|
||||||
|
* @return string The input tag and options XHTML.
|
||||||
|
*/
|
||||||
|
public function formDateTime($name, $value = null, $attribs = null)
|
||||||
|
{
|
||||||
|
return '<input type="datetime" class="datepick"'
|
||||||
|
. ' name="' . $this->view->escape($name) . '"'
|
||||||
|
. ' value="' . $this->view->escape($value) . '"'
|
||||||
|
. ' id="' . $this->view->escape($name) . '"'
|
||||||
|
. $this->_htmlAttribs($attribs)
|
||||||
|
. $this->getClosingBracket();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @codingStandardsIgnoreStop
|
@ -1,4 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// @codingStandardsIgnoreStart
|
||||||
|
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring frontends
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to generate a number input
|
* Helper to generate a number input
|
||||||
@ -27,4 +52,4 @@ class Zend_View_Helper_FormNumber extends \Zend_View_Helper_FormText
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
// @codingStandardsIgnoreStop
|
@ -1,4 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// @codingStandardsIgnoreStart
|
||||||
|
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring frontends
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to generate a text input with a timepicker being attached
|
* Helper to generate a text input with a timepicker being attached
|
||||||
@ -27,4 +52,4 @@ class Zend_View_Helper_FormTime extends \Zend_View_Helper_FormText
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
// @codingStandardsIgnoreStop
|
@ -1,4 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// @codingStandardsIgnoreStart
|
||||||
|
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring frontends
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
use Icinga\Util\Format;
|
use Icinga\Util\Format;
|
||||||
|
|
||||||
@ -10,3 +35,4 @@ class Zend_View_Helper_Format extends Zend_View_Helper_Abstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @codingStandardsIgnoreStop
|
@ -1,8 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// @codingStandardsIgnoreStart
|
||||||
|
|
||||||
// TODO: Search for the best and safest quoting
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
// TODO: Check whether attributes are safe. Script, title in combination with
|
/**
|
||||||
// Hover-Tips etc. Eventually create a whitelist for a few options only.
|
* Icinga 2 Web - Head for multiple monitoring frontends
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Zend_View_Helper_Img
|
||||||
|
*/
|
||||||
class Zend_View_Helper_Img extends Zend_View_Helper_Abstract
|
class Zend_View_Helper_Img extends Zend_View_Helper_Abstract
|
||||||
{
|
{
|
||||||
public function img($url, array $properties = array())
|
public function img($url, array $properties = array())
|
||||||
@ -27,3 +52,4 @@ class Zend_View_Helper_Img extends Zend_View_Helper_Abstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @codingStandardsIgnoreStart
|
@ -1,4 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// @codingStandardsIgnoreStart
|
||||||
|
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring frontends
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
|
|
||||||
@ -19,3 +44,4 @@ class Zend_View_Helper_QUrl extends Zend_View_Helper_Abstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @codingStandardsIgnoreStop
|
@ -1,10 +1,38 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// @codingStandardsIgnoreStart
|
||||||
|
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring frontends
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
// TODO: Search for the best and safest quoting
|
|
||||||
// TODO: Check whether attributes are safe. Script, title in combination with
|
|
||||||
// Hover-Tips etc. Eventually create a whitelist for a few options only.
|
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Zend_View_Helper_Qlink
|
||||||
|
* TODO: Search for the best and safest quoting
|
||||||
|
* TODO: Check whether attributes are safe. Script, title in combination with
|
||||||
|
* Hover-Tips etc. Eventually create a whitelist for a few options only.
|
||||||
|
*/
|
||||||
class Zend_View_Helper_Qlink extends Zend_View_Helper_Abstract
|
class Zend_View_Helper_Qlink extends Zend_View_Helper_Abstract
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -90,3 +118,4 @@ class Zend_View_Helper_Qlink extends Zend_View_Helper_Abstract
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @codingStandardsIgnoreStop
|
@ -1,5 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// @codingStandardsIgnoreStart
|
||||||
|
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring frontends
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Zend_View_Helper_TimeSince
|
||||||
|
*/
|
||||||
class Zend_View_Helper_TimeSince extends Zend_View_Helper_Abstract
|
class Zend_View_Helper_TimeSince extends Zend_View_Helper_Abstract
|
||||||
{
|
{
|
||||||
public function timeSince($timestamp)
|
public function timeSince($timestamp)
|
||||||
@ -42,3 +70,5 @@ class Zend_View_Helper_TimeSince extends Zend_View_Helper_Abstract
|
|||||||
return floor($hour / 24) . 'd ' . ($hour % 24) . 'h';
|
return floor($hour / 24) . 'd ' . ($hour % 24) . 'h';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @codingStandardsIgnoreStop
|
@ -1,5 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// @codingStandardsIgnoreStart
|
||||||
|
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring frontends
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Zend_View_Helper_Util
|
||||||
|
*/
|
||||||
class Zend_View_Helper_Util extends Zend_View_Helper_Abstract
|
class Zend_View_Helper_Util extends Zend_View_Helper_Abstract
|
||||||
{
|
{
|
||||||
public function util() {
|
public function util() {
|
||||||
@ -112,3 +140,4 @@ class Zend_View_Helper_Util extends Zend_View_Helper_Abstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @codingStandardsIgnoreStop
|
@ -26,6 +26,7 @@
|
|||||||
namespace Icinga\Web;
|
namespace Icinga\Web;
|
||||||
|
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
|
use Zend_View_Interface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Form
|
* Class Form
|
||||||
@ -68,7 +69,14 @@ abstract class Form extends \Zend_Form
|
|||||||
if (!$this->tokenDisabled) {
|
if (!$this->tokenDisabled) {
|
||||||
$this->initCsrfToken();
|
$this->initCsrfToken();
|
||||||
}
|
}
|
||||||
$this->create();
|
}
|
||||||
|
|
||||||
|
public function render(Zend_View_Interface $view = null)
|
||||||
|
{
|
||||||
|
if ($this->_isRendered === false) {
|
||||||
|
$this->create();
|
||||||
|
}
|
||||||
|
return parent::render($view);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
43
library/Icinga/Web/Form/Element/Date.php
Normal file
43
library/Icinga/Web/Form/Element/Date.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Icinga\Web\Form\Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Date form element
|
||||||
|
*
|
||||||
|
* @TODO: The given label for this element is not displayed. (Reason unknown)
|
||||||
|
*/
|
||||||
|
class Date extends \Zend_Form_Element_Xhtml
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Default form view helper to use for rendering
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $helper = "formDate";
|
||||||
|
}
|
40
library/Icinga/Web/Form/Element/DateTime.php
Normal file
40
library/Icinga/Web/Form/Element/DateTime.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Icinga\Web\Form\Element;
|
||||||
|
|
||||||
|
use Zend_Form_Element_Xhtml;
|
||||||
|
|
||||||
|
class DateTime extends Zend_Form_Element_Xhtml
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Default form view helper to use for rendering
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $helper = "formDateTime";
|
||||||
|
}
|
43
library/Icinga/Web/Form/Element/Note.php
Normal file
43
library/Icinga/Web/Form/Element/Note.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Icinga\Web\Form\Element;
|
||||||
|
|
||||||
|
use Zend_Form_Element_Xhtml;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements note element for Zend forms
|
||||||
|
*/
|
||||||
|
class Note extends Zend_Form_Element_Xhtml
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Name of the view helper
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $helper = 'formNote';
|
||||||
|
}
|
43
library/Icinga/Web/Form/Element/Number.php
Normal file
43
library/Icinga/Web/Form/Element/Number.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Icinga\Web\Form\Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number form element
|
||||||
|
*
|
||||||
|
* @TODO: The given label for this element is not displayed. (Reason unknown)
|
||||||
|
*/
|
||||||
|
class Number extends \Zend_Form_Element_Xhtml
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Default form view helper to use for rendering
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $helper = "formNumber";
|
||||||
|
}
|
43
library/Icinga/Web/Form/Element/Time.php
Normal file
43
library/Icinga/Web/Form/Element/Time.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Icinga\Web\Form\Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time form element
|
||||||
|
*
|
||||||
|
* @TODO: The given label for this element is not displayed. (Reason unknown)
|
||||||
|
*/
|
||||||
|
class Time extends \Zend_Form_Element_Xhtml
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Default form view helper to use for rendering
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $helper = "formTime";
|
||||||
|
}
|
@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace Icinga\Form\Elements;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Date form element
|
|
||||||
*
|
|
||||||
* @TODO: The given label for this element is not displayed. (Reason unknown)
|
|
||||||
*/
|
|
||||||
class Date extends \Zend_Form_Element_Xhtml
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Default form view helper to use for rendering
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $helper = "formDate";
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace Icinga\Form\Elements;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Number form element
|
|
||||||
*
|
|
||||||
* @TODO: The given label for this element is not displayed. (Reason unknown)
|
|
||||||
*/
|
|
||||||
class Number extends \Zend_Form_Element_Xhtml
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Default form view helper to use for rendering
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $helper = "formNumber";
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace Icinga\Form\Elements;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Time form element
|
|
||||||
*
|
|
||||||
* @TODO: The given label for this element is not displayed. (Reason unknown)
|
|
||||||
*/
|
|
||||||
class Time extends \Zend_Form_Element_Xhtml
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Default form view helper to use for rendering
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $helper = "formTime";
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
@ -1,7 +1,32 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
use Icinga\Backend;
|
use Icinga\Backend;
|
||||||
use Icinga\Form\SendCommand;
|
|
||||||
use Icinga\Form\Confirmation;
|
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
use Icinga\Authentication\Manager;
|
use Icinga\Authentication\Manager;
|
||||||
use Icinga\Web\ModuleActionController;
|
use Icinga\Web\ModuleActionController;
|
||||||
@ -10,41 +35,67 @@ use Icinga\Protocol\Commandpipe\CommandPipe;
|
|||||||
use Icinga\Protocol\Commandpipe\Acknowledgement;
|
use Icinga\Protocol\Commandpipe\Acknowledgement;
|
||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
use Icinga\Exception\MissingParameterException;
|
use Icinga\Exception\MissingParameterException;
|
||||||
|
use Monitoring\Form\Command\Acknowledge;
|
||||||
|
use Monitoring\Form\Command\Comment as CommentForm;
|
||||||
|
use Monitoring\Form\Command\Confirmation;
|
||||||
|
use Monitoring\Form\Command\CustomNotification;
|
||||||
|
use Monitoring\Form\Command\RescheduleNextCheck;
|
||||||
|
use Monitoring\Form\Command\SubmitPassiveCheckResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Monitoring_CommandController
|
||||||
|
*
|
||||||
|
* Interface to send commands and display forms
|
||||||
|
*/
|
||||||
class Monitoring_CommandController extends ModuleActionController
|
class Monitoring_CommandController extends ModuleActionController
|
||||||
{
|
{
|
||||||
|
const DEFAULT_VIEW_SCRIPT = 'renderform';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Icinga\Protocol\Commandpipe\CommandPipe
|
* @var \Icinga\Protocol\Commandpipe\CommandPipe
|
||||||
*/
|
*/
|
||||||
public $target;
|
public $target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controller configuration
|
||||||
|
* @throws Icinga\Exception\ConfigurationError
|
||||||
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
if ($this->_request->isPost()) {
|
// if ($this->_request->isPost()) {
|
||||||
// We do not need to display a view..
|
// // We do not need to display a view..
|
||||||
$this->_helper->viewRenderer->setNoRender(true);
|
// $this->_helper->viewRenderer->setNoRender(true);
|
||||||
// ..nor the overall site layout in case its a POST request.
|
// // ..nor the overall site layout in case its a POST request.
|
||||||
$this->_helper->layout()->disableLayout();
|
// $this->_helper->layout()->disableLayout();
|
||||||
|
//
|
||||||
|
// $instance = $this->_request->getPost("instance");
|
||||||
|
// $target_config = Config::getInstance()->getModuleConfig("instances", "monitoring");
|
||||||
|
// if ($instance) {
|
||||||
|
// if (isset($target_config[$instance])) {
|
||||||
|
// $this->target = new CommandPipe($target_config[$instance]);
|
||||||
|
// } else {
|
||||||
|
// throw new ConfigurationError("Instance $instance is not configured");
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// $target_info = $target_config->current(); // Take the very first section
|
||||||
|
// if ($target_info === false) {
|
||||||
|
// throw new ConfigurationError("Not any instances are configured yet");
|
||||||
|
// } else {
|
||||||
|
// $this->target = new CommandPipe($target_info);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
$instance = $this->_request->getPost("instance");
|
$this->_helper->viewRenderer->setRender(self::DEFAULT_VIEW_SCRIPT);
|
||||||
$target_config = Config::getInstance()->getModuleConfig("instances", "monitoring");
|
|
||||||
if ($instance) {
|
|
||||||
if (isset($target_config[$instance])) {
|
|
||||||
$this->target = new CommandPipe($target_config[$instance]);
|
|
||||||
} else {
|
|
||||||
throw new ConfigurationError("Instance $instance is not configured");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$target_info = $target_config->current(); // Take the very first section
|
|
||||||
if ($target_info === false) {
|
|
||||||
throw new ConfigurationError("Not any instances are configured yet");
|
|
||||||
} else {
|
|
||||||
$this->target = new CommandPipe($target_info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve all existing targets for host- and service combination
|
||||||
|
* @param string $hostname
|
||||||
|
* @param string $servicename
|
||||||
|
* @return array
|
||||||
|
* @throws Icinga\Exception\MissingParameterException
|
||||||
|
*/
|
||||||
private function selectCommandTargets($hostname, $servicename = null)
|
private function selectCommandTargets($hostname, $servicename = null)
|
||||||
{
|
{
|
||||||
$target = "hostlist";
|
$target = "hostlist";
|
||||||
@ -62,6 +113,13 @@ class Monitoring_CommandController extends ModuleActionController
|
|||||||
return Backend::getInstance()->select()->from($target)->applyFilters($filter)->fetchAll();
|
return Backend::getInstance()->select()->from($target)->applyFilters($filter)->fetchAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for request parameters
|
||||||
|
* @param string $name
|
||||||
|
* @param bool $mandatory
|
||||||
|
* @return mixed
|
||||||
|
* @throws Icinga\Exception\MissingParameterException
|
||||||
|
*/
|
||||||
private function getParameter($name, $mandatory = true)
|
private function getParameter($name, $mandatory = true)
|
||||||
{
|
{
|
||||||
$value = $this->_request->getParam($name);
|
$value = $this->_request->getParam($name);
|
||||||
@ -71,587 +129,350 @@ class Monitoring_CommandController extends ModuleActionController
|
|||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function restartAction()
|
// ------------------------------------------------------------------------
|
||||||
|
// Commands for hosts / services
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
public function disableactivechecksAction()
|
||||||
{
|
{
|
||||||
$form = new Confirmation("Restart Icinga?", Confirmation::YES_NO);
|
$form = new Confirmation();
|
||||||
if ($this->_request->isPost()) {
|
$form->setRequest($this->getRequest());
|
||||||
if ($form->isValid() && $form->isConfirmed()) {
|
$form->setSubmitLabel(t('Disable active checks'));
|
||||||
$this->target->restartIcinga();
|
$form->addNote(t('Disable active checks for this object.'));
|
||||||
}
|
$this->view->form = $form;
|
||||||
} else {
|
|
||||||
$form->setAction($this->view->url());
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
$this->view->form = $form;
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function schedulecheckAction()
|
|
||||||
{
|
|
||||||
$form = new SendCommand("Schedule Host/Service check");
|
|
||||||
$form->addDatePicker("checkDate", "Check date", date("m-d-Y"));
|
|
||||||
$form->addTimePicker("checkTime", "Check time", date("h:i A"));
|
|
||||||
$form->addCheckbox("forceCheck", "Force check", false);
|
|
||||||
|
|
||||||
if ($this->_request->isPost()) {
|
|
||||||
if ($form->isValid()) {
|
|
||||||
$withChilds = false;
|
|
||||||
$services = $form->getServices();
|
|
||||||
$time = sprintf("%s %s", $form->getDate("checkDate"), $form->getTime("checkTime"));
|
|
||||||
|
|
||||||
if (!$services || $services === "all") {
|
|
||||||
$withChilds = $services === "all";
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts());
|
|
||||||
} else {
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts(), $services);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($form->isChecked("forceCheck")) {
|
|
||||||
$this->target->scheduleForcedCheck($targets, $time, $withChilds);
|
|
||||||
} else {
|
|
||||||
$this->target->scheduleCheck($targets, $time, $withChilds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$form->setServices($this->getParameter("services", false));
|
|
||||||
$form->setHosts($this->getParameter("hosts"));
|
|
||||||
$form->setAction($this->view->url());
|
|
||||||
$form->addSubmitButton("Commit");
|
|
||||||
$this->view->form = $form;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function sendScheduledowntime()
|
|
||||||
{
|
|
||||||
$author = "AUTHOR"; //@TODO: get from auth backend
|
|
||||||
$comment = $this->getMandatoryParameter("comment");
|
|
||||||
$persistent = $this->_request->getPost("persistent", false) == "true";
|
|
||||||
$commentObj = new \Icinga\Protocol\Commandpipe\Comment($author, $comment, $persistent);
|
|
||||||
|
|
||||||
$start = intval($this->_request->getPost("start", time()));
|
|
||||||
$end = intval($this->getMandatoryParameter("end"));
|
|
||||||
$duration = $this->_request->getPost("duration", false);
|
|
||||||
if ($duration !== false) {
|
|
||||||
$duration = intval($duration);
|
|
||||||
}
|
|
||||||
$downtime = new \Icinga\Protocol\Commandpipe\Downtime($start, $end, $commentObj, $duration);
|
|
||||||
|
|
||||||
$this->target->scheduleDowntime($this->selectCommandTargets(), $downtime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function enableactivechecksAction()
|
public function enableactivechecksAction()
|
||||||
{
|
{
|
||||||
// @TODO: Elaborate how "withChilds" and "forHosts" can be utilised
|
$form = new Confirmation();
|
||||||
$form = new SendCommand("Enable active checks?");
|
$form->setRequest($this->getRequest());
|
||||||
if ($this->_request->isPost()) {
|
$form->setSubmitLabel(t('Enable active checks'));
|
||||||
if ($form->isValid()) {
|
$form->addNote(t('Enable active checks for this object.'));
|
||||||
$withChilds = $forHosts = false;
|
$this->view->form = $form;
|
||||||
$services = $form->getServices();
|
|
||||||
|
|
||||||
if ($services) {
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
$withChilds = $services === "all";
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
$form->addCheckbox("forHosts", "", false);
|
|
||||||
$forHosts = $form->isChecked("forHosts");
|
|
||||||
if ($withChilds) {
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts());
|
|
||||||
} else {
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts(), $services);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts());
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->target->enableActiveChecks($targets);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$services = $this->getParameter("services", false);
|
|
||||||
if ($services) {
|
|
||||||
$form->addCheckbox("forHosts", "Enable for hosts too?", false);
|
|
||||||
}
|
|
||||||
$form->setServices($services);
|
|
||||||
$form->setHosts($this->getParameter("hosts"));
|
|
||||||
$form->setAction($this->view->url());
|
|
||||||
$form->addSubmitButton("Commit");
|
|
||||||
$this->view->form = $form;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function disableactivechecksAction()
|
public function reschedulenextcheckAction()
|
||||||
{
|
{
|
||||||
// @TODO: Elaborate how "withChilds" and "forHosts" can be utilised
|
$form = new RescheduleNextCheck();
|
||||||
$form = new SendCommand("Disable active checks?");
|
$form->setRequest($this->getRequest());
|
||||||
if ($this->_request->isPost()) {
|
|
||||||
if ($form->isValid()) {
|
|
||||||
$withChilds = $forHosts = false;
|
|
||||||
$services = $form->getServices();
|
|
||||||
|
|
||||||
if ($services) {
|
$this->view->form = $form;
|
||||||
$withChilds = $services === "all";
|
|
||||||
$form->addCheckbox("forHosts", "", false);
|
|
||||||
$forHosts = $form->isChecked("forHosts");
|
|
||||||
if ($withChilds) {
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts());
|
|
||||||
} else {
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts(), $services);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts());
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->target->disableActiveChecks($targets);
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
}
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
} else {
|
|
||||||
$services = $this->getParameter("services", false);
|
|
||||||
if ($services) {
|
|
||||||
$form->addCheckbox("forHosts", "Disable for hosts too?", false);
|
|
||||||
}
|
|
||||||
$form->setServices($services);
|
|
||||||
$form->setHosts($this->getParameter("hosts"));
|
|
||||||
$form->setAction($this->view->url());
|
|
||||||
$form->addSubmitButton("Commit");
|
|
||||||
$this->view->form = $form;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function enablenotificationsAction()
|
public function submitpassivecheckresultAction()
|
||||||
{
|
{
|
||||||
// @TODO: Elaborate how "withChilds", "childHosts" and "forHosts" can be utilised
|
$type = SubmitPassiveCheckResult::TYPE_SERVICE;
|
||||||
$form = new SendCommand("Enable notifications?");
|
|
||||||
if ($this->_request->isPost()) {
|
|
||||||
if ($form->isValid()) {
|
|
||||||
$services = $form->getServices();
|
|
||||||
$withChilds = $forHosts = $childHosts = false;
|
|
||||||
|
|
||||||
if ($services) {
|
$form = new SubmitPassiveCheckResult();
|
||||||
$withChilds = $services === "all";
|
$form->setRequest($this->getRequest());
|
||||||
$form->addCheckbox("forHosts", "", false);
|
$form->setType($type);
|
||||||
$forHosts = $form->isChecked("forHosts");
|
|
||||||
if ($withChilds) {
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts());
|
|
||||||
} else {
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts(), $services);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$form->addCheckbox("childHosts", "", false);
|
|
||||||
$childHosts = $form->isChecked("childHosts");
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts());
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->target->enableNotifications($targets);
|
$this->view->form = $form;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$services = $this->getParameter("services", false);
|
|
||||||
if ($services) {
|
|
||||||
$form->addCheckbox("forHosts", "Enable for hosts too?", false);
|
|
||||||
} else {
|
|
||||||
$form->addCheckbox("childHosts", "Enable notifications for ".
|
|
||||||
"child hosts too?", false);
|
|
||||||
}
|
|
||||||
$form->setServices($services);
|
|
||||||
$form->setHosts($this->getParameter("hosts"));
|
|
||||||
$form->setAction($this->view->url());
|
|
||||||
$form->addSubmitButton("Commit");
|
|
||||||
$this->view->form = $form;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function disablenotificationsAction()
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
{
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
// @TODO: Elaborate how "withChilds", "childHosts" and "forHosts" can be utilised
|
|
||||||
$form = new SendCommand("Disable notifications?");
|
|
||||||
if ($this->_request->isPost()) {
|
|
||||||
if ($form->isValid()) {
|
|
||||||
$services = $form->getServices();
|
|
||||||
$withChilds = $forHosts = $childHosts = false;
|
|
||||||
|
|
||||||
if ($services) {
|
|
||||||
$withChilds = $services === "all";
|
|
||||||
$form->addCheckbox("forHosts", "", false);
|
|
||||||
$forHosts = $form->isChecked("forHosts");
|
|
||||||
if ($withChilds) {
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts());
|
|
||||||
} else {
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts(), $services);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$form->addCheckbox("childHosts", "", false);
|
|
||||||
$childHosts = $form->isChecked("childHosts");
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts());
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->target->disableNotifications($targets);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$services = $this->getParameter("services", false);
|
|
||||||
if ($services) {
|
|
||||||
$form->addCheckbox("forHosts", "Disable for hosts too?", false);
|
|
||||||
} else {
|
|
||||||
$form->addCheckbox("childHosts", "Disable notifications for ".
|
|
||||||
"child hosts too?", false);
|
|
||||||
}
|
|
||||||
$form->setServices($services);
|
|
||||||
$form->setHosts($this->getParameter("hosts"));
|
|
||||||
$form->setAction($this->view->url());
|
|
||||||
$form->addSubmitButton("Commit");
|
|
||||||
$this->view->form = $form;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function enableeventhandlingAction()
|
|
||||||
{
|
|
||||||
$form = new SendCommand("Enable event handler?");
|
|
||||||
if ($this->_request->isPost()) {
|
|
||||||
if ($form->isValid()) {
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts(), $form->getServices());
|
|
||||||
$this->target->enableEventHandler($targets);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$form->setServices($this->getParameter("services", false));
|
|
||||||
$form->setHosts($this->getParameter("hosts"));
|
|
||||||
$form->setAction($this->view->url());
|
|
||||||
$form->addSubmitButton("Commit");
|
|
||||||
$this->view->form = $form;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function disableeventhandlingAction()
|
|
||||||
{
|
|
||||||
$form = new SendCommand("Disable event handler?");
|
|
||||||
if ($this->_request->isPost()) {
|
|
||||||
if ($form->isValid()) {
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts(), $form->getServices());
|
|
||||||
$this->target->disableEventHandler($targets);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$form->setServices($this->getParameter("services", false));
|
|
||||||
$form->setHosts($this->getParameter("hosts"));
|
|
||||||
$form->setAction($this->view->url());
|
|
||||||
$form->addSubmitButton("Commit");
|
|
||||||
$this->view->form = $form;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function enableflapdetectionAction()
|
|
||||||
{
|
|
||||||
$form = new SendCommand("Enable flap detection?");
|
|
||||||
if ($this->_request->isPost()) {
|
|
||||||
if ($form->isValid()) {
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts(), $form->getServices());
|
|
||||||
$this->target->enableFlappingDetection($targets);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$form->setServices($this->getParameter("services", false));
|
|
||||||
$form->setHosts($this->getParameter("hosts"));
|
|
||||||
$form->setAction($this->view->url());
|
|
||||||
$form->addSubmitButton("Commit");
|
|
||||||
$this->view->form = $form;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function disableflapdetectionAction()
|
|
||||||
{
|
|
||||||
$form = new SendCommand("Disable flap detection?");
|
|
||||||
if ($this->_request->isPost()) {
|
|
||||||
if ($form->isValid()) {
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts(), $form->getServices());
|
|
||||||
$this->target->disableFlappingDetection($targets);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$form->setServices($this->getParameter("services", false));
|
|
||||||
$form->setHosts($this->getParameter("hosts"));
|
|
||||||
$form->setAction($this->view->url());
|
|
||||||
$form->addSubmitButton("Commit");
|
|
||||||
$this->view->form = $form;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function enablepassivechecksAction()
|
|
||||||
{
|
|
||||||
$form = new SendCommand("Enable passive checks?");
|
|
||||||
if ($this->_request->isPost()) {
|
|
||||||
if ($form->isValid()) {
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts(), $form->getServices());
|
|
||||||
$this->target->enablePassiveChecks($targets);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$form->setServices($this->getParameter("services", false));
|
|
||||||
$form->setHosts($this->getParameter("hosts"));
|
|
||||||
$form->setAction($this->view->url());
|
|
||||||
$form->addSubmitButton("Commit");
|
|
||||||
$this->view->form = $form;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function disablepassivechecksAction()
|
|
||||||
{
|
|
||||||
$form = new SendCommand("Disable passive checks?");
|
|
||||||
if ($this->_request->isPost()) {
|
|
||||||
if ($form->isValid()) {
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts(), $form->getServices());
|
|
||||||
$this->target->disablePassiveChecks($targets);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$form->setServices($this->getParameter("services", false));
|
|
||||||
$form->setHosts($this->getParameter("hosts"));
|
|
||||||
$form->setAction($this->view->url());
|
|
||||||
$form->addSubmitButton("Commit");
|
|
||||||
$this->view->form = $form;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function startobsessingAction()
|
|
||||||
{
|
|
||||||
$form = new SendCommand("Start obsessing?");
|
|
||||||
if ($this->_request->isPost()) {
|
|
||||||
if ($form->isValid()) {
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts(), $form->getServices());
|
|
||||||
$this->target->startObsessing($targets);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$form->setServices($this->getParameter("services", false));
|
|
||||||
$form->setHosts($this->getParameter("hosts"));
|
|
||||||
$form->setAction($this->view->url());
|
|
||||||
$form->addSubmitButton("Commit");
|
|
||||||
$this->view->form = $form;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stopobsessingAction()
|
public function stopobsessingAction()
|
||||||
{
|
{
|
||||||
$form = new SendCommand("Stop obsessing?");
|
$form = new Confirmation();
|
||||||
if ($this->_request->isPost()) {
|
$form->setRequest($this->getRequest());
|
||||||
if ($form->isValid()) {
|
$form->setSubmitLabel(t('Stop obsessing'));
|
||||||
$targets = $this->selectCommandTargets($form->getHosts(), $form->getServices());
|
$form->addNote(t('Stop obsessing over this object.'));
|
||||||
$this->target->stopObsessing($targets);
|
$this->view->form = $form;
|
||||||
}
|
|
||||||
} else {
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
$form->setServices($this->getParameter("services", false));
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
$form->setHosts($this->getParameter("hosts"));
|
|
||||||
$form->setAction($this->view->url());
|
|
||||||
$form->addSubmitButton("Commit");
|
|
||||||
$this->view->form = $form;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function placeacknowledgementAction()
|
public function startobsessingAction()
|
||||||
{
|
{
|
||||||
$form = new SendCommand("Place acknowledgement?");
|
$form = new Confirmation();
|
||||||
$form->addTextBox("author", "Author (Your name):", "", true);
|
$form->setRequest($this->getRequest());
|
||||||
$form->addTextBox("comment", "Comment:", "", false, true);
|
$form->setSubmitLabel(t('Start obsessing'));
|
||||||
$form->addCheckbox("persistent", "Persistent comment:", false);
|
$form->addNote(t('Start obsessing over this object.'));
|
||||||
$form->addDatePicker("expireDate", "Expire date:", "");
|
$this->view->form = $form;
|
||||||
$form->addTimePicker("expireTime", "Expire time:", "");
|
|
||||||
$form->addCheckbox("sticky", "Sticky acknowledgement:", true);
|
|
||||||
$form->addCheckbox("notify", "Send notification:", true);
|
|
||||||
|
|
||||||
if ($this->_request->isPost()) {
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
if ($form->isValid()) {
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
$raw_time = strptime(sprintf("%s %s", $form->getDate("expireDate"),
|
|
||||||
$form->getTime("expireTime")), "%m-%d-%Y %I:%M %p");
|
|
||||||
if ($raw_time) {
|
|
||||||
$time = mktime($raw_time['tm_hour'], $raw_time['tm_min'], $raw_time['tm_sec'],
|
|
||||||
$raw_time['tm_mon'], $raw_time['tm_mday'], $raw_time['tm_year']);
|
|
||||||
} else {
|
|
||||||
$time = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
$comment = new Comment($form->getText("author"), $form->getText("comment"),
|
|
||||||
$form->isChecked("persistent"));
|
|
||||||
$acknowledgement = new Acknowledgement($comment, $form->isChecked("notify"),
|
|
||||||
$time, $form->isChecked("sticky"));
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts(), $form->getServices());
|
|
||||||
$this->target->acknowledge($targets, $acknowledgement);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$form->getElement("author")->setValue(Manager::getInstance()->getUser()->getUsername());
|
|
||||||
$form->setServices($this->getParameter("services", false));
|
|
||||||
$form->setHosts($this->getParameter("hosts"));
|
|
||||||
$form->setAction($this->view->url());
|
|
||||||
$form->addSubmitButton("Commit");
|
|
||||||
$this->view->form = $form;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteacknowledgementAction()
|
public function stopacceptingpassivechecksAction()
|
||||||
{
|
{
|
||||||
$form = new SendCommand("Remove acknowledgements?");
|
$form = new Confirmation();
|
||||||
if ($this->_request->isPost()) {
|
$form->setRequest($this->getRequest());
|
||||||
if ($form->isValid()) {
|
$form->setSubmitLabel(t('Stop accepting passive checks'));
|
||||||
$targets = $this->selectCommandTargets($form->getHosts(), $form->getServices());
|
$form->addNote(t('Passive checks for this object will be omitted.'));
|
||||||
$this->target->removeAcknowledge($targets);
|
$this->view->form = $form;
|
||||||
}
|
|
||||||
} else {
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
$form->setServices($this->getParameter("services", false));
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
$form->setHosts($this->getParameter("hosts"));
|
|
||||||
$form->setAction($this->view->url());
|
|
||||||
$form->addSubmitButton("Commit");
|
|
||||||
$this->view->form = $form;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function submitcheckresultAction()
|
public function startacceptingpassivechecksAction()
|
||||||
{
|
{
|
||||||
// @TODO: How should the "perfdata" be handled? (The interface function does not accept it)
|
$form = new Confirmation();
|
||||||
$form = new SendCommand("Submit passive check result");
|
$form->setRequest($this->getRequest());
|
||||||
$form->addChoice("state", "Check result:", array("UP", "DOWN", "UNREACHABLE"));
|
$form->setSubmitLabel(t('Start accepting passive checks'));
|
||||||
$form->addTextBox("output", "Check output:", "", false, true);
|
$form->addNote(t('Passive checks for this object will be accepted.'));
|
||||||
$form->addTextBox("perfdata", "Performance data:", "", false, true);
|
$this->view->form = $form;
|
||||||
|
|
||||||
if ($this->_request->isPost()) {
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
if ($form->isValid()) {
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
$targets = $this->selectCommandTargets($form->getHosts(), $form->getServices());
|
}
|
||||||
$this->target->submitCheckResult($targets, $form->getChoice("state"),
|
}
|
||||||
$form->getText("output"));
|
|
||||||
}
|
public function disablenotificationsAction()
|
||||||
} else {
|
{
|
||||||
$form->setServices($this->getParameter("services", false));
|
$form = new Confirmation();
|
||||||
$form->setHosts($this->getParameter("hosts"));
|
$form->setRequest($this->getRequest());
|
||||||
$form->setAction($this->view->url());
|
$form->setSubmitLabel(t('Disable notifications'));
|
||||||
$form->addSubmitButton("Commit");
|
$form->addNote(t('Notifications for this object will be disabled.'));
|
||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
|
|
||||||
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function enablenotificationsAction()
|
||||||
|
{
|
||||||
|
$form = new Confirmation();
|
||||||
|
$form->setRequest($this->getRequest());
|
||||||
|
$form->setSubmitLabel(t('Enable notifications'));
|
||||||
|
$form->addNote(t('Notifications for this object will be enabled.'));
|
||||||
|
$this->view->form = $form;
|
||||||
|
|
||||||
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendcustomnotificationAction()
|
public function sendcustomnotificationAction()
|
||||||
{
|
{
|
||||||
$form = new SendCommand("Send custom notification");
|
$form = new CustomNotification();
|
||||||
$form->addTextBox("author", "Author (Your name):", "", true);
|
$form->setRequest($this->getRequest());
|
||||||
$form->addTextBox("comment", "Comment:", "", false, true);
|
$this->view->form = $form;
|
||||||
$form->addCheckbox("force", "Forced:", false);
|
|
||||||
$form->addCheckbox("broadcast", "Broadcast:", false);
|
|
||||||
|
|
||||||
if ($this->_request->isPost()) {
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
if ($form->isValid()) {
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
$comment = new Comment($form->getText("author"), $form->getText("comment"));
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts(), $form->getServices());
|
|
||||||
|
|
||||||
if ($form->isChecked("force")) {
|
|
||||||
$this->target->sendForcedCustomNotification($targets, $comment,
|
|
||||||
$form->isChecked("broadcast"));
|
|
||||||
} else {
|
|
||||||
$this->target->sendCustomNotification($targets, $comment,
|
|
||||||
$form->isChecked("broadcast"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$form->getElement("author")->setValue(Manager::getInstance()->getUser()->getUsername());
|
|
||||||
$form->setServices($this->getParameter("services", false));
|
|
||||||
$form->setHosts($this->getParameter("hosts"));
|
|
||||||
$form->setAction($this->view->url());
|
|
||||||
$form->addSubmitButton("Commit");
|
|
||||||
$this->view->form = $form;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delaynotificationAction()
|
public function scheduledowntimeAction()
|
||||||
{
|
{
|
||||||
$form = new SendCommand("Delay a notification");
|
|
||||||
$form->addNumberBox("delay", "Notification delay (minutes from now):");
|
|
||||||
|
|
||||||
if ($this->_request->isPost()) {
|
}
|
||||||
if ($form->isValid()) {
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts(), $form->getServices());
|
public function scheduledowntimeswithchildrenAction()
|
||||||
$this->target->delayNotification($targets, $form->getNumber("delay"));
|
{
|
||||||
}
|
|
||||||
} else {
|
}
|
||||||
$form->setServices($this->getParameter("services", false));
|
|
||||||
$form->setHosts($this->getParameter("hosts"));
|
public function removedowntimeswithchildrenAction()
|
||||||
$form->setAction($this->view->url());
|
{
|
||||||
$form->addSubmitButton("Commit");
|
$form = new Confirmation();
|
||||||
$this->view->form = $form;
|
$form->setRequest($this->getRequest());
|
||||||
|
$form->setSubmitLabel(t('Remove downtime(s)'));
|
||||||
|
$form->addNote(t('Remove downtime(s) from this host and its services.'));
|
||||||
|
$this->view->form = $form;
|
||||||
|
|
||||||
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function disablenotificationswithchildrenAction()
|
||||||
|
{
|
||||||
|
$form = new Confirmation();
|
||||||
|
$form->setRequest($this->getRequest());
|
||||||
|
$form->setSubmitLabel(t('Disable notifications'));
|
||||||
|
$form->addNote(t('Notifications for this host and its services will be disabled.'));
|
||||||
|
$this->view->form = $form;
|
||||||
|
|
||||||
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function enablenotificationswithchildrenAction()
|
||||||
|
{
|
||||||
|
$form = new Confirmation();
|
||||||
|
$form->setRequest($this->getRequest());
|
||||||
|
$form->setSubmitLabel(t('Enable notifications'));
|
||||||
|
$form->addNote(t('Notifications for this host and its services will be enabled.'));
|
||||||
|
$this->view->form = $form;
|
||||||
|
|
||||||
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function reschedulenextcheckwithchildrenAction()
|
||||||
|
{
|
||||||
|
$form = new RescheduleNextCheck();
|
||||||
|
$form->setRequest($this->getRequest());
|
||||||
|
|
||||||
|
$form->setWithChildred(true);
|
||||||
|
|
||||||
|
$this->view->form = $form;
|
||||||
|
|
||||||
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function disableactivecheckswithchildrenAction()
|
||||||
|
{
|
||||||
|
$form = new Confirmation();
|
||||||
|
$form->setRequest($this->getRequest());
|
||||||
|
$form->setSubmitLabel(t('Disable active checks'));
|
||||||
|
$form->addNote(t('Disable active checks for this host and its services.'));
|
||||||
|
$this->view->form = $form;
|
||||||
|
|
||||||
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function enableactivecheckswithchildrenAction()
|
||||||
|
{
|
||||||
|
$form = new Confirmation();
|
||||||
|
$form->setRequest($this->getRequest());
|
||||||
|
$form->setSubmitLabel(t('Enable active checks'));
|
||||||
|
$form->addNote(t('Enable active checks for this host and its services.'));
|
||||||
|
$this->view->form = $form;
|
||||||
|
|
||||||
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function disableeventhandlerAction()
|
||||||
|
{
|
||||||
|
$form = new Confirmation();
|
||||||
|
$form->setRequest($this->getRequest());
|
||||||
|
$form->setSubmitLabel(t('Disable event handler'));
|
||||||
|
$form->addNote(t('Disable event handler for this object.'));
|
||||||
|
$this->view->form = $form;
|
||||||
|
|
||||||
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function enableeventhandlerAction()
|
||||||
|
{
|
||||||
|
$form = new Confirmation();
|
||||||
|
$form->setRequest($this->getRequest());
|
||||||
|
$form->setSubmitLabel(t('Enable event handler'));
|
||||||
|
$form->addNote(t('Enable event handler for this object.'));
|
||||||
|
$this->view->form = $form;
|
||||||
|
|
||||||
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function disableflapdetectionAction()
|
||||||
|
{
|
||||||
|
$form = new Confirmation();
|
||||||
|
$form->setRequest($this->getRequest());
|
||||||
|
$form->setSubmitLabel(t('Disable flapping detection'));
|
||||||
|
$form->addNote(t('Disable flapping detection for this object.'));
|
||||||
|
$this->view->form = $form;
|
||||||
|
|
||||||
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function enableflapdetectionAction()
|
||||||
|
{
|
||||||
|
$form = new Confirmation();
|
||||||
|
$form->setRequest($this->getRequest());
|
||||||
|
$form->setSubmitLabel(t('Enable flapping detection'));
|
||||||
|
$form->addNote(t('Enable flapping detection for this object.'));
|
||||||
|
$this->view->form = $form;
|
||||||
|
|
||||||
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addcommentAction()
|
public function addcommentAction()
|
||||||
{
|
{
|
||||||
$form = new SendCommand("Add comment");
|
$form = new CommentForm();
|
||||||
$form->addTextBox("author", "Author (Your name):", "", true);
|
$form->setRequest($this->getRequest());
|
||||||
$form->addTextBox("comment", "Comment:", "", false, true);
|
|
||||||
$form->addCheckbox("persistent", "Persistent:", false);
|
|
||||||
|
|
||||||
if ($this->_request->isPost()) {
|
$this->view->form = $form;
|
||||||
if ($form->isValid()) {
|
|
||||||
$comment = new Comment($form->getText("author"), $form->getText("comment"),
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
$form->isChecked("persistent"));
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
$targets = $this->selectCommandTargets($form->getHosts(), $form->getServices());
|
|
||||||
$this->target->addComment($targets, $comment);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$form->getElement("author")->setValue(Manager::getInstance()->getUser()->getUsername());
|
|
||||||
$form->setServices($this->getParameter("services", false));
|
|
||||||
$form->setHosts($this->getParameter("hosts"));
|
|
||||||
$form->setAction($this->view->url());
|
|
||||||
$form->addSubmitButton("Commit");
|
|
||||||
$this->view->form = $form;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deletecommentAction()
|
public function resetattributesAction()
|
||||||
{
|
{
|
||||||
$form = new SendCommand("Delete comment");
|
$form = new Confirmation();
|
||||||
// @TODO: How should this form look like?
|
$form->setRequest($this->getRequest());
|
||||||
|
$form->setSubmitLabel(t('Reset attributes'));
|
||||||
|
$form->addNote(t('Reset modified attributes to its default.'));
|
||||||
|
$this->view->form = $form;
|
||||||
|
|
||||||
if ($this->_request->isPost()) {
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
if ($form->isValid()) {
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
$comments = $form->getValue("comments");
|
|
||||||
if ($comments) {
|
|
||||||
// @TODO: Which data structure should be used to transmit comment details?
|
|
||||||
$this->target->removeComment($comments);
|
|
||||||
} else {
|
|
||||||
$targets = $this->selectCommandTargets($form->getHosts(), $form->getServices());
|
|
||||||
$this->target->removeComment($targets);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$comments = $this->getParameter("comments", false);
|
|
||||||
if ($comments) {
|
|
||||||
// @TODO: Which data structure should be used to transmit comment details?
|
|
||||||
} else {
|
|
||||||
$form->setServices($this->getParameter("services", false));
|
|
||||||
$form->setHosts($this->getParameter("hosts"));
|
|
||||||
}
|
|
||||||
|
|
||||||
$form->setAction($this->view->url());
|
|
||||||
$form->addSubmitButton("Commit");
|
|
||||||
$this->view->form = $form;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendDeletecomment()
|
public function acknowledgeproblemAction()
|
||||||
{
|
{
|
||||||
if ($this->_request->getPost("comments")) {
|
$form = new Acknowledge();
|
||||||
$comments = array();
|
$form->setRequest($this->getRequest());
|
||||||
foreach ($this->_request->getPost("comments") as $id => $content) {
|
|
||||||
$comment = new StdClass();
|
$this->view->form = $form;
|
||||||
$comment->comment_id = $id;
|
|
||||||
$value = explode(";", $content, 2);
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
$comment->host_name = $value[0];
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
if (isset($value[1])) {
|
|
||||||
$comment->service_description = $value[1];
|
|
||||||
}
|
|
||||||
$comments[] = $comment;
|
|
||||||
}
|
|
||||||
$this->target->removeComment($comments);
|
|
||||||
} else {
|
|
||||||
$this->target->removeComment($this->selectCommandTargets());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendDeletedowntime()
|
public function removeacknowledgementAction()
|
||||||
{
|
{
|
||||||
if ($this->_request->getPost("downtimes")) {
|
$form = new Confirmation();
|
||||||
$downtimes = array();
|
$form->setRequest($this->getRequest());
|
||||||
foreach ($this->_request->getPost("comments") as $id => $content) {
|
$form->setSubmitLabel(t('Remove problem acknowledgement'));
|
||||||
$downtime = new StdClass();
|
$form->addNote(t('Remove problem acknowledgement for this object.'));
|
||||||
$downtime->downtime_id = $id;
|
$this->view->form = $form;
|
||||||
$value = explode(";", $content, 2);
|
|
||||||
$downtime->host_name = $value[0];
|
if ($form->isValid($this->getRequest()) && $this->getRequest()->isPost()) {
|
||||||
if (isset($value[1])) {
|
throw new \Icinga\Exception\ProgrammingError('Command sender not implemented: '. __FUNCTION__);
|
||||||
$downtime->service_description = $value[1];
|
|
||||||
}
|
|
||||||
$downtimes[] = $downtime;
|
|
||||||
}
|
|
||||||
$this->target->removeDowntime($downtimes);
|
|
||||||
} else {
|
|
||||||
$this->target->removeDowntime($this->selectCommandTargets());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delaynotificationAction()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removedowntimeAction()
|
||||||
|
{
|
||||||
|
// DOWNTIME ID
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
202
modules/monitoring/application/forms/Command/AbstractCommand.php
Normal file
202
modules/monitoring/application/forms/Command/AbstractCommand.php
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Monitoring\Form\Command;
|
||||||
|
|
||||||
|
use Icinga\Web\Form;
|
||||||
|
use Icinga\Web\Form\Element\Note;
|
||||||
|
use Zend_Form_Element_Hidden;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AbstractCommand
|
||||||
|
*/
|
||||||
|
abstract class AbstractCommand extends Form
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Label for submit button
|
||||||
|
*
|
||||||
|
* If omitted, no button will be shown.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $submitLabel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Label for cancel button
|
||||||
|
*
|
||||||
|
* If omitted, no button will be shown.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $cancelLabel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of messages
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
private $notes = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for cancel label
|
||||||
|
* @param string $cancelLabel
|
||||||
|
*/
|
||||||
|
public function setCancelLabel($cancelLabel)
|
||||||
|
{
|
||||||
|
$this->cancelLabel = $cancelLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for cancel label
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCancelLabel()
|
||||||
|
{
|
||||||
|
return $this->cancelLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for submit label
|
||||||
|
* @param string $submitLabel
|
||||||
|
*/
|
||||||
|
public function setSubmitLabel($submitLabel)
|
||||||
|
{
|
||||||
|
$this->submitLabel = $submitLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for submit label
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getSubmitLabel()
|
||||||
|
{
|
||||||
|
return $this->submitLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add message to stack
|
||||||
|
* @param string $message
|
||||||
|
*/
|
||||||
|
public function addNote($message)
|
||||||
|
{
|
||||||
|
$this->notes[] = $message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purge messages from stack
|
||||||
|
*/
|
||||||
|
public function purgeNotes()
|
||||||
|
{
|
||||||
|
$this->notes = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for notes
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function getNotes()
|
||||||
|
{
|
||||||
|
return $this->notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add elements to this form (used by extending classes)
|
||||||
|
*/
|
||||||
|
protected function create()
|
||||||
|
{
|
||||||
|
if (count($this->getNotes())) {
|
||||||
|
foreach ($this->getNotes() as $nodeid => $note) {
|
||||||
|
$element = new Note(
|
||||||
|
array(
|
||||||
|
'name' => 'note_'. $nodeid,
|
||||||
|
'value' => $note
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->addElement($element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->getCancelLabel()) {
|
||||||
|
$cancelLabel = new \Zend_Form_Element_Reset(
|
||||||
|
array(
|
||||||
|
'name' => 'reset',
|
||||||
|
'label' => $this->getCancelLabel(),
|
||||||
|
'class' => 'btn pull-right'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->addElement($cancelLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->getSubmitLabel()) {
|
||||||
|
$submitButton = new \Zend_Form_Element_Submit(
|
||||||
|
array(
|
||||||
|
'name' => 'submit',
|
||||||
|
'label' => $this->getSubmitLabel(),
|
||||||
|
'class' => 'btn btn-primary pull-right'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->addElement($submitButton);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the author name
|
||||||
|
* TODO(mh): This should work on the request, at present it's fix
|
||||||
|
*/
|
||||||
|
protected function getAuthorName()
|
||||||
|
{
|
||||||
|
return 'Iwan IV. Wassiljewitsch, der Schreckliche';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creator for author field
|
||||||
|
* @return Zend_Form_Element_Hidden
|
||||||
|
*/
|
||||||
|
protected function createAuthorField()
|
||||||
|
{
|
||||||
|
$authorName = $this->getAuthorName();
|
||||||
|
|
||||||
|
$authorField = new Zend_Form_Element_Hidden(
|
||||||
|
array(
|
||||||
|
'name' => 'author',
|
||||||
|
'value' => $authorName,
|
||||||
|
'label' => t('Author name')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$authorField->addDecorator(
|
||||||
|
'Callback',
|
||||||
|
array(
|
||||||
|
'callback' => function () use ($authorName) {
|
||||||
|
return sprintf('<strong>%s</strong>', $authorName);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return $authorField;
|
||||||
|
}
|
||||||
|
}
|
85
modules/monitoring/application/forms/Command/Acknowledge.php
Normal file
85
modules/monitoring/application/forms/Command/Acknowledge.php
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Monitoring\Form\Command;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form for acknowledge commands
|
||||||
|
*/
|
||||||
|
class Acknowledge extends AbstractCommand
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Interface method to build the form
|
||||||
|
* @see Form::create()
|
||||||
|
*/
|
||||||
|
protected function create()
|
||||||
|
{
|
||||||
|
$this->addElement($this->createAuthorField());
|
||||||
|
|
||||||
|
$this->addElement(
|
||||||
|
'textarea',
|
||||||
|
'comment',
|
||||||
|
array(
|
||||||
|
'label' => t('Comment'),
|
||||||
|
'rows' => 4
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->addElement(
|
||||||
|
'checkbox',
|
||||||
|
'persistent',
|
||||||
|
array(
|
||||||
|
'label' => t('Persistent comment'),
|
||||||
|
'value' => false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->addElement(
|
||||||
|
'checkbox',
|
||||||
|
'sticky',
|
||||||
|
array(
|
||||||
|
'label' => t('Sticky acknowledgement'),
|
||||||
|
'value' => false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->addElement(
|
||||||
|
'checkbox',
|
||||||
|
'notify',
|
||||||
|
array(
|
||||||
|
'label' => t('Send notification'),
|
||||||
|
'value' => false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->setSubmitLabel(t('Acknowledge problem'));
|
||||||
|
|
||||||
|
parent::create();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
63
modules/monitoring/application/forms/Command/Comment.php
Normal file
63
modules/monitoring/application/forms/Command/Comment.php
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Monitoring\Form\Command;
|
||||||
|
|
||||||
|
class Comment extends AbstractCommand
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Interface method to build the form
|
||||||
|
* @see Form::create()
|
||||||
|
*/
|
||||||
|
protected function create()
|
||||||
|
{
|
||||||
|
$this->addElement($this->createAuthorField());
|
||||||
|
|
||||||
|
$this->addElement(
|
||||||
|
'textarea',
|
||||||
|
'comment',
|
||||||
|
array(
|
||||||
|
'label' => t('Comment'),
|
||||||
|
'rows' => 4
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->addElement(
|
||||||
|
'checkbox',
|
||||||
|
'persistent',
|
||||||
|
array(
|
||||||
|
'label' => t('Persistent'),
|
||||||
|
'value' => false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->setSubmitLabel(t('Post comment'));
|
||||||
|
|
||||||
|
parent::create();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Monitoring\Form\Command;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple confirmation form
|
||||||
|
*
|
||||||
|
* Exist to make the abstract form concrete.
|
||||||
|
*/
|
||||||
|
class Confirmation extends AbstractCommand
|
||||||
|
{
|
||||||
|
}
|
@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Monitoring\Form\Command;
|
||||||
|
|
||||||
|
use Zend_Form_Element_Hidden;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For for command CustomNotification
|
||||||
|
*/
|
||||||
|
class CustomNotification extends AbstractCommand
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Interface method to build the form
|
||||||
|
* @see Form::create()
|
||||||
|
*/
|
||||||
|
protected function create()
|
||||||
|
{
|
||||||
|
$this->addElement($this->createAuthorField());
|
||||||
|
|
||||||
|
$this->addElement(
|
||||||
|
'textarea',
|
||||||
|
'comment',
|
||||||
|
array(
|
||||||
|
'label' => t('Comment'),
|
||||||
|
'rows' => 4
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->addElement(
|
||||||
|
'checkbox',
|
||||||
|
'force',
|
||||||
|
array(
|
||||||
|
'label' => t('Forced')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->addElement(
|
||||||
|
'checkbox',
|
||||||
|
'broadcast',
|
||||||
|
array(
|
||||||
|
'label' => t('Broadcast')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->setSubmitLabel(t('Send custom notification'));
|
||||||
|
|
||||||
|
parent::create();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,100 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Monitoring\Form\Command;
|
||||||
|
|
||||||
|
use Icinga\Web\Form\Element\DateTime;
|
||||||
|
use Zend_Form_Element_Checkbox;
|
||||||
|
use DateTime as PhpDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form for RescheduleNextCheck
|
||||||
|
*/
|
||||||
|
class RescheduleNextCheck extends AbstractCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
private $withChildren = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for withChildren
|
||||||
|
* @param bool $flag
|
||||||
|
*/
|
||||||
|
public function setWithChildred($flag = true)
|
||||||
|
{
|
||||||
|
$this->withChildren = $flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for withChildren
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function getWithChildren()
|
||||||
|
{
|
||||||
|
return $this->withChildren;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface method to build the form
|
||||||
|
* @see Form::create()
|
||||||
|
*/
|
||||||
|
protected function create()
|
||||||
|
{
|
||||||
|
|
||||||
|
$now = new PhpDateTime();
|
||||||
|
|
||||||
|
$dateElement = new DateTime(
|
||||||
|
array(
|
||||||
|
'name' => 'checktime',
|
||||||
|
'label' => t('Check time'),
|
||||||
|
'value' => $now->format('Y-m-d H:i:s')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->addElement($dateElement);
|
||||||
|
|
||||||
|
$checkBox = new Zend_Form_Element_Checkbox(
|
||||||
|
array(
|
||||||
|
'name' => 'forcecheck',
|
||||||
|
'label' => t('Force check'),
|
||||||
|
'value' => true
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->addElement($checkBox);
|
||||||
|
|
||||||
|
if ($this->getWithChildren() === true) {
|
||||||
|
$this->addNote(t('Reschedule next check for this host and its services.'));
|
||||||
|
} else {
|
||||||
|
$this->addNote(t('Reschedule next check for this object.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->setSubmitLabel(t('Reschedule check'));
|
||||||
|
|
||||||
|
parent::create();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,151 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga 2 Web.
|
||||||
|
*
|
||||||
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2013 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Monitoring\Form\Command;
|
||||||
|
|
||||||
|
use Icinga\Exception\ProgrammingError;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form for command SubmitPassiveCheckResult
|
||||||
|
*/
|
||||||
|
class SubmitPassiveCheckResult extends AbstractCommand
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Type constant for host form
|
||||||
|
*/
|
||||||
|
const TYPE_HOST = 'host';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type constant for service form
|
||||||
|
*/
|
||||||
|
const TYPE_SERVICE = 'service';
|
||||||
|
|
||||||
|
private static $options = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of form
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup plugin states
|
||||||
|
*/
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
if (!count(self::$options)) {
|
||||||
|
self::$options = array(
|
||||||
|
self::TYPE_HOST => array(
|
||||||
|
0 => t('UP'),
|
||||||
|
1 => t('DOWN'),
|
||||||
|
2 => t('UNREACHABLE')
|
||||||
|
),
|
||||||
|
self::TYPE_SERVICE => array(
|
||||||
|
0 => t('OK'),
|
||||||
|
1 => t('WARNING'),
|
||||||
|
2 => t('CRITICAL'),
|
||||||
|
3 => t('UNKNOWN')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for type
|
||||||
|
* @param string $type
|
||||||
|
*/
|
||||||
|
public function setType($type)
|
||||||
|
{
|
||||||
|
$this->type = $type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for type
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getType()
|
||||||
|
{
|
||||||
|
return $this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return array of options
|
||||||
|
* @return array
|
||||||
|
* @throws \Icinga\Exception\ProgrammingError
|
||||||
|
*/
|
||||||
|
private function getOptions()
|
||||||
|
{
|
||||||
|
if (in_array($this->getType(), array(self::TYPE_HOST, self::TYPE_SERVICE)) === false) {
|
||||||
|
throw new ProgrammingError('Type is not valid');
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$options[$this->getType()];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface method to build the form
|
||||||
|
* @see Form::create()
|
||||||
|
*/
|
||||||
|
protected function create()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->addElement(
|
||||||
|
'select',
|
||||||
|
'pluginstate',
|
||||||
|
array(
|
||||||
|
'label' => t('Plugin state'),
|
||||||
|
'multiOptions' => $this->getOptions()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->addElement(
|
||||||
|
'textarea',
|
||||||
|
'checkoutput',
|
||||||
|
array(
|
||||||
|
'label' => t('Check output'),
|
||||||
|
'rows' => 2
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->addElement(
|
||||||
|
'textarea',
|
||||||
|
'performancedata',
|
||||||
|
array(
|
||||||
|
'label' => t('Performance data'),
|
||||||
|
'rows' => 2
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->setSubmitLabel(t('Submit passive check result'));
|
||||||
|
|
||||||
|
parent::create();
|
||||||
|
}
|
||||||
|
}
|
@ -1 +0,0 @@
|
|||||||
<?= $this->form ?>
|
|
@ -1 +0,0 @@
|
|||||||
<?= $this->form ?>
|
|
@ -1 +0,0 @@
|
|||||||
<?= $this->form ?>
|
|
@ -1 +0,0 @@
|
|||||||
<?= $this->form ?>
|
|
@ -1 +0,0 @@
|
|||||||
<?= $this->form ?>
|
|
@ -1 +0,0 @@
|
|||||||
<?= $this->form ?>
|
|
@ -1 +0,0 @@
|
|||||||
<?= $this->form ?>
|
|
@ -1 +0,0 @@
|
|||||||
<?= $this->form ?>
|
|
@ -1 +0,0 @@
|
|||||||
<?= $this->form ?>
|
|
@ -1 +0,0 @@
|
|||||||
<?= $this->form ?>
|
|
@ -1 +0,0 @@
|
|||||||
<?= $this->form ?>
|
|
@ -1 +0,0 @@
|
|||||||
<?= $this->form ?>
|
|
@ -1 +0,0 @@
|
|||||||
<?= $this->form ?>
|
|
@ -1 +0,0 @@
|
|||||||
<?= $this->form ?>
|
|
@ -1 +0,0 @@
|
|||||||
<?= $this->form ?>
|
|
@ -0,0 +1,4 @@
|
|||||||
|
<div style="border: 1px #cc0000 solid; padding: 5px; margin: 10px 0 0 10px; max-width: 600px;">
|
||||||
|
<?= $this->form; ?>
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
</div>
|
@ -1 +0,0 @@
|
|||||||
<?= $this->form ?>
|
|
@ -1 +0,0 @@
|
|||||||
<?= $this->form ?>
|
|
@ -1 +0,0 @@
|
|||||||
<?= $this->form ?>
|
|
@ -1 +0,0 @@
|
|||||||
<?= $this->form ?>
|
|
@ -1 +0,0 @@
|
|||||||
<?= $this->form ?>
|
|
@ -1 +0,0 @@
|
|||||||
<?= $this->form ?>
|
|
Loading…
x
Reference in New Issue
Block a user