[icinga-checkins] icinga.org: icinga2/master: Fixes host acknowledgement commands.

git at icinga.org git at icinga.org
Sun Jan 27 12:02:26 CET 2013


Module: icinga2
Branch: master
Commit: dbe1e7cdd5da19369994f0983ca784355dfe0645
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=dbe1e7cdd5da19369994f0983ca784355dfe0645

Author: Gunnar Beutner <gunnar at beutner.name>
Date:   Sun Jan 27 12:02:22 2013 +0100

Fixes host acknowledgement commands.

---

 lib/icinga/externalcommand.cpp |   40 ++++++++++++++++++++--------------------
 1 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/lib/icinga/externalcommand.cpp b/lib/icinga/externalcommand.cpp
index 79a4ed1..c82846a 100644
--- a/lib/icinga/externalcommand.cpp
+++ b/lib/icinga/externalcommand.cpp
@@ -363,18 +363,18 @@ void ExternalCommand::RemoveSvcAcknowledgement(double time, const vector<String>
 
 void ExternalCommand::AcknowledgeHostProblem(double time, const vector<String>& arguments)
 {
-	if (arguments.size() < 7)
-		throw_exception(invalid_argument("Expected 7 arguments."));
+	if (arguments.size() < 6)
+		throw_exception(invalid_argument("Expected 6 arguments."));
 
-	if (!Host::Exists(arguments[1]))
-		throw_exception(invalid_argument("The host '" + arguments[1] + "' does not exist."));
+	if (!Host::Exists(arguments[0]))
+		throw_exception(invalid_argument("The host '" + arguments[0] + "' does not exist."));
 
-	int sticky = arguments[2].ToDouble();
+	int sticky = arguments[0].ToDouble();
 
-	Host::Ptr host = Host::GetByName(arguments[1]);
+	Host::Ptr host = Host::GetByName(arguments[0]);
 
 	if (host->IsUp())
-		throw_exception(invalid_argument("The host '" + arguments[1] + "' is OK."));
+		throw_exception(invalid_argument("The host '" + arguments[0] + "' is OK."));
 
 	Logger::Write(LogInformation, "icinga", "Setting acknowledgement for host '" + host->GetName() + "'");
 	host->SetAcknowledgement(sticky ? AcknowledgementSticky : AcknowledgementNormal);
@@ -383,19 +383,19 @@ void ExternalCommand::AcknowledgeHostProblem(double time, const vector<String>&
 
 void ExternalCommand::AcknowledgeHostProblemExpire(double time, const vector<String>& arguments)
 {
-	if (arguments.size() < 8)
-		throw_exception(invalid_argument("Expected 8 arguments."));
+	if (arguments.size() < 7)
+		throw_exception(invalid_argument("Expected 7 arguments."));
 
-	if (!Host::Exists(arguments[1]))
-		throw_exception(invalid_argument("The host '" + arguments[1] + "' does not exist."));
+	if (!Host::Exists(arguments[0]))
+		throw_exception(invalid_argument("The host '" + arguments[0] + "' does not exist."));
 
-	int sticky = arguments[2].ToDouble();
-	double timestamp = arguments[5].ToDouble();
+	int sticky = arguments[1].ToDouble();
+	double timestamp = arguments[4].ToDouble();
 
-	Host::Ptr host = Host::GetByName(arguments[1]);
+	Host::Ptr host = Host::GetByName(arguments[0]);
 
 	if (host->IsUp())
-		throw_exception(invalid_argument("The host '" + arguments[1] + "' is OK."));
+		throw_exception(invalid_argument("The host '" + arguments[0] + "' is OK."));
 
 	Logger::Write(LogInformation, "icinga", "Setting timed acknowledgement for host '" + host->GetName() + "'");
 	host->SetAcknowledgement(sticky ? AcknowledgementSticky : AcknowledgementNormal);
@@ -404,13 +404,13 @@ void ExternalCommand::AcknowledgeHostProblemExpire(double time, const vector<Str
 
 void ExternalCommand::RemoveHostAcknowledgement(double time, const vector<String>& arguments)
 {
-	if (arguments.size() < 2)
-		throw_exception(invalid_argument("Expected 2 arguments."));
+	if (arguments.size() < 1)
+		throw_exception(invalid_argument("Expected 1 argument."));
 
-	if (!Host::Exists(arguments[1]))
-		throw_exception(invalid_argument("The host '" + arguments[1] + "' does not exist."));
+	if (!Host::Exists(arguments[0]))
+		throw_exception(invalid_argument("The host '" + arguments[0] + "' does not exist."));
 
-	Host::Ptr host = Host::GetByName(arguments[1]);
+	Host::Ptr host = Host::GetByName(arguments[0]);
 
 	Logger::Write(LogInformation, "icinga", "Removing acknowledgement for host '" + host->GetName() + "'");
 	host->SetAcknowledgement(AcknowledgementNone);





More information about the icinga-checkins mailing list