2015-07-30 17:50:17 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
|
|
|
* Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) *
|
|
|
|
* *
|
|
|
|
* 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 St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#include "icinga/apiactions.hpp"
|
|
|
|
#include "icinga/service.hpp"
|
2015-08-03 15:27:09 +02:00
|
|
|
#include "icinga/servicegroup.hpp"
|
|
|
|
#include "icinga/hostgroup.hpp"
|
2015-07-31 17:18:49 +02:00
|
|
|
#include "icinga/pluginutility.hpp"
|
2015-08-03 15:27:09 +02:00
|
|
|
#include "icinga/checkcommand.hpp"
|
|
|
|
#include "icinga/eventcommand.hpp"
|
|
|
|
#include "icinga/notificationcommand.hpp"
|
2015-07-30 17:50:17 +02:00
|
|
|
#include "remote/apiaction.hpp"
|
|
|
|
#include "remote/httputility.hpp"
|
|
|
|
#include "base/utility.hpp"
|
|
|
|
#include "base/convert.hpp"
|
2015-08-21 15:50:40 +02:00
|
|
|
#include <fstream>
|
2015-07-30 17:50:17 +02:00
|
|
|
|
|
|
|
using namespace icinga;
|
|
|
|
|
2015-08-03 15:27:09 +02:00
|
|
|
REGISTER_APIACTION(process_check_result, "Service;Host", &ApiActions::ProcessCheckResult);
|
|
|
|
REGISTER_APIACTION(reschedule_check, "Service;Host", &ApiActions::RescheduleCheck);
|
2015-08-21 12:47:49 +02:00
|
|
|
REGISTER_APIACTION(delay_notifications, "Service;Host", &ApiActions::DelayNotifications);
|
2015-08-03 15:27:09 +02:00
|
|
|
|
|
|
|
REGISTER_APIACTION(acknowledge_problem, "Service;Host", &ApiActions::AcknowledgeProblem);
|
|
|
|
REGISTER_APIACTION(remove_acknowledgement, "Service;Host", &ApiActions::RemoveAcknowledgement);
|
|
|
|
REGISTER_APIACTION(add_comment, "Service;Host", &ApiActions::AddComment);
|
2015-08-21 15:50:40 +02:00
|
|
|
REGISTER_APIACTION(remove_comment, "Service;Host", &ApiActions::RemoveComment);
|
|
|
|
REGISTER_APIACTION(remove_comment_by_id, "", &ApiActions::RemoveCommentByID);
|
2015-08-21 12:47:49 +02:00
|
|
|
REGISTER_APIACTION(schedule_downtime, "Service;Host", &ApiActions::ScheduleDowntime);
|
2015-08-21 15:50:40 +02:00
|
|
|
REGISTER_APIACTION(remove_downtime, "Service;Host", &ApiActions::RemoveDowntime);
|
|
|
|
REGISTER_APIACTION(remove_downtime_by_id, "", &ApiActions::RemoveDowntimeByID);
|
2015-08-03 15:27:09 +02:00
|
|
|
|
2015-08-21 12:47:49 +02:00
|
|
|
REGISTER_APIACTION(enable_passive_checks, "Service;Host", &ApiActions::EnablePassiveChecks);
|
|
|
|
REGISTER_APIACTION(disable_passive_checks, "Service;Host", &ApiActions::DisablePassiveChecks);
|
|
|
|
REGISTER_APIACTION(enable_active_checks, "Host", &ApiActions::EnableActiveChecks);
|
|
|
|
REGISTER_APIACTION(disable_active_checks, "Host", &ApiActions::DisableActiveChecks);
|
2015-08-03 15:27:09 +02:00
|
|
|
REGISTER_APIACTION(enable_notifications, "Service;Host", &ApiActions::EnableNotifications);
|
|
|
|
REGISTER_APIACTION(disable_notifications, "Service;Host", &ApiActions::DisableNotifications);
|
|
|
|
REGISTER_APIACTION(enable_flap_detection, "Service;Host", &ApiActions::EnableFlapDetection);
|
|
|
|
REGISTER_APIACTION(disable_flap_detection, "Service;Host", &ApiActions::DisableFlapDetection);
|
|
|
|
|
2015-08-21 12:47:49 +02:00
|
|
|
//TODO-MA. Figure out how to handle modified attributes as actions
|
2015-08-03 15:27:09 +02:00
|
|
|
/*
|
|
|
|
REGISTER_APIACTION(change_event_handler, "Service;Host", &ApiActions::ChangeEventHandler);
|
|
|
|
REGISTER_APIACTION(change_check_command, "Service;Host", &ApiActions::ChangeCheckCommand);
|
|
|
|
REGISTER_APIACTION(change_max_check_attempts, "Service;Host", &ApiActions::ChangeMaxCheckAttempts);
|
|
|
|
REGISTER_APIACTION(change_check_period, "Service;Host", &ApiActions::ChangeCheckPeriod);
|
|
|
|
REGISTER_APIACTION(change_check_interval, "Service;Host", &ApiActions::ChangeCheckInterval);
|
|
|
|
REGISTER_APIACTION(change_retry_interval, "Service;Host", &ApiActions::ChangeRetryInterval);
|
|
|
|
*/
|
2015-08-20 14:30:34 +02:00
|
|
|
|
|
|
|
REGISTER_APIACTION(enable_global_notifications, "", &ApiActions::EnableGlobalNotifications);
|
|
|
|
REGISTER_APIACTION(disable_global_notifications, "", &ApiActions::DisableGlobalNotifications);
|
|
|
|
REGISTER_APIACTION(enable_global_flap_detection, "", &ApiActions::EnableGlobalFlapDetection);
|
|
|
|
REGISTER_APIACTION(disable_global_flap_detection, "", &ApiActions::DisableGlobalFlapDetection);
|
|
|
|
REGISTER_APIACTION(enable_global_event_handlers, "", &ApiActions::EnableGlobalEventHandlers);
|
|
|
|
REGISTER_APIACTION(disable_global_event_handlers, "", &ApiActions::DisableGlobalEventHandlers);
|
|
|
|
REGISTER_APIACTION(enable_global_performance_data, "", &ApiActions::EnableGlobalPerformanceData);
|
|
|
|
REGISTER_APIACTION(disable_global_performance_data, "", &ApiActions::DisableGlobalPerformanceData);
|
|
|
|
REGISTER_APIACTION(start_global_executing_svc_checks, "", &ApiActions::StartGlobalExecutingSvcChecks);
|
|
|
|
REGISTER_APIACTION(stop_global_executing_svc_checks, "", &ApiActions::StopGlobalExecutingSvcChecks);
|
|
|
|
REGISTER_APIACTION(start_global_executing_host_checks, "", &ApiActions::StartGlobalExecutingHostChecks);
|
|
|
|
REGISTER_APIACTION(stop_global_executing_host_checks, "", &ApiActions::StopGlobalExecutingHostChecks);
|
2015-08-03 15:27:09 +02:00
|
|
|
|
|
|
|
REGISTER_APIACTION(shutdown_process, "", &ApiActions::ShutdownProcess);
|
|
|
|
REGISTER_APIACTION(restart_process, "", &ApiActions::RestartProcess);
|
|
|
|
|
2015-08-21 12:47:49 +02:00
|
|
|
Dictionary::Ptr ApiActions::CreateResult(int code, const String& status, const Dictionary::Ptr& additional)
|
2015-08-03 15:27:09 +02:00
|
|
|
{
|
2015-07-31 17:18:49 +02:00
|
|
|
Dictionary::Ptr result = new Dictionary();
|
|
|
|
result->Set("code", code);
|
|
|
|
result->Set("status", status);
|
2015-08-21 12:47:49 +02:00
|
|
|
|
|
|
|
if (additional)
|
|
|
|
additional->CopyTo(result);
|
|
|
|
|
2015-07-31 17:18:49 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-08-15 20:28:05 +02:00
|
|
|
Dictionary::Ptr ApiActions::RescheduleCheck(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
2015-07-30 17:50:17 +02:00
|
|
|
{
|
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
2015-07-31 17:18:49 +02:00
|
|
|
|
|
|
|
if (!checkable)
|
2015-08-21 12:47:49 +02:00
|
|
|
return ApiActions::CreateResult(404, "Cannot reschedule check for non-existent object.");
|
2015-07-31 17:18:49 +02:00
|
|
|
|
2015-07-30 17:50:17 +02:00
|
|
|
if (Convert::ToBool(HttpUtility::GetLastParameter(params, "force")))
|
|
|
|
checkable->SetForceNextCheck(true);
|
|
|
|
|
|
|
|
double nextCheck;
|
|
|
|
if (params->Contains("next_check"))
|
|
|
|
nextCheck = HttpUtility::GetLastParameter(params, "next_check");
|
|
|
|
else
|
|
|
|
nextCheck = Utility::GetTime();
|
|
|
|
|
|
|
|
checkable->SetNextCheck(nextCheck);
|
2015-07-31 17:18:49 +02:00
|
|
|
|
2015-08-21 12:47:49 +02:00
|
|
|
return ApiActions::CreateResult(200, "Successfully rescheduled check for " + checkable->GetName() + ".");
|
2015-07-31 17:18:49 +02:00
|
|
|
}
|
|
|
|
|
2015-08-15 20:28:05 +02:00
|
|
|
Dictionary::Ptr ApiActions::ProcessCheckResult(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
2015-07-31 17:18:49 +02:00
|
|
|
{
|
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
|
|
|
|
|
|
|
if (!checkable)
|
2015-08-21 12:47:49 +02:00
|
|
|
return ApiActions::CreateResult(404, "Cannot process passive check result for non-existent object.");
|
2015-07-31 17:18:49 +02:00
|
|
|
|
|
|
|
if (!checkable->GetEnablePassiveChecks())
|
|
|
|
return ApiActions::CreateResult(403, "Passive checks are disabled for " + checkable->GetName());
|
|
|
|
|
|
|
|
Host::Ptr host;
|
|
|
|
Service::Ptr service;
|
|
|
|
tie(host, service) = GetHostService(checkable);
|
|
|
|
|
|
|
|
if (!params->Contains("exit_status"))
|
2015-08-21 12:47:49 +02:00
|
|
|
return ApiActions::CreateResult(403, "Parameter 'exit_status' is required.");
|
2015-07-31 17:18:49 +02:00
|
|
|
|
|
|
|
int exitStatus = HttpUtility::GetLastParameter(params, "exit_status");
|
|
|
|
|
|
|
|
ServiceState state;
|
|
|
|
|
|
|
|
if (!service) {
|
|
|
|
if (exitStatus == 0)
|
|
|
|
state = ServiceOK;
|
|
|
|
else if (exitStatus == 1)
|
|
|
|
state = ServiceCritical;
|
|
|
|
else
|
2015-08-21 12:47:49 +02:00
|
|
|
return ApiActions::CreateResult(403, "Invalid 'exit_status' for Host " + checkable->GetName() + ".");
|
2015-07-31 17:18:49 +02:00
|
|
|
} else {
|
|
|
|
state = PluginUtility::ExitStatusToState(exitStatus);
|
|
|
|
}
|
|
|
|
|
2015-08-03 15:27:09 +02:00
|
|
|
if (!params->Contains("plugin_output"))
|
|
|
|
return ApiActions::CreateResult(403, "Parameter 'plugin_output' is required");
|
2015-07-31 17:18:49 +02:00
|
|
|
|
|
|
|
CheckResult::Ptr cr = new CheckResult();
|
2015-08-03 15:27:09 +02:00
|
|
|
cr->SetOutput(HttpUtility::GetLastParameter(params, "plugin_output"));
|
2015-07-31 17:18:49 +02:00
|
|
|
cr->SetState(state);
|
|
|
|
|
|
|
|
cr->SetCheckSource(HttpUtility::GetLastParameter(params, "check_source"));
|
2015-08-03 15:27:09 +02:00
|
|
|
cr->SetPerformanceData(params->Get("performance_data"));
|
|
|
|
cr->SetCommand(params->Get("check_command"));
|
2015-07-31 17:18:49 +02:00
|
|
|
cr->SetExecutionEnd(HttpUtility::GetLastParameter(params, "execution_end"));
|
|
|
|
cr->SetExecutionStart(HttpUtility::GetLastParameter(params, "execution_start"));
|
|
|
|
cr->SetScheduleEnd(HttpUtility::GetLastParameter(params, "schedule_end"));
|
|
|
|
cr->SetScheduleStart(HttpUtility::GetLastParameter(params, "schedule_start"));
|
|
|
|
|
|
|
|
checkable->ProcessCheckResult(cr);
|
|
|
|
|
2015-08-03 15:27:09 +02:00
|
|
|
/* Reschedule the next check. The side effect of this is that for as long
|
|
|
|
* as we receive passive results for a service we won't execute any
|
|
|
|
* active checks. */
|
|
|
|
checkable->SetNextCheck(Utility::GetTime() + checkable->GetCheckInterval());
|
|
|
|
|
2015-08-21 12:47:49 +02:00
|
|
|
return ApiActions::CreateResult(200, "Successfully processed check result for object " + checkable->GetName() + ".");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::EnablePassiveChecks(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
|
|
|
{
|
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
|
|
|
|
|
|
|
if (!checkable)
|
2015-08-21 12:47:49 +02:00
|
|
|
return ApiActions::CreateResult(404, "Cannot enable passive checks for non-existent object.");
|
2015-08-03 15:27:09 +02:00
|
|
|
|
|
|
|
checkable->SetEnablePassiveChecks(true);
|
|
|
|
|
2015-08-21 12:47:49 +02:00
|
|
|
return ApiActions::CreateResult(200, "Successfully enabled passive checks for object " + checkable->GetName() + ".");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::DisablePassiveChecks(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
|
|
|
{
|
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
|
|
|
|
|
|
|
if (!checkable)
|
2015-08-21 12:47:49 +02:00
|
|
|
return ApiActions::CreateResult(404, "Cannot disable passive checks non-existent object.");
|
2015-08-03 15:27:09 +02:00
|
|
|
|
|
|
|
checkable->SetEnablePassiveChecks(false);
|
|
|
|
|
2015-08-21 12:47:49 +02:00
|
|
|
return ApiActions::CreateResult(200, "Successfully disabled passive checks for object " + checkable->GetName() + ".");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::EnableActiveChecks(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
|
|
|
{
|
2015-08-21 12:47:49 +02:00
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
2015-08-03 15:27:09 +02:00
|
|
|
|
2015-08-21 12:47:49 +02:00
|
|
|
if (!checkable)
|
|
|
|
return ApiActions::CreateResult(404, "Cannot enable passive checks for non-existent object.");
|
2015-08-03 15:27:09 +02:00
|
|
|
|
2015-08-21 12:47:49 +02:00
|
|
|
checkable->SetEnableActiveChecks(true);
|
2015-08-03 15:27:09 +02:00
|
|
|
|
2015-08-21 12:47:49 +02:00
|
|
|
return ApiActions::CreateResult(200, "Successfully enabled passive checks for object " + checkable->GetName() + ".");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::DisableActiveChecks(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
|
|
|
{
|
2015-08-21 12:47:49 +02:00
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
2015-08-03 15:27:09 +02:00
|
|
|
|
2015-08-21 12:47:49 +02:00
|
|
|
if (!checkable)
|
|
|
|
return ApiActions::CreateResult(404, "Cannot disable passive checks non-existent object.");
|
2015-08-03 15:27:09 +02:00
|
|
|
|
2015-08-21 12:47:49 +02:00
|
|
|
checkable->SetEnableActiveChecks(false);
|
2015-08-03 15:27:09 +02:00
|
|
|
|
2015-08-21 12:47:49 +02:00
|
|
|
return ApiActions::CreateResult(200, "Successfully disabled passive checks for object " + checkable->GetName() + ".");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::AcknowledgeProblem(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
|
|
|
{
|
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
|
|
|
|
|
|
|
if (!checkable)
|
2015-08-21 12:47:49 +02:00
|
|
|
return ApiActions::CreateResult(404, "Cannot acknowledge problem for non-existent object.");
|
2015-08-03 15:27:09 +02:00
|
|
|
|
|
|
|
if (!params->Contains("author") || !params->Contains("comment"))
|
2015-08-21 12:47:49 +02:00
|
|
|
return ApiActions::CreateResult(403, "Acknowledgements require author and comment.");
|
2015-08-03 15:27:09 +02:00
|
|
|
|
|
|
|
AcknowledgementType sticky = AcknowledgementNormal;
|
|
|
|
bool notify = false;
|
2015-08-21 12:47:49 +02:00
|
|
|
double timestamp = 0.0;
|
2015-08-03 15:27:09 +02:00
|
|
|
if (params->Contains("sticky"))
|
|
|
|
sticky = AcknowledgementSticky;
|
|
|
|
if (params->Contains("notify"))
|
|
|
|
notify = true;
|
|
|
|
if (params->Contains("timestamp"))
|
|
|
|
timestamp = HttpUtility::GetLastParameter(params, "timestamp");
|
|
|
|
|
|
|
|
Host::Ptr host;
|
|
|
|
Service::Ptr service;
|
|
|
|
tie(host, service) = GetHostService(checkable);
|
|
|
|
|
2015-07-31 17:18:49 +02:00
|
|
|
if (!service) {
|
2015-08-03 15:27:09 +02:00
|
|
|
if (host->GetState() == HostUp)
|
2015-08-21 12:47:49 +02:00
|
|
|
return ApiActions::CreateResult(409, "Host " + checkable->GetName() + " is UP.");
|
2015-08-03 15:27:09 +02:00
|
|
|
} else {
|
|
|
|
if (service->GetState() == ServiceOK)
|
2015-08-21 12:47:49 +02:00
|
|
|
return ApiActions::CreateResult(409, "Service " + checkable->GetName() + " is OK.");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
checkable->AddComment(CommentAcknowledgement, HttpUtility::GetLastParameter(params, "author"),
|
|
|
|
HttpUtility::GetLastParameter(params, "comment"), timestamp);
|
|
|
|
checkable->AcknowledgeProblem(HttpUtility::GetLastParameter(params, "author"),
|
|
|
|
HttpUtility::GetLastParameter(params, "comment"), sticky, notify, timestamp);
|
2015-08-21 12:47:49 +02:00
|
|
|
|
2015-08-03 15:27:09 +02:00
|
|
|
return ApiActions::CreateResult(200, "Successfully acknowledged problem for " + checkable->GetName());
|
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::RemoveAcknowledgement(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
|
|
|
{
|
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
|
|
|
|
|
|
|
if (!checkable)
|
2015-08-21 12:47:49 +02:00
|
|
|
return ApiActions::CreateResult(404, "Cannot remove acknowlegement for non-existent checkable object " + object->GetName() + ".");
|
2015-08-03 15:27:09 +02:00
|
|
|
|
|
|
|
checkable->ClearAcknowledgement();
|
|
|
|
checkable->RemoveCommentsByType(CommentAcknowledgement);
|
|
|
|
|
2015-08-21 12:47:49 +02:00
|
|
|
return ApiActions::CreateResult(200, "Successfully removed acknowledgement for " + checkable->GetName() + ".");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::AddComment(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
|
|
|
{
|
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
|
|
|
|
|
|
|
if (!checkable)
|
|
|
|
return ApiActions::CreateResult(404, "Cannot add comment for non-existent object");
|
|
|
|
|
|
|
|
if (!params->Contains("author") || !params->Contains("comment"))
|
2015-08-21 12:47:49 +02:00
|
|
|
return ApiActions::CreateResult(403, "Comments require author and comment.");
|
2015-08-03 15:27:09 +02:00
|
|
|
|
2015-08-21 12:47:49 +02:00
|
|
|
String comment_id = checkable->AddComment(CommentUser, HttpUtility::GetLastParameter(params, "author"),
|
2015-08-03 15:27:09 +02:00
|
|
|
HttpUtility::GetLastParameter(params, "comment"), 0);
|
|
|
|
|
2015-08-21 12:47:49 +02:00
|
|
|
Comment::Ptr comment = Checkable::GetCommentByID(comment_id);
|
|
|
|
int legacy_id = comment->GetLegacyId();
|
|
|
|
|
|
|
|
Dictionary::Ptr additional = new Dictionary();
|
|
|
|
additional->Set("comment_id", comment_id);
|
|
|
|
additional->Set("legacy_id", legacy_id);
|
|
|
|
|
|
|
|
return ApiActions::CreateResult(200, "Successfully added comment with id " +
|
|
|
|
Convert::ToString(legacy_id) + " for object " + checkable->GetName() + ".", additional);
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::RemoveComment(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
|
|
|
{
|
2015-08-21 15:50:40 +02:00
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
2015-08-03 15:27:09 +02:00
|
|
|
|
2015-08-21 15:50:40 +02:00
|
|
|
if (!checkable)
|
|
|
|
return ApiActions::CreateResult(404, "Cannot remove comment form non-existent object");
|
2015-08-03 15:27:09 +02:00
|
|
|
|
2015-08-21 15:50:40 +02:00
|
|
|
checkable->RemoveAllComments();
|
2015-08-03 15:27:09 +02:00
|
|
|
|
2015-08-21 15:50:40 +02:00
|
|
|
return ApiActions::CreateResult(200, "Successfully removed comments for " + checkable->GetName());
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
2015-08-21 15:50:40 +02:00
|
|
|
Dictionary::Ptr ApiActions::RemoveCommentByID(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
2015-08-03 15:27:09 +02:00
|
|
|
{
|
2015-08-21 15:50:40 +02:00
|
|
|
if (!params->Contains("comment_id"))
|
|
|
|
return ApiActions::CreateResult(403, "Parameter 'comment_id' is required.");
|
2015-08-03 15:27:09 +02:00
|
|
|
|
2015-08-21 15:50:40 +02:00
|
|
|
int comment_id = HttpUtility::GetLastParameter(params, "comment_id");
|
2015-08-03 15:27:09 +02:00
|
|
|
|
2015-08-21 15:50:40 +02:00
|
|
|
String rid = Service::GetCommentIDFromLegacyID(comment_id);
|
|
|
|
|
|
|
|
if (rid.IsEmpty())
|
|
|
|
return ApiActions::CreateResult(404, "Comment '" + Convert::ToString(comment_id) + "' does not exist.");
|
2015-08-21 12:47:49 +02:00
|
|
|
|
2015-08-21 15:50:40 +02:00
|
|
|
Service::RemoveComment(rid);
|
|
|
|
|
|
|
|
return ApiActions::CreateResult(200, "Successfully removed comment " + Convert::ToString(comment_id) + ".");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::EnableNotifications(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
|
|
|
{
|
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
|
|
|
|
|
|
|
if (!checkable)
|
|
|
|
return ApiActions::CreateResult(404, "Cannot enable notifications for non-existent object");
|
|
|
|
|
|
|
|
checkable->SetEnableNotifications(true);
|
2015-08-21 12:47:49 +02:00
|
|
|
|
2015-08-03 15:27:09 +02:00
|
|
|
return ApiActions::CreateResult(200, "Successfully enabled notifications for " + checkable->GetName());
|
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::DisableNotifications(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
|
|
|
{
|
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
|
|
|
|
|
|
|
if (!checkable)
|
|
|
|
return ApiActions::CreateResult(404, "Cannot disable notifications for non-existent object");
|
|
|
|
|
|
|
|
checkable->SetEnableNotifications(true);
|
2015-08-21 12:47:49 +02:00
|
|
|
|
2015-08-03 15:27:09 +02:00
|
|
|
return ApiActions::CreateResult(200, "Successfully disabled notifications for " + checkable->GetName());
|
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::DelayNotifications(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
|
|
|
{
|
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
|
|
|
|
|
|
|
if (!checkable)
|
|
|
|
return ApiActions::CreateResult(404, "Cannot delay notifications for non-existent object");
|
|
|
|
|
|
|
|
if (!params->Contains("timestamp"))
|
|
|
|
return ApiActions::CreateResult(403, "A timestamp is required to delay notifications");
|
|
|
|
|
|
|
|
BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) {
|
|
|
|
notification->SetNextNotification(HttpUtility::GetLastParameter(params, "timestamp"));
|
|
|
|
}
|
|
|
|
|
|
|
|
return ApiActions::CreateResult(200, "Successfully delayed notifications for " + checkable->GetName());
|
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::ScheduleDowntime(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
|
|
|
{
|
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
|
|
|
|
|
|
|
if (!checkable)
|
|
|
|
return ApiActions::CreateResult(404, "Can't schedule downtime for non-existent object");
|
|
|
|
|
|
|
|
if (!params->Contains("start_time") || !params->Contains("end_time") || !params->Contains("duration") ||
|
|
|
|
!params->Contains("author") || !params->Contains("comment"))
|
|
|
|
return ApiActions::CreateResult(404, "Options 'start_time', 'end_time', 'duration', 'author' and 'comment' are required");
|
|
|
|
|
2015-08-21 12:47:49 +02:00
|
|
|
bool fixed = false;
|
2015-08-03 15:27:09 +02:00
|
|
|
if (params->Contains("fixed"))
|
2015-08-21 12:47:49 +02:00
|
|
|
fixed = HttpUtility::GetLastParameter(params, "fixed");
|
2015-08-03 15:27:09 +02:00
|
|
|
|
|
|
|
int triggeredByLegacy = params->Contains("trigger_id") ? (int) HttpUtility::GetLastParameter(params, "trigger_id") : 0;
|
|
|
|
String triggeredBy;
|
|
|
|
if (triggeredByLegacy)
|
|
|
|
triggeredBy = Service::GetDowntimeIDFromLegacyID(triggeredByLegacy);
|
|
|
|
|
2015-08-21 12:47:49 +02:00
|
|
|
String downtime_id = checkable->AddDowntime(HttpUtility::GetLastParameter(params, "author"), HttpUtility::GetLastParameter(params, "comment"),
|
2015-08-03 15:27:09 +02:00
|
|
|
HttpUtility::GetLastParameter(params, "start_time"), HttpUtility::GetLastParameter(params, "end_time"),
|
2015-08-21 12:47:49 +02:00
|
|
|
fixed, triggeredBy, HttpUtility::GetLastParameter(params, "duration"));
|
|
|
|
|
|
|
|
Downtime::Ptr downtime = Checkable::GetDowntimeByID(downtime_id);
|
|
|
|
int legacy_id = downtime->GetLegacyId();
|
2015-08-03 15:27:09 +02:00
|
|
|
|
2015-08-21 12:47:49 +02:00
|
|
|
Dictionary::Ptr additional = new Dictionary();
|
|
|
|
additional->Set("downtime_id", downtime_id);
|
|
|
|
additional->Set("legacy_id", legacy_id);
|
|
|
|
|
|
|
|
return ApiActions::CreateResult(200, "Successfully scheduled downtime with id " +
|
|
|
|
Convert::ToString(legacy_id) + " for object " + checkable->GetName() + ".", additional);
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::EnableFlapDetection(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
|
|
|
{
|
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
|
|
|
|
|
|
|
if (!checkable)
|
|
|
|
return ApiActions::CreateResult(404, "Can't enable flap detection for non-existent object");
|
|
|
|
|
|
|
|
checkable->SetEnableFlapping(true);
|
|
|
|
|
|
|
|
return ApiActions::CreateResult(200, "Successfully enabled flap detection for " + checkable->GetName());
|
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::DisableFlapDetection(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
|
|
|
{
|
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
|
|
|
|
|
|
|
if (!checkable)
|
|
|
|
return ApiActions::CreateResult(404, "Can't disable flap detection for non-existent object");
|
|
|
|
|
|
|
|
checkable->SetEnableFlapping(false);
|
|
|
|
|
|
|
|
return ApiActions::CreateResult(200, "Successfully disabled flap detection for " + checkable->GetName());
|
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::RemoveDowntime(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
2015-08-21 15:50:40 +02:00
|
|
|
{
|
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
|
|
|
|
|
|
|
if (!checkable)
|
|
|
|
return ApiActions::CreateResult(404, "Cannot remove downtime for non-existent object");
|
|
|
|
|
|
|
|
checkable->RemoveAllDowntimes();
|
|
|
|
|
|
|
|
return ApiActions::CreateResult(200, "Successfully removed downtimes for " + checkable->GetName());
|
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::RemoveDowntimeByID(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
2015-08-03 15:27:09 +02:00
|
|
|
{
|
|
|
|
if (!params->Contains("downtime_id"))
|
2015-08-21 15:50:40 +02:00
|
|
|
return ApiActions::CreateResult(403, "Parameter 'downtime_id' is required.");
|
2015-08-03 15:27:09 +02:00
|
|
|
|
|
|
|
int downtime_id = HttpUtility::GetLastParameter(params, "downtime_id");
|
|
|
|
|
|
|
|
String rid = Service::GetDowntimeIDFromLegacyID(downtime_id);
|
2015-08-21 15:50:40 +02:00
|
|
|
if (rid.IsEmpty())
|
|
|
|
return ApiActions::CreateResult(404, "Downtime '" + Convert::ToString(downtime_id) + "' does not exist.");
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
Service::RemoveDowntime(rid, true);
|
2015-08-03 15:27:09 +02:00
|
|
|
|
2015-08-21 15:50:40 +02:00
|
|
|
return ApiActions::CreateResult(200, "Successfully removed downtime " + Convert::ToString(downtime_id) + ".");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
2015-08-20 14:30:34 +02:00
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::EnableGlobalNotifications(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
2015-08-03 15:27:09 +02:00
|
|
|
{
|
|
|
|
IcingaApplication::GetInstance()->SetEnableNotifications(true);
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
return ApiActions::CreateResult(200, "Globally enabled notifications.");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
Dictionary::Ptr ApiActions::DisableGlobalNotifications(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
2015-08-03 15:27:09 +02:00
|
|
|
{
|
|
|
|
IcingaApplication::GetInstance()->SetEnableNotifications(false);
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
return ApiActions::CreateResult(200, "Globally disabled notifications.");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
Dictionary::Ptr ApiActions::EnableGlobalFlapDetection(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
2015-08-03 15:27:09 +02:00
|
|
|
{
|
|
|
|
IcingaApplication::GetInstance()->SetEnableFlapping(true);
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
return ApiActions::CreateResult(200, "Globally enabled flap detection.");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
Dictionary::Ptr ApiActions::DisableGlobalFlapDetection(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
2015-08-03 15:27:09 +02:00
|
|
|
{
|
|
|
|
IcingaApplication::GetInstance()->SetEnableFlapping(false);
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
return ApiActions::CreateResult(200, "Globally disabled flap detection.");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
Dictionary::Ptr ApiActions::EnableGlobalEventHandlers(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
2015-08-03 15:27:09 +02:00
|
|
|
{
|
|
|
|
IcingaApplication::GetInstance()->SetEnableEventHandlers(true);
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
return ApiActions::CreateResult(200, "Globally enabled event handlers.");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
Dictionary::Ptr ApiActions::DisableGlobalEventHandlers(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
2015-08-03 15:27:09 +02:00
|
|
|
{
|
|
|
|
IcingaApplication::GetInstance()->SetEnableEventHandlers(false);
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
return ApiActions::CreateResult(200, "Globally disabled event handlers.");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
Dictionary::Ptr ApiActions::EnableGlobalPerformanceData(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
2015-08-03 15:27:09 +02:00
|
|
|
{
|
|
|
|
IcingaApplication::GetInstance()->SetEnablePerfdata(true);
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
return ApiActions::CreateResult(200, "Globally enabled performance data processing.");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
Dictionary::Ptr ApiActions::DisableGlobalPerformanceData(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
2015-08-03 15:27:09 +02:00
|
|
|
{
|
|
|
|
IcingaApplication::GetInstance()->SetEnablePerfdata(false);
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
return ApiActions::CreateResult(200, "Globally disabled performance data processing.");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
Dictionary::Ptr ApiActions::StartGlobalExecutingSvcChecks(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
2015-08-03 15:27:09 +02:00
|
|
|
{
|
|
|
|
IcingaApplication::GetInstance()->SetEnableServiceChecks(true);
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
return ApiActions::CreateResult(200, "Globally enabled service checks.");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
Dictionary::Ptr ApiActions::StopGlobalExecutingSvcChecks(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
2015-08-03 15:27:09 +02:00
|
|
|
{
|
|
|
|
IcingaApplication::GetInstance()->SetEnableServiceChecks(false);
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
return ApiActions::CreateResult(200, "Globally disabled service checks.");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
Dictionary::Ptr ApiActions::StartGlobalExecutingHostChecks(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
2015-08-03 15:27:09 +02:00
|
|
|
{
|
|
|
|
IcingaApplication::GetInstance()->SetEnableHostChecks(true);
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
return ApiActions::CreateResult(200, "Globally enabled host checks.");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
Dictionary::Ptr ApiActions::StopGlobalExecutingHostChecks(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
2015-08-03 15:27:09 +02:00
|
|
|
{
|
|
|
|
IcingaApplication::GetInstance()->SetEnableHostChecks(false);
|
|
|
|
|
2015-08-20 14:30:34 +02:00
|
|
|
return ApiActions::CreateResult(200, "Globally disabled host checks.");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
2015-08-21 12:47:49 +02:00
|
|
|
//TODO-MA
|
2015-08-03 15:27:09 +02:00
|
|
|
/*
|
|
|
|
Dictionary::Ptr ApiActions::ChangeEventHandler(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
|
|
|
{
|
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
|
|
|
|
|
|
|
if (!checkable)
|
|
|
|
return ApiActions::CreateResult(404, "Cannot change event handler of a non-existent object");
|
|
|
|
|
|
|
|
// empty command string implicitely disables event handler
|
|
|
|
if (!params->Contains("event_command_name")) {
|
|
|
|
checkable->SetEnableEventHandler(false);
|
|
|
|
return ApiActions::CreateResult(200, "Successfully disabled event handler for " + checkable->GetName());
|
|
|
|
} else {
|
|
|
|
String event_name = HttpUtility::GetLastParameter(params, "event_command_name");
|
|
|
|
|
|
|
|
EventCommand::Ptr command = EventCommand::GetByName(event_name);
|
|
|
|
|
|
|
|
if (!command)
|
|
|
|
return ApiActions::CreateResult(404, "Event command '" + event_name + "' does not exist");
|
2015-07-31 17:18:49 +02:00
|
|
|
|
2015-08-03 15:27:09 +02:00
|
|
|
checkable->SetEventCommand(command);
|
|
|
|
|
|
|
|
return ApiActions::CreateResult(200, "Successfully changed event command for " + checkable->GetName());
|
2015-07-31 17:18:49 +02:00
|
|
|
}
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::ChangeCheckCommand(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
|
|
|
{
|
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
|
|
|
|
|
|
|
if (!checkable)
|
|
|
|
return ApiActions::CreateResult(404, "Cannot change check command of a non-existent object");
|
|
|
|
if (!params->Contains("check_command_name"))
|
|
|
|
return ApiActions::CreateResult(403, "Parameter 'check_command_name' is required");
|
|
|
|
|
|
|
|
String check_name = HttpUtility::GetLastParameter(params, "check_command_name");
|
|
|
|
|
|
|
|
CheckCommand::Ptr command = CheckCommand::GetByName(check_name);
|
|
|
|
|
|
|
|
if (!command)
|
|
|
|
return ApiActions::CreateResult(404, "Check command '" + check_name + "' does not exist");
|
|
|
|
|
|
|
|
checkable->SetCheckCommand(command);
|
|
|
|
|
|
|
|
return ApiActions::CreateResult(200, "Successfully changed check command for " + checkable->GetName());
|
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::ChangeMaxCheckAttempts(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
|
|
|
{
|
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
|
|
|
|
|
|
|
if (!checkable)
|
|
|
|
return ApiActions::CreateResult(404, "Cannot change check command of a non-existent object");
|
|
|
|
if (!params->Contains("max_check_attempts"))
|
|
|
|
return ApiActions::CreateResult(403, "Parameter 'max_check_attempts' is required");
|
|
|
|
|
|
|
|
checkable->SetMaxCheckAttempts(HttpUtility::GetLastParameter(params, "max_check_attempts"));
|
|
|
|
|
|
|
|
return ApiActions::CreateResult(200, "Successfully changed the maximum check attempts for " + checkable->GetName());
|
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::ChangeCheckPeriod(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
|
|
|
{
|
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
|
|
|
|
|
|
|
if (!checkable)
|
|
|
|
return ApiActions::CreateResult(404, "Cannot change check command of a non-existent object");
|
|
|
|
if (!params->Contains("time_period_name"))
|
|
|
|
return ApiActions::CreateResult(403, "Parameter 'time_period_name' is required");
|
|
|
|
|
|
|
|
String time_period_name = HttpUtility::GetLastParameter(params, "time_period_name");
|
|
|
|
|
|
|
|
TimePeriod::Ptr time_period = TimePeriod::GetByName(time_period_name);
|
|
|
|
|
|
|
|
if (!time_period)
|
|
|
|
return ApiActions::CreateResult(404, "Time period '" + time_period_name + "' does not exist");
|
|
|
|
|
|
|
|
checkable->SetCheckPeriod(time_period);
|
|
|
|
|
|
|
|
return ApiActions::CreateResult(200, "Successfully changed the time period for " + checkable->GetName());
|
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::ChangeCheckInterval(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
|
|
|
{
|
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
|
|
|
|
|
|
|
if (!checkable)
|
|
|
|
return ApiActions::CreateResult(404, "Cannot change check command of a non-existent object");
|
|
|
|
if (!params->Contains("check_interval"))
|
|
|
|
return ApiActions::CreateResult(403, "Parameter 'check_interval' is required");
|
|
|
|
|
|
|
|
checkable->SetCheckInterval(HttpUtility::GetLastParameter(params, "check_interval"));
|
|
|
|
|
|
|
|
return ApiActions::CreateResult(200, "Successfully changed the check interval for " + checkable->GetName());
|
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::ChangeRetryInterval(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
|
|
|
{
|
|
|
|
Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
|
|
|
|
|
|
|
|
if (!checkable)
|
|
|
|
return ApiActions::CreateResult(404, "Cannot change check command of a non-existent object");
|
|
|
|
if (!params->Contains("retry_interval"))
|
|
|
|
return ApiActions::CreateResult(403, "Parameter 'retry_interval' is required");
|
|
|
|
|
|
|
|
checkable->SetRetryInterval(HttpUtility::GetLastParameter(params, "retry_interval"));
|
|
|
|
|
|
|
|
return ApiActions::CreateResult(200, "Successfully changed the retry interval for " + checkable->GetName());
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2015-08-21 15:50:40 +02:00
|
|
|
Dictionary::Ptr ApiActions::ShutdownProcess(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
2015-08-03 15:27:09 +02:00
|
|
|
{
|
|
|
|
Application::RequestShutdown();
|
|
|
|
|
2015-08-21 15:50:40 +02:00
|
|
|
return ApiActions::CreateResult(200, "Shutting down Icinga2");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary::Ptr ApiActions::RestartProcess(const ConfigObject::Ptr& object, const Dictionary::Ptr& params)
|
|
|
|
{
|
|
|
|
Application::RequestRestart();
|
|
|
|
|
2015-08-21 15:50:40 +02:00
|
|
|
return ApiActions::CreateResult(200, "Restarting Icinga");
|
2015-08-03 15:27:09 +02:00
|
|
|
}
|
|
|
|
|