/******************************************************************************
* Icinga 2 *
- * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
+ * Copyright (C) 2012-2013 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 *
Host::Ptr host = Host::GetByName(arguments[0]);
- Service::Ptr hc = host->GetHostCheckService();
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot passive host check result for non-existent host '" + arguments[0] + "'"));
+
+ Service::Ptr hc = host->GetCheckService();
if (!hc->GetEnablePassiveChecks())
BOOST_THROW_EXCEPTION(std::invalid_argument("Got passive check result for host '" + arguments[0] + "' which has passive checks disabled."));
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
+ if (!service)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot process passive service check result for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
+
if (!service->GetEnablePassiveChecks())
BOOST_THROW_EXCEPTION(std::invalid_argument("Got passive check result for service '" + arguments[1] + "' which has passive checks disabled."));
Host::Ptr host = Host::GetByName(arguments[0]);
- Service::Ptr hc = host->GetHostCheckService();
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot reschedule host check for non-existent host '" + arguments[0] + "'"));
+
+ Service::Ptr hc = host->GetCheckService();
if (!hc) {
Log(LogInformation, "icinga", "Ignoring request request for host '" +
Host::Ptr host = Host::GetByName(arguments[0]);
- Service::Ptr hc = host->GetHostCheckService();
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot reschedule forced host check for non-existent host '" + arguments[0] + "'"));
+
+ Service::Ptr hc = host->GetCheckService();
if (!hc) {
Log(LogInformation, "icinga", "Ignoring request request for host '" +
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
+ if (!service)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot reschedule service check for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
+
double planned_check = Convert::ToDouble(arguments[2]);
if (planned_check > service->GetNextCheck()) {
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
+ if (!service)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot reschedule forced service check for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Rescheduling next check for service '" + arguments[1] + "'");
{
Host::Ptr host = Host::GetByName(arguments[0]);
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host check non-existent host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Enabling active checks for host '" + arguments[0] + "'");
- Service::Ptr hc = host->GetHostCheckService();
+ Service::Ptr hc = host->GetCheckService();
if (!hc)
return;
Host::Ptr host = Host::GetByName(arguments[0]);
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host check non-existent host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Disabling active checks for host '" + arguments[0] + "'");
- Service::Ptr hc = host->GetHostCheckService();
+ Service::Ptr hc = host->GetCheckService();
if (!hc)
return;
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
+ if (!service)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable service check for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Enabling active checks for service '" + arguments[1] + "'");
{
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
+ if (!service)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable service check for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Disabling active checks for service '" + arguments[1] + "'");
{
Host::Ptr host = Host::GetByName(arguments[0]);
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot reschedule forced host service checks for non-existent host '" + arguments[0] + "'"));
+
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
Log(LogInformation, "icinga", "Rescheduling next check for service '" + service->GetName() + "'");
Host::Ptr host = Host::GetByName(arguments[0]);
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot reschedule host service checks for non-existent host '" + arguments[0] + "'"));
+
if (planned_check < Utility::GetTime())
planned_check = Utility::GetTime();
Host::Ptr host = Host::GetByName(arguments[0]);
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host service checks for non-existent host '" + arguments[0] + "'"));
+
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
Log(LogInformation, "icinga", "Enabling active checks for service '" + service->GetName() + "'");
service->SetEnableActiveChecks(true);
Host::Ptr host = Host::GetByName(arguments[0]);
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host service checks for non-existent host '" + arguments[0] + "'"));
+
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
Log(LogInformation, "icinga", "Disabling active checks for service '" + service->GetName() + "'");
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
+ if (!service)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge service problem for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
+
if (service->GetState() == StateOK)
BOOST_THROW_EXCEPTION(std::invalid_argument("The service '" + arguments[1] + "' is OK."));
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
+ if (!service)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge service problem with expire time for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
+
if (service->GetState() == StateOK)
BOOST_THROW_EXCEPTION(std::invalid_argument("The service '" + arguments[1] + "' is OK."));
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
+ if (!service)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot remove service acknowledgement for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Removing acknowledgement for service '" + service->GetName() + "'");
service->ClearAcknowledgement();
Host::Ptr host = Host::GetByName(arguments[0]);
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge host problem for non-existent host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Setting acknowledgement for host '" + host->GetName() + "'");
- Service::Ptr service = host->GetHostCheckService();
+ Service::Ptr service = host->GetCheckService();
if (service) {
if (service->GetState() == StateOK)
BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + arguments[0] + "' is OK."));
Host::Ptr host = Host::GetByName(arguments[0]);
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot acknowledge host problem with expire time for non-existent host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Setting timed acknowledgement for host '" + host->GetName() + "'");
- Service::Ptr service = host->GetHostCheckService();
+ Service::Ptr service = host->GetCheckService();
if (service) {
if (service->GetState() == StateOK)
BOOST_THROW_EXCEPTION(std::invalid_argument("The host '" + arguments[0] + "' is OK."));
Host::Ptr host = Host::GetByName(arguments[0]);
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot remove acknowledgement for non-existent host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Removing acknowledgement for host '" + host->GetName() + "'");
- Service::Ptr service = host->GetHostCheckService();
+ Service::Ptr service = host->GetCheckService();
if (service)
service->ClearAcknowledgement();
}
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
+ if (!hg)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable hostgroup service checks for non-existent hostgroup '" + arguments[0] + "'"));
+
BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
Log(LogInformation, "icinga", "Enabling active checks for service '" + service->GetName() + "'");
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
+ if (!hg)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable hostgroup service checks for non-existent hostgroup '" + arguments[0] + "'"));
+
BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
Log(LogInformation, "icinga", "Disabling active checks for service '" + service->GetName() + "'");
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
+ if (!sg)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable servicegroup service checks for non-existent servicegroup '" + arguments[0] + "'"));
+
BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
Log(LogInformation, "icinga", "Enabling active checks for service '" + service->GetName() + "'");
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
+ if (!sg)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable servicegroup service checks for non-existent servicegroup '" + arguments[0] + "'"));
+
BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
Log(LogInformation, "icinga", "Disabling active checks for service '" + service->GetName() + "'");
Host::Ptr host = Host::GetByName(arguments[0]);
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable passive host checks for non-existent host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Enabling passive checks for host '" + arguments[0] + "'");
- Service::Ptr hc = host->GetHostCheckService();
+ Service::Ptr hc = host->GetCheckService();
if (!hc)
return;
Host::Ptr host = Host::GetByName(arguments[0]);
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable passive host checks for non-existent host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Disabling passive checks for host '" + arguments[0] + "'");
- Service::Ptr hc = host->GetHostCheckService();
+ Service::Ptr hc = host->GetCheckService();
if (!hc)
return;
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
+ if (!service)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable service checks for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Enabling passive checks for service '" + arguments[1] + "'");
{
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
+ if (!service)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable service checks for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Disabling passive checks for service '" + arguments[1] + "'");
{
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
+ if (!sg)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable servicegroup passive service checks for non-existent servicegroup '" + arguments[0] + "'"));
+
BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
Log(LogInformation, "icinga", "Enabling passive checks for service '" + service->GetName() + "'");
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
+ if (!sg)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable servicegroup passive service checks for non-existent servicegroup '" + arguments[0] + "'"));
+
BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
Log(LogInformation, "icinga", "Disabling passive checks for service '" + service->GetName() + "'");
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
+ if (!hg)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable hostgroup passive service checks for non-existent hostgroup '" + arguments[0] + "'"));
+
BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
Log(LogInformation, "icinga", "Enabling passive checks for service '" + service->GetName() + "'");
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
+ if (!hg)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable hostgroup passive service checks for non-existent hostgroup '" + arguments[0] + "'"));
+
BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
Log(LogInformation, "icinga", "Disabling passive checks for service '" + service->GetName() + "'");
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
+ if (!service)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot schedule service downtime for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
+
String triggeredBy;
int triggeredByLegacy = Convert::ToLong(arguments[5]);
if (triggeredByLegacy != 0)
int id = Convert::ToLong(arguments[0]);
Log(LogInformation, "icinga", "Removing downtime ID " + arguments[0]);
String rid = Service::GetDowntimeIDFromLegacyID(id);
- Service::RemoveDowntime(rid);
+ Service::RemoveDowntime(rid, true);
}
void ExternalCommandProcessor::ScheduleHostDowntime(double, const std::vector<String>& arguments)
Host::Ptr host = Host::GetByName(arguments[0]);
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot schedule host downtime for non-existent host '" + arguments[0] + "'"));
+
String triggeredBy;
int triggeredByLegacy = Convert::ToLong(arguments[4]);
if (triggeredByLegacy != 0)
triggeredBy = Service::GetDowntimeIDFromLegacyID(triggeredByLegacy);
Log(LogInformation, "icinga", "Creating downtime for host " + host->GetName());
- Service::Ptr service = host->GetHostCheckService();
+ Service::Ptr service = host->GetCheckService();
if (service) {
String comment_id = service->AddComment(CommentDowntime, arguments[6], arguments[7], Convert::ToDouble(arguments[2]));
(void) service->AddDowntime(comment_id,
int id = Convert::ToLong(arguments[0]);
Log(LogInformation, "icinga", "Removing downtime ID " + arguments[0]);
String rid = Service::GetDowntimeIDFromLegacyID(id);
- Service::RemoveDowntime(rid);
+ Service::RemoveDowntime(rid, true);
}
void ExternalCommandProcessor::ScheduleHostSvcDowntime(double, const std::vector<String>& arguments)
Host::Ptr host = Host::GetByName(arguments[0]);
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot schedule host services downtime for non-existent host '" + arguments[0] + "'"));
+
String triggeredBy;
int triggeredByLegacy = Convert::ToLong(arguments[4]);
if (triggeredByLegacy != 0)
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
+ if (!hg)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot schedule hostgroup host downtime for non-existent hostgroup '" + arguments[0] + "'"));
+
String triggeredBy;
int triggeredByLegacy = Convert::ToLong(arguments[4]);
if (triggeredByLegacy != 0)
BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
Log(LogInformation, "icinga", "Creating downtime for host " + host->GetName());
- Service::Ptr service = host->GetHostCheckService();
+ Service::Ptr service = host->GetCheckService();
if (service) {
String comment_id = service->AddComment(CommentDowntime, arguments[6], arguments[7], Convert::ToDouble(arguments[2]));
(void) service->AddDowntime(comment_id,
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
+ if (!hg)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot schedule hostgroup service downtime for non-existent hostgroup '" + arguments[0] + "'"));
+
String triggeredBy;
int triggeredByLegacy = Convert::ToLong(arguments[4]);
if (triggeredByLegacy != 0)
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
+ if (!sg)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot schedule servicegroup host downtime for non-existent servicegroup '" + arguments[0] + "'"));
+
String triggeredBy;
int triggeredByLegacy = Convert::ToLong(arguments[4]);
if (triggeredByLegacy != 0)
BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
Host::Ptr host = service->GetHost();
- Service::Ptr hcService = host->GetHostCheckService();
+ Service::Ptr hcService = host->GetCheckService();
if (hcService)
services.insert(hcService);
}
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
+ if (!sg)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot schedule servicegroup service downtime for non-existent servicegroup '" + arguments[0] + "'"));
+
String triggeredBy;
int triggeredByLegacy = Convert::ToLong(arguments[4]);
if (triggeredByLegacy != 0)
Host::Ptr host = Host::GetByName(arguments[0]);
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot add host comment for non-existent host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Creating comment for host " + host->GetName());
- Service::Ptr service = host->GetHostCheckService();
+ Service::Ptr service = host->GetCheckService();
if (service)
(void) service->AddComment(CommentUser, arguments[2], arguments[3], 0);
}
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
+ if (!service)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot add service comment for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Creating comment for service " + service->GetName());
(void) service->AddComment(CommentUser, arguments[3], arguments[4], 0);
}
Host::Ptr host = Host::GetByName(arguments[0]);
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot delete all host comments for non-existent host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Removing all comments for host " + host->GetName());
- Service::Ptr service = host->GetHostCheckService();
+ Service::Ptr service = host->GetCheckService();
if (service)
service->RemoveAllComments();
}
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
+ if (!service)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot delete all service comments for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Removing all comments for service " + service->GetName());
service->RemoveAllComments();
}
BOOST_THROW_EXCEPTION(std::invalid_argument("Expected 4 arguments."));
Host::Ptr host = Host::GetByName(arguments[0]);
+
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot send custom host notification for non-existent host '" + arguments[0] + "'"));
+
int options = Convert::ToLong(arguments[1]);
Log(LogInformation, "icinga", "Sending custom notification for host " + host->GetName());
- Service::Ptr service = host->GetHostCheckService();
+ Service::Ptr service = host->GetCheckService();
if (service) {
if (options & 2) {
ObjectLock olock(service);
BOOST_THROW_EXCEPTION(std::invalid_argument("Expected 5 arguments."));
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
+
+ if (!service)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot send custom service notification for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
+
int options = Convert::ToLong(arguments[2]);
Log(LogInformation, "icinga", "Sending custom notification for service " + service->GetName());
Host::Ptr host = Host::GetByName(arguments[0]);
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot delay host notification for non-existent host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Delaying notifications for host " + host->GetName());
- Service::Ptr hc = host->GetHostCheckService();
+ Service::Ptr hc = host->GetCheckService();
if (!hc)
return;
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
+ if (!service)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot delay service notification for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Delaying notifications for service " + service->GetName());
BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) {
Host::Ptr host = Host::GetByName(arguments[0]);
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host notifications for non-existent host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Enabling notifications for host '" + arguments[0] + "'");
- Service::Ptr hc = host->GetHostCheckService();
+ Service::Ptr hc = host->GetCheckService();
if (!hc)
return;
Host::Ptr host = Host::GetByName(arguments[0]);
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host notifications for non-existent host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Disabling notifications for host '" + arguments[0] + "'");
- Service::Ptr hc = host->GetHostCheckService();
+ Service::Ptr hc = host->GetCheckService();
if (!hc)
return;
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
+ if (!service)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable service notifications for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Enabling notifications for service '" + arguments[1] + "'");
{
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
+ if (!service)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable service notifications for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Disabling notifications for service '" + arguments[1] + "'");
{
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
+ if (!hg)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable hostgroup host checks for non-existent hostgroup '" + arguments[0] + "'"));
+
BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
- Service::Ptr hc = host->GetHostCheckService();
+ Service::Ptr hc = host->GetCheckService();
if (!hc)
continue;
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
+ if (!hg)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable hostgroup passive host checks for non-existent hostgroup '" + arguments[0] + "'"));
+
BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
- Service::Ptr hc = host->GetHostCheckService();
+ Service::Ptr hc = host->GetCheckService();
if (!hc)
continue;
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
+ if (!sg)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable servicegroup host checks for non-existent servicegroup '" + arguments[0] + "'"));
+
BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
Host::Ptr host = service->GetHost();
if (!host)
continue;
- Service::Ptr hc = host->GetHostCheckService();
+ Service::Ptr hc = host->GetCheckService();
if (!hc)
continue;
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
+ if (!sg)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable servicegroup passive host checks for non-existent servicegroup '" + arguments[0] + "'"));
+
BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
Host::Ptr host = service->GetHost();
if (!host)
continue;
- Service::Ptr hc = host->GetHostCheckService();
+ Service::Ptr hc = host->GetCheckService();
if (!hc)
continue;
HostGroup::Ptr hg = HostGroup::GetByName(arguments[0]);
+ if (!hg)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable hostgroup host checks for non-existent hostgroup '" + arguments[0] + "'"));
+
BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
- Service::Ptr hc = host->GetHostCheckService();
+ Service::Ptr hc = host->GetCheckService();
if (!hc)
continue;
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
+ if (!sg)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable servicegroup host checks for non-existent servicegroup '" + arguments[0] + "'"));
+
BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
Host::Ptr host = service->GetHost();
if (!host)
continue;
- Service::Ptr hc = host->GetHostCheckService();
+ Service::Ptr hc = host->GetCheckService();
if (!hc)
continue;
ServiceGroup::Ptr sg = ServiceGroup::GetByName(arguments[0]);
+ if (!sg)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable servicegroup passive host checks for non-existent servicegroup '" + arguments[0] + "'"));
+
BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
Host::Ptr host = service->GetHost();
if (!host)
continue;
- Service::Ptr hc = host->GetHostCheckService();
+ Service::Ptr hc = host->GetCheckService();
if (!hc)
continue;
Host::Ptr host = Host::GetByName(arguments[0]);
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host flapping for non-existent host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Enabling flapping detection for host '" + arguments[0] + "'");
- Service::Ptr hc = host->GetHostCheckService();
+ Service::Ptr hc = host->GetCheckService();
if (!hc)
return;
Host::Ptr host = Host::GetByName(arguments[0]);
+ if (!host)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host flapping for non-existent host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Disabling flapping detection for host '" + arguments[0] + "'");
- Service::Ptr hc = host->GetHostCheckService();
+ Service::Ptr hc = host->GetCheckService();
if (!hc)
return;
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
+ if (!service)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable service flapping for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Enabling flapping detection for service '" + arguments[1] + "'");
{
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
+ if (!service)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable service flapping for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
+
Log(LogInformation, "icinga", "Disabling flapping detection for service '" + arguments[1] + "'");
{