Service::Ptr hc = host->GetCheckService();
+ if (!hc)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot process passive host check result for host '" + arguments[0] + "' which has no check service."));
+
if (!hc->GetEnablePassiveChecks())
BOOST_THROW_EXCEPTION(std::invalid_argument("Got passive check result for host '" + arguments[0] + "' which has passive checks disabled."));
Service::Ptr hc = host->GetCheckService();
- if (!hc) {
- Log(LogInformation, "icinga", "Ignoring request request for host '" +
- arguments[0] + "' (does not have a host check)");
- return;
- }
+ if (!hc)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot reschedule host check for host '" + arguments[0] + "' which has no check service."));
double planned_check = Convert::ToDouble(arguments[1]);
Service::Ptr hc = host->GetCheckService();
- if (!hc) {
- Log(LogInformation, "icinga", "Ignoring request request for host '" +
- arguments[0] + "' (does not have a host check)");
- return;
- }
+ if (!hc)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot reschedule forced host check for host '" + arguments[0] + "' which has no check service."));
Log(LogInformation, "icinga", "Rescheduling next check for host '" + arguments[0] + "'");
Host::Ptr host = Host::GetByName(arguments[0]);
if (!host)
- BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host check non-existent host '" + arguments[0] + "'"));
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host checks for non-existent host '" + arguments[0] + "'"));
- Log(LogInformation, "icinga", "Enabling active checks for host '" + arguments[0] + "'");
Service::Ptr hc = host->GetCheckService();
- if (!hc)
- return;
+ if (!hc)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host checks for host '" + arguments[0] + "' which has no check service."));
+
+ Log(LogInformation, "icinga", "Enabling active checks for host '" + arguments[0] + "'");
{
ObjectLock olock(hc);
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->GetCheckService();
- if (!hc)
- return;
+ if (!hc)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host checks for host '" + arguments[0] + "' which has no check service."));
+
+ Log(LogInformation, "icinga", "Disabling active checks for host '" + arguments[0] + "'");
{
ObjectLock olock(hc);
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->GetCheckService();
- if (!hc)
- return;
+ if (!hc)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable passive host checks for host '" + arguments[0] + "' which has no check service."));
+
+ Log(LogInformation, "icinga", "Enabling passive checks for host '" + arguments[0] + "'");
{
ObjectLock olock(hc);
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->GetCheckService();
- if (!hc)
- return;
+ if (!hc)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable passive host checks for host '" + arguments[0] + "' which has no check service."));
+
+ Log(LogInformation, "icinga", "Disabling passive checks for host '" + arguments[0] + "'");
{
ObjectLock olock(hc);
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->GetCheckService();
- if (!hc)
- return;
+
+ if (!hc)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot delay host notification for host '" + arguments[0] + "' which has no check service."));
+
+ Log(LogInformation, "icinga", "Delaying notifications for host '" + host->GetName() + "'");
BOOST_FOREACH(const Notification::Ptr& notification, hc->GetNotifications()) {
ObjectLock olock(notification);
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->GetCheckService();
- if (!hc)
- return;
+ if (!hc)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host notifications for host '" + arguments[0] + "' which has no check service."));
+
+ Log(LogInformation, "icinga", "Enabling notifications for host '" + arguments[0] + "'");
{
ObjectLock olock(hc);
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->GetCheckService();
- if (!hc)
- return;
+ if (!hc)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host notifications for host '" + arguments[0] + "' which has no check service."));
+
+ Log(LogInformation, "icinga", "Disabling notifications for host '" + arguments[0] + "'");
{
ObjectLock olock(hc);
BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
Service::Ptr hc = host->GetCheckService();
- if (!hc)
- continue;
-
- Log(LogInformation, "icinga", "Disabling active checks for host '" + host->GetName() + "'");
+ if (!hc) {
+ Log(LogInformation, "icinga", "Cannot disable active checks for host '" + host->GetName() + "' which has no check service.");
+ } else {
+ Log(LogInformation, "icinga", "Disabling active checks for host '" + host->GetName() + "'");
- {
- ObjectLock olock(hc);
+ {
+ ObjectLock olock(hc);
- hc->SetEnableActiveChecks(false);
- }
+ hc->SetEnableActiveChecks(false);
+ }
+ }
}
}
BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
Service::Ptr hc = host->GetCheckService();
- if (!hc)
- continue;
-
- Log(LogInformation, "icinga", "Disabling active checks for host '" + host->GetName() + "'");
+ if (!hc) {
+ Log(LogInformation, "icinga", "Cannot disable passive checks for host '" + host->GetName() + "' which has no check service.");
+ } else {
+ Log(LogInformation, "icinga", "Disabling passive checks for host '" + host->GetName() + "'");
- {
- ObjectLock olock(hc);
+ {
+ ObjectLock olock(hc);
- hc->SetEnablePassiveChecks(false);
- }
+ hc->SetEnablePassiveChecks(false);
+ }
+ }
}
}
Service::Ptr hc = host->GetCheckService();
- if (!hc)
- continue;
-
- Log(LogInformation, "icinga", "Disabling active checks for host '" + host->GetName() + "'");
+ if (!hc) {
+ Log(LogInformation, "icinga", "Cannot disable active checks for host '" + host->GetName() + "' which has no check service.");
+ } else {
+ Log(LogInformation, "icinga", "Disabling active checks for host '" + host->GetName() + "'");
- {
- ObjectLock olock(hc);
+ {
+ ObjectLock olock(hc);
- hc->SetEnableActiveChecks(false);
- }
+ hc->SetEnableActiveChecks(false);
+ }
+ }
}
}
Service::Ptr hc = host->GetCheckService();
- if (!hc)
- continue;
+ if (!hc) {
+ Log(LogInformation, "icinga", "Cannot disable passive checks for host '" + host->GetName() + "' which has no check service.");
+ } else {
+ Log(LogInformation, "icinga", "Disabling passive checks for host '" + host->GetName() + "'");
- Log(LogInformation, "icinga", "Disabling active checks for host '" + host->GetName() + "'");
+ {
+ ObjectLock olock(hc);
- {
- ObjectLock olock(hc);
-
- hc->SetEnablePassiveChecks(false);
- }
+ hc->SetEnablePassiveChecks(false);
+ }
+ }
}
}
BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
Service::Ptr hc = host->GetCheckService();
- if (!hc)
- continue;
-
- Log(LogInformation, "icinga", "Enabling active checks for host '" + host->GetName() + "'");
+ if (!hc) {
+ Log(LogInformation, "icinga", "Cannot enable active checks for host '" + host->GetName() + "' which has no check service.");
+ } else {
+ Log(LogInformation, "icinga", "Enabling active checks for host '" + host->GetName() + "'");
- {
- ObjectLock olock(hc);
+ {
+ ObjectLock olock(hc);
- hc->SetEnableActiveChecks(true);
- }
+ hc->SetEnableActiveChecks(true);
+ }
+ }
}
}
Service::Ptr hc = host->GetCheckService();
- if (!hc)
- continue;
-
- Log(LogInformation, "icinga", "Enabling active checks for host '" + host->GetName() + "'");
+ if (!hc) {
+ Log(LogInformation, "icinga", "Cannot enable active checks for host '" + host->GetName() + "' which has no check service.");
+ } else {
+ Log(LogInformation, "icinga", "Enabling active checks for host '" + host->GetName() + "'");
- {
- ObjectLock olock(hc);
+ {
+ ObjectLock olock(hc);
- hc->SetEnableActiveChecks(true);
- }
+ hc->SetEnableActiveChecks(true);
+ }
+ }
}
}
Service::Ptr hc = host->GetCheckService();
- if (!hc)
- continue;
-
- Log(LogInformation, "icinga", "Enabling active checks for host '" + host->GetName() + "'");
+ if (!hc) {
+ Log(LogInformation, "icinga", "Cannot enable passive host checks for host '" + host->GetName() + "' which has no check service.");
+ } else {
+ Log(LogInformation, "icinga", "Enabling passive checks for host '" + host->GetName() + "'");
- {
- ObjectLock olock(hc);
+ {
+ ObjectLock olock(hc);
- hc->SetEnablePassiveChecks(false);
- }
+ hc->SetEnablePassiveChecks(false);
+ }
+ }
}
}
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->GetCheckService();
- if (!hc)
- return;
+ if (!hc)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable host flapping for host '" + arguments[0] + "' which has no check service."));
+
+ Log(LogInformation, "icinga", "Enabling flapping detection for host '" + arguments[0] + "'");
{
ObjectLock olock(hc);
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->GetCheckService();
- if (!hc)
- return;
+ if (!hc)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable host flapping for host '" + arguments[0] + "' which has no check service."));
+
+ Log(LogInformation, "icinga", "Disabling flapping detection for host '" + arguments[0] + "'");
{
ObjectLock olock(hc);
if (!host)
BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot update modified attributes for non-existent host '" + arguments[0] + "'"));
- Log(LogInformation, "icinga", "Updating modified attributes for for host '" + arguments[0] + "'");
Service::Ptr hc = host->GetCheckService();
+ if (!hc)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot update modified attributes for host '" + arguments[0] + "' which has no check service."));
+
+ Log(LogInformation, "icinga", "Updating modified attributes for host '" + arguments[0] + "'");
+
int modifiedAttributes = Convert::ToLong(arguments[1]);
{
if (!host)
BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot update check interval for non-existent host '" + arguments[0] + "'"));
- Log(LogInformation, "icinga", "Updating check interval for for host '" + arguments[0] + "'");
Service::Ptr hc = host->GetCheckService();
+ if (!hc)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot update check interval for host '" + arguments[0] + "' which has no check service."));
+
+ Log(LogInformation, "icinga", "Updating check interval for host '" + arguments[0] + "'");
+
double interval = Convert::ToDouble(arguments[1]);
{
if (!host)
BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot update retry interval for non-existent host '" + arguments[0] + "'"));
- Log(LogInformation, "icinga", "Updating retry interval for for host '" + arguments[0] + "'");
Service::Ptr hc = host->GetCheckService();
+ if (!hc)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot update retry interval for host '" + arguments[0] + "' which has no check service."));
+
+ Log(LogInformation, "icinga", "Updating retry interval for host '" + arguments[0] + "'");
+
double interval = Convert::ToDouble(arguments[1]);
{
Service::Ptr hc = host->GetCheckService();
+ if (!hc)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot enable event handler for host '" + arguments[0] + "' which has no check service."));
+
Log(LogInformation, "icinga", "Enabling event handler for host '" + arguments[0] + "'");
{
Service::Ptr hc = host->GetCheckService();
+ if (!hc)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot disable event handler for host '" + arguments[0] + "' which has no check service."));
+
Log(LogInformation, "icinga", "Disabling event handler for host '" + arguments[0] + "'");
{
Service::Ptr hc = host->GetCheckService();
+ if (!hc)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot change event handler for host '" + arguments[0] + "' which has no check service."));
+
EventCommand::Ptr command = EventCommand::GetByName(arguments[2]);
if (!command)
Service::Ptr hc = host->GetCheckService();
+ if (!hc)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot change check command for host '" + arguments[0] + "' which has no check service."));
+
CheckCommand::Ptr command = CheckCommand::GetByName(arguments[2]);
if (!command)
Service::Ptr hc = host->GetCheckService();
+ if (!hc)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot change max check attempts for host '" + arguments[0] + "' which has no check service."));
+
int attempts = Convert::ToLong(arguments[2]);
Log(LogInformation, "icinga", "Changing max check attempts for host '" + arguments[0] + "' to '" + arguments[1] + "'");
Service::Ptr hc = host->GetCheckService();
+ if (!hc)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot change check period for host '" + arguments[0] + "' which has no check service."));
+
TimePeriod::Ptr tp = TimePeriod::GetByName(arguments[2]);
if (!tp)
service->SetCheckPeriod(tp);
}
-}
\ No newline at end of file
+}