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
|
|
|
/**
|
2013-07-15 12:26:10 +02:00
|
|
|
* This file is part of Icinga 2 Web.
|
|
|
|
*
|
|
|
|
* Icinga 2 Web - Head for multiple monitoring backends.
|
2013-06-28 16:47:30 +02:00
|
|
|
* 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>
|
2013-07-15 12:26:10 +02:00
|
|
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
|
|
|
* @author Icinga Development Team <info@icinga.org>
|
2013-06-28 16:47:30 +02:00
|
|
|
*/
|
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
|
|
|
|
2013-07-31 14:17:40 +02:00
|
|
|
use Icinga\Protocol\Commandpipe\Transport\Transport;
|
|
|
|
use Icinga\Protocol\Commandpipe\Transport\LocalPipe;
|
|
|
|
use Icinga\Protocol\Commandpipe\Transport\SecureShell;
|
|
|
|
|
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
|
|
|
|
2013-07-31 14:17:40 +02:00
|
|
|
private $name = "";
|
2013-06-07 13:29:11 +02:00
|
|
|
|
2013-07-31 14:17:40 +02:00
|
|
|
private $transport = null;
|
2013-06-03 16:56:08 +02:00
|
|
|
|
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)
|
|
|
|
{
|
2013-07-31 14:17:40 +02:00
|
|
|
$this->getTransportForConfiguration($config);
|
2013-06-03 16:56:08 +02:00
|
|
|
$this->name = $config->name;
|
2013-07-31 14:17:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private function getTransportForConfiguration(\Zend_Config $config, $transport = null)
|
|
|
|
{
|
|
|
|
if ($transport != null) {
|
|
|
|
$this->transport = $transport;
|
|
|
|
} else if (isset($config->host)) {
|
|
|
|
$this->transport = new SecureShell();
|
|
|
|
$this->transport->setEndpoint($config);
|
|
|
|
} else {
|
|
|
|
$this->transport = new LocalPipe();
|
|
|
|
$this->transport->setEndpoint($config);
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-07-31 14:17:40 +02:00
|
|
|
$this->transport->send($command);
|
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-07-31 17:03:21 +02:00
|
|
|
public function submitCheckResult($objects, $state, $output, $perfdata = "")
|
2013-06-03 16:56:08 +02:00
|
|
|
{
|
2013-07-31 17:03:21 +02:00
|
|
|
if ($perfdata) {
|
|
|
|
$output = $output."|".$perfdata;
|
|
|
|
}
|
2013-06-03 16:56:08 +02:00
|
|
|
foreach ($objects as $object) {
|
|
|
|
if (isset($object->service_description)) {
|
2013-07-31 17:03:21 +02:00
|
|
|
$this->send("PROCESS_SERVICE_CHECK_RESULT;$object->host_name;$object->service_description;$state;$output");
|
2013-06-03 16:56:08 +02:00
|
|
|
} 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-07-31 17:03:21 +02:00
|
|
|
$this->setMonitoringProperties(
|
2013-06-06 16:52:54 +02:00
|
|
|
$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-07-31 17:03:21 +02:00
|
|
|
$this->setMonitoringProperties(
|
2013-06-06 16:52:54 +02:00
|
|
|
$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-07-31 14:17:40 +02:00
|
|
|
|
2013-07-31 17:03:21 +02:00
|
|
|
public function startObsessing($objects)
|
|
|
|
{
|
|
|
|
foreach ($objects as $object) {
|
|
|
|
$type = $this->getObjectType($object);
|
|
|
|
$msg = "START_OBSESSING_OVER_". (($type == self::TYPE_SERVICE) ? 'SVC' : 'HOST');
|
|
|
|
$msg .= ';'.$object->host_name;
|
|
|
|
if ($type == self::TYPE_SERVICE) {
|
|
|
|
$msg .= ';'.$object->service_description;
|
|
|
|
}
|
|
|
|
$this->send($msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function stopObsessing($objects)
|
|
|
|
{
|
|
|
|
foreach ($objects as $object) {
|
|
|
|
$type = $this->getObjectType($object);
|
|
|
|
$msg = "STOP_OBSESSING_OVER_". (($type == self::TYPE_SERVICE) ? 'SVC' : 'HOST');
|
|
|
|
$msg .= ';'.$object->host_name;
|
|
|
|
if ($type == self::TYPE_SERVICE) {
|
|
|
|
$msg .= ';'.$object->service_description;
|
|
|
|
}
|
|
|
|
$this->send($msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-31 14:17:40 +02:00
|
|
|
/**
|
|
|
|
* Return the transport handler that handles actual sending of commands
|
|
|
|
*
|
|
|
|
* @return Transport
|
|
|
|
*/
|
|
|
|
public function getTransport()
|
|
|
|
{
|
|
|
|
return $this->transport;
|
|
|
|
}
|
2013-06-06 16:52:54 +02:00
|
|
|
}
|