mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-06 13:24:28 +02:00
Unify code to check if command exists
This commit is contained in:
parent
96dc349240
commit
4e3a38f320
@ -225,10 +225,11 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons
|
||||
String command = params->Get("command");
|
||||
String command_type = params->Get("command_type");
|
||||
|
||||
if (command_type == "check_command") {
|
||||
if (!CheckCommand::GetByName(command)) {
|
||||
if (command_type == "check_command" && !CheckCommand::GetByName(command) ||
|
||||
command_type == "event_command" && !EventCommand::GetByName(command) ||
|
||||
command_type == "notification_command" && !NotificationCommand::GetByName(command)) {
|
||||
ServiceState state = ServiceUnknown;
|
||||
String output = "Check command '" + command + "' does not exist.";
|
||||
String output = command_type + " '" + command + "' does not exist.";
|
||||
double now = Utility::GetTime();
|
||||
|
||||
if (params->Contains("source")) {
|
||||
@ -265,21 +266,8 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else if (command_type == "event_command") {
|
||||
if (!EventCommand::GetByName(command)) {
|
||||
Log(LogWarning, "ClusterEvents")
|
||||
<< "Event command '" << command << "' does not exist.";
|
||||
return;
|
||||
}
|
||||
} else if (command_type == "notification_command") {
|
||||
if (!NotificationCommand::GetByName(command)) {
|
||||
Log(LogWarning, "ClusterEvents")
|
||||
<< "Notification command '" << command << "' does not exist.";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
attrs->Set(command_type, params->Get("command"));
|
||||
attrs->Set(command_type, command);
|
||||
attrs->Set("command_endpoint", sourceEndpoint->GetName());
|
||||
|
||||
Deserialize(host, attrs, false, FAConfig);
|
||||
|
Loading…
x
Reference in New Issue
Block a user