2013-06-03 16:56:08 +02:00
|
|
|
<?php
|
2013-06-06 16:52:54 +02:00
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
2013-06-28 16:47:30 +02:00
|
|
|
/**
|
|
|
|
* 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>
|
|
|
|
*/
|
2013-06-06 16:52:54 +02:00
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
|
2013-06-03 16:56:08 +02:00
|
|
|
namespace Icinga\Protocol\Commandpipe;
|
2013-06-06 16:52:54 +02:00
|
|
|
|
2013-06-03 16:56:08 +02:00
|
|
|
use Icinga\Application\Logger as IcingaLogger;
|
2013-06-06 16:52:54 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class CommandPipe
|
|
|
|
* @package Icinga\Protocol\Commandpipe
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
class CommandPipe
|
|
|
|
{
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @var mixed
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
private $path;
|
2013-06-07 13:29:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var mixed
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
private $name;
|
2013-06-07 13:29:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var bool|mixed
|
|
|
|
*/
|
2013-06-06 16:52:54 +02:00
|
|
|
private $user = false;
|
2013-06-07 13:29:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var bool|mixed
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
private $host = false;
|
2013-06-07 13:29:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var int|mixed
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
private $port = 22;
|
2013-06-07 13:29:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public $fopen_mode = "w";
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
const TYPE_HOST = "HOST";
|
2013-06-07 13:29:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
const TYPE_SERVICE = "SVC";
|
2013-06-07 13:29:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
const TYPE_HOSTGROUP = "HOSTGROUP";
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
const TYPE_SERVICEGROUP = "SERVICEGROUP";
|
2013-06-03 16:56:08 +02:00
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param \Zend_Config $config
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function __construct(\Zend_Config $config)
|
|
|
|
{
|
|
|
|
$this->path = $config->path;
|
|
|
|
$this->name = $config->name;
|
2013-06-06 16:52:54 +02:00
|
|
|
if (isset($config->host)) {
|
2013-06-03 16:56:08 +02:00
|
|
|
$this->host = $config->host;
|
|
|
|
}
|
2013-06-06 16:52:54 +02:00
|
|
|
if (isset($config->port)) {
|
2013-06-03 16:56:08 +02:00
|
|
|
$this->port = $config->port;
|
|
|
|
}
|
2013-06-06 16:52:54 +02:00
|
|
|
if (isset($config->user)) {
|
2013-06-03 16:56:08 +02:00
|
|
|
$this->user = $config->user;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $command
|
|
|
|
* @throws \RuntimeException
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function send($command)
|
|
|
|
{
|
2013-06-06 16:52:54 +02:00
|
|
|
if (!$this->host) {
|
|
|
|
IcingaLogger::debug(
|
|
|
|
"Attempting to send external icinga command $command to local command file {$this->path}"
|
|
|
|
);
|
2013-06-03 16:56:08 +02:00
|
|
|
$file = @fopen($this->path, $this->fopen_mode);
|
2013-06-06 16:52:54 +02:00
|
|
|
if (!$file) {
|
|
|
|
throw new \RuntimeException("Could not open icinga pipe at $file : " . print_r(error_get_last(), true));
|
|
|
|
}
|
|
|
|
fwrite($file, "[" . time() . "] " . $command . PHP_EOL);
|
|
|
|
IcingaLogger::debug('Writing [' . time() . '] ' . $command . PHP_EOL);
|
2013-06-03 16:56:08 +02:00
|
|
|
fclose($file);
|
|
|
|
} else {
|
|
|
|
// send over ssh
|
|
|
|
$retCode = 0;
|
|
|
|
$output = array();
|
2013-06-06 16:52:54 +02:00
|
|
|
IcingaLogger::debug(
|
|
|
|
'Icinga instance is on different host, attempting to send command %s via ssh to %s:%s/%s',
|
|
|
|
$command,
|
|
|
|
$this->host,
|
|
|
|
$this->port,
|
|
|
|
$this->path
|
|
|
|
);
|
|
|
|
$hostConnector = $this->user ? $this->user . "@" . $this->host : $this->host;
|
|
|
|
exec(
|
|
|
|
"ssh $hostConnector -p{$this->port} \"echo '[" . time() . "] "
|
|
|
|
. escapeshellcmd(
|
|
|
|
$command
|
|
|
|
)
|
|
|
|
. "' > {$this->path}\"",
|
|
|
|
$output,
|
|
|
|
$retCode
|
|
|
|
);
|
|
|
|
IcingaLogger::debug(
|
|
|
|
"$:ssh $hostConnector -p{$this->port} \"echo '[" . time() . "] " . escapeshellcmd(
|
|
|
|
$command
|
|
|
|
) . "' > {$this->path}\""
|
|
|
|
);
|
2013-06-03 16:56:08 +02:00
|
|
|
IcingaLogger::debug("Code code %s: %s ", $retCode, $output);
|
|
|
|
|
2013-06-06 16:52:54 +02:00
|
|
|
if ($retCode != 0) {
|
|
|
|
throw new \RuntimeException(
|
|
|
|
'Could not send command to remote icinga host: '
|
|
|
|
. implode(
|
|
|
|
"\n",
|
|
|
|
$output
|
|
|
|
)
|
|
|
|
. " (returncode $retCode)"
|
|
|
|
);
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objects
|
|
|
|
* @param IComment $acknowledgementOrComment
|
|
|
|
*/
|
2013-06-06 16:52:54 +02:00
|
|
|
public function acknowledge($objects, IComment $acknowledgementOrComment)
|
|
|
|
{
|
|
|
|
if (is_a($acknowledgementOrComment, 'Icinga\Protocol\Commandpipe\Comment')) {
|
2013-06-03 16:56:08 +02:00
|
|
|
$acknowledgementOrComment = new Acknowledgement($acknowledgementOrComment);
|
2013-06-06 16:52:54 +02:00
|
|
|
}
|
2013-06-03 16:56:08 +02:00
|
|
|
|
|
|
|
foreach ($objects as $object) {
|
|
|
|
if (isset($object->service_description)) {
|
|
|
|
$format = $acknowledgementOrComment->getFormatString(self::TYPE_SERVICE);
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->send(sprintf($format, $object->host_name, $object->service_description));
|
2013-06-03 16:56:08 +02:00
|
|
|
} else {
|
|
|
|
$format = $acknowledgementOrComment->getFormatString(self::TYPE_HOST);
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->send(sprintf($format, $object->host_name));
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objects
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function removeAcknowledge($objects)
|
|
|
|
{
|
|
|
|
foreach ($objects as $object) {
|
|
|
|
if (isset($object->service_description)) {
|
|
|
|
$this->send("REMOVE_SVC_ACKNOWLEDGEMENT;$object->host_name;$object->service_description");
|
|
|
|
} else {
|
|
|
|
$this->send("REMOVE_HOST_ACKNOWLEDGEMENT;$object->host_name");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objects
|
|
|
|
* @param $state
|
|
|
|
* @param $output
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function submitCheckResult($objects, $state, $output)
|
|
|
|
{
|
|
|
|
foreach ($objects as $object) {
|
|
|
|
if (isset($object->service_description)) {
|
|
|
|
$this->send("PROCESS_SVC_CHECK_RESULT;$object->host_name;$object->service_description;$state;$output");
|
|
|
|
} else {
|
|
|
|
$this->send("PROCESS_HOST_CHECK_RESULT;$object->host_name;$state;$output");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objects
|
|
|
|
* @param bool $time
|
|
|
|
* @param bool $withChilds
|
|
|
|
*/
|
2013-06-06 16:52:54 +02:00
|
|
|
public function scheduleForcedCheck($objects, $time = false, $withChilds = false)
|
|
|
|
{
|
|
|
|
if (!$time) {
|
2013-06-03 16:56:08 +02:00
|
|
|
$time = time();
|
2013-06-06 16:52:54 +02:00
|
|
|
}
|
2013-06-03 16:56:08 +02:00
|
|
|
$base = "SCHEDULE_FORCED_";
|
|
|
|
foreach ($objects as $object) {
|
|
|
|
if (isset($object->service_description)) {
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->send($base . "SVC_CHECK;$object->host_name;$object->service_description;$time");
|
2013-06-03 16:56:08 +02:00
|
|
|
} else {
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->send($base . 'HOST_' . ($withChilds ? 'SVC_CHECKS' : 'CHECK') . ";$object->host_name;$time");
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objects
|
|
|
|
* @param bool $time
|
|
|
|
* @param bool $withChilds
|
|
|
|
*/
|
2013-06-06 16:52:54 +02:00
|
|
|
public function scheduleCheck($objects, $time = false, $withChilds = false)
|
|
|
|
{
|
|
|
|
if (!$time) {
|
2013-06-03 16:56:08 +02:00
|
|
|
$time = time();
|
2013-06-06 16:52:54 +02:00
|
|
|
}
|
2013-06-03 16:56:08 +02:00
|
|
|
$base = "SCHEDULE_";
|
|
|
|
foreach ($objects as $object) {
|
|
|
|
if (isset($object->service_description)) {
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->send($base . "SVC_CHECK;$object->host_name;$object->service_description;$time");
|
2013-06-03 16:56:08 +02:00
|
|
|
} else {
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->send($base . 'HOST_' . ($withChilds ? 'SVC_CHECKS' : 'CHECK') . ";$object->host_name;$time");
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param array $objects
|
|
|
|
* @param Comment $comment
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function addComment(array $objects, Comment $comment)
|
|
|
|
{
|
|
|
|
foreach ($objects as $object) {
|
|
|
|
if (isset($object->service_description)) {
|
|
|
|
$format = $comment->getFormatString(self::TYPE_SERVICE);
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->send(sprintf($format, $object->host_name, $object->service_description));
|
2013-06-03 16:56:08 +02:00
|
|
|
} else {
|
|
|
|
$format = $comment->getFormatString(self::TYPE_HOST);
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->send(sprintf($format, $object->host_name));
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objectsOrComments
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function removeComment($objectsOrComments)
|
|
|
|
{
|
|
|
|
foreach ($objectsOrComments as $object) {
|
|
|
|
if (isset($object->comment_id)) {
|
|
|
|
if (isset($object->service_description)) {
|
|
|
|
$type = "SERVICE_COMMENT";
|
|
|
|
} else {
|
|
|
|
$type = "HOST_COMMENT";
|
|
|
|
}
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->send("DEL_{$type};" . intval($object->comment_id));
|
2013-06-03 16:56:08 +02:00
|
|
|
} else {
|
|
|
|
if (isset($object->service_description)) {
|
|
|
|
$type = "SERVICE_COMMENT";
|
|
|
|
} else {
|
|
|
|
$type = "HOST_COMMENT";
|
|
|
|
}
|
2013-06-06 16:52:54 +02:00
|
|
|
$cmd = "DEL_ALL_{$type}S;" . $object->host_name;
|
|
|
|
if ($type == "SERVICE_COMMENT") {
|
|
|
|
$cmd .= ";" . $object->service_description;
|
|
|
|
}
|
2013-06-03 16:56:08 +02:00
|
|
|
$this->send($cmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function enableGlobalNotifications()
|
|
|
|
{
|
|
|
|
$this->send("ENABLE_NOTIFICATIONS");
|
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function disableGlobalNotifications()
|
|
|
|
{
|
|
|
|
$this->send("DISABLE_NOTIFICATIONS");
|
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $object
|
|
|
|
* @return string
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
private function getObjectType($object)
|
|
|
|
{
|
|
|
|
//@TODO: This must be refactored once more commands are supported
|
2013-06-06 16:52:54 +02:00
|
|
|
if (isset($object->service_description)) {
|
2013-06-03 16:56:08 +02:00
|
|
|
return self::TYPE_SERVICE;
|
2013-06-06 16:52:54 +02:00
|
|
|
}
|
2013-06-03 16:56:08 +02:00
|
|
|
return self::TYPE_HOST;
|
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objects
|
|
|
|
* @param Downtime $downtime
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function scheduleDowntime($objects, Downtime $downtime)
|
|
|
|
{
|
|
|
|
foreach ($objects as $object) {
|
|
|
|
$type = $this->getObjectType($object);
|
2013-06-06 16:52:54 +02:00
|
|
|
if ($type == self::TYPE_SERVICE) {
|
|
|
|
$this->send(
|
|
|
|
sprintf($downtime->getFormatString($type), $object->host_name, $object->service_description)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$this->send(sprintf($downtime->getFormatString($type), $object->host_name));
|
|
|
|
}
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objects
|
|
|
|
* @param int $starttime
|
|
|
|
*/
|
2013-06-06 16:52:54 +02:00
|
|
|
public function removeDowntime($objects, $starttime = 0)
|
2013-06-03 16:56:08 +02:00
|
|
|
{
|
|
|
|
foreach ($objects as $object) {
|
|
|
|
$type = $this->getObjectType($object);
|
|
|
|
if (isset($object->downtime_id)) {
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->send("DEL_" . $type . "_DOWNTIME;" . $object->downtime_id);
|
2013-06-03 16:56:08 +02:00
|
|
|
continue;
|
|
|
|
}
|
2013-06-06 16:52:54 +02:00
|
|
|
$cmd = "DEL_DOWNTIME_BY_HOST_NAME;" . $object->host_name;
|
|
|
|
if ($type == self::TYPE_SERVICE) {
|
|
|
|
$cmd .= ";" . $object->service_description;
|
|
|
|
}
|
|
|
|
if ($starttime != 0) {
|
|
|
|
$cmd .= ";" . $starttime;
|
|
|
|
}
|
2013-06-03 16:56:08 +02:00
|
|
|
$this->send($cmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function restartIcinga()
|
|
|
|
{
|
|
|
|
$this->send("RESTART_PROCESS");
|
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objects
|
|
|
|
* @param PropertyModifier $flags
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function setMonitoringProperties($objects, PropertyModifier $flags)
|
|
|
|
{
|
|
|
|
foreach ($objects as $object) {
|
|
|
|
$type = $this->getObjectType($object);
|
|
|
|
$formatArray = $flags->getFormatString($type);
|
|
|
|
foreach ($formatArray as $format) {
|
2013-06-06 16:52:54 +02:00
|
|
|
$format .= ";"
|
|
|
|
. $object->host_name
|
|
|
|
. ($type == self::TYPE_SERVICE ? ";" . $object->service_description : "");
|
2013-06-03 16:56:08 +02:00
|
|
|
$this->send($format);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objects
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function enableActiveChecks($objects)
|
|
|
|
{
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->setMonitoringProperties(
|
|
|
|
$objects,
|
|
|
|
new PropertyModifier(
|
|
|
|
array(
|
|
|
|
PropertyModifier::ACTIVE => PropertyModifier::STATE_ENABLE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objects
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function disableActiveChecks($objects)
|
|
|
|
{
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->modifyMonitoringProperties(
|
|
|
|
$objects,
|
|
|
|
new PropertyModifier(
|
|
|
|
array(
|
|
|
|
PropertyModifier::ACTIVE => PropertyModifier::STATE_DISABLE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objects
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function enablePassiveChecks($objects)
|
|
|
|
{
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->setMonitoringProperties(
|
|
|
|
$objects,
|
|
|
|
new PropertyModifier(
|
|
|
|
array(
|
|
|
|
PropertyModifier::PASSIVE => PropertyModifier::STATE_ENABLE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objects
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function disablePassiveChecks($objects)
|
|
|
|
{
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->modifyMonitoringProperties(
|
|
|
|
$objects,
|
|
|
|
new PropertyModifier(
|
|
|
|
array(
|
|
|
|
PropertyModifier::PASSIVE => PropertyModifier::STATE_DISABLE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objects
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function enableFlappingDetection($objects)
|
|
|
|
{
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->setMonitoringProperties(
|
|
|
|
$objects,
|
|
|
|
new PropertyModifier(
|
|
|
|
array(
|
|
|
|
PropertyModifier::FLAPPING => PropertyModifier::STATE_ENABLE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objects
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function disableFlappingDetection($objects)
|
|
|
|
{
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->setMonitoringProperties(
|
|
|
|
$objects,
|
|
|
|
new PropertyModifier(
|
|
|
|
array(
|
|
|
|
PropertyModifier::FLAPPING => PropertyModifier::STATE_DISABLE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objects
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function enableNotifications($objects)
|
|
|
|
{
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->setMonitoringProperties(
|
|
|
|
$objects,
|
|
|
|
new PropertyModifier(
|
|
|
|
array(
|
|
|
|
PropertyModifier::NOTIFICATIONS => PropertyModifier::STATE_ENABLE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objects
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function disableNotifications($objects)
|
|
|
|
{
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->setMonitoringProperties(
|
|
|
|
$objects,
|
|
|
|
new PropertyModifier(
|
|
|
|
array(
|
|
|
|
PropertyModifier::NOTIFICATIONS => PropertyModifier::STATE_DISABLE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objects
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function enableFreshnessChecks($objects)
|
|
|
|
{
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->setMonitoringProperties(
|
|
|
|
$objects,
|
|
|
|
new PropertyModifier(
|
|
|
|
array(
|
|
|
|
PropertyModifier::FRESHNESS => PropertyModifier::STATE_ENABLE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objects
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function disableFreshnessChecks($objects)
|
|
|
|
{
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->setMonitoringProperties(
|
|
|
|
$objects,
|
|
|
|
new PropertyModifier(
|
|
|
|
array(
|
|
|
|
PropertyModifier::FRESHNESS => PropertyModifier::STATE_DISABLE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
2013-06-06 16:52:54 +02:00
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objects
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function enableEventHandler($objects)
|
|
|
|
{
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->setMonitoringProperties(
|
|
|
|
$objects,
|
|
|
|
new PropertyModifier(
|
|
|
|
array(
|
|
|
|
PropertyModifier::EVENTHANDLER => PropertyModifier::STATE_ENABLE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objects
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function disableEventHandler($objects)
|
|
|
|
{
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->setMonitoringProperties(
|
|
|
|
$objects,
|
|
|
|
new PropertyModifier(
|
|
|
|
array(
|
|
|
|
PropertyModifier::EVENTHANDLER => PropertyModifier::STATE_DISABLE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $objects
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public function enablePerfdata($objects)
|
|
|
|
{
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->setMonitoringProperties(
|
|
|
|
$objects,
|
|
|
|
new PropertyModifier(
|
|
|
|
array(
|
|
|
|
PropertyModifier::PERFDATA => PropertyModifier::STATE_ENABLE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function disablePerfdata($objects)
|
|
|
|
{
|
2013-06-06 16:52:54 +02:00
|
|
|
$this->setMonitoringProperties(
|
|
|
|
$objects,
|
|
|
|
new PropertyModifier(
|
|
|
|
array(
|
|
|
|
PropertyModifier::PERFDATA => PropertyModifier::STATE_DISABLE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
2013-06-06 16:52:54 +02:00
|
|
|
}
|