mirror of https://github.com/Icinga/icinga2.git
compat: dump commands to objects.cache
service->notifications may create duplicates.
This commit is contained in:
parent
91e36eb90d
commit
207b91224b
|
@ -229,6 +229,46 @@ void CompatComponent::DumpComments(std::ostream& fp, const Service::Ptr& owner,
|
|||
}
|
||||
}
|
||||
|
||||
void CompatComponent::DumpTimeperiods(std::ostream& fp, const Service::Ptr& owner)
|
||||
{
|
||||
|
||||
}
|
||||
void CompatComponent::DumpCommands(std::ostream& fp, const Service::Ptr& owner)
|
||||
{
|
||||
/* check_command, event_command -> service
|
||||
* notification_command -> GetNotifications() -> GetNotificationCommand()
|
||||
*/
|
||||
CheckCommand::Ptr check_command = owner->GetCheckCommand();
|
||||
EventCommand::Ptr event_command = owner->GetEventCommand();
|
||||
|
||||
if (check_command) {
|
||||
fp << "define command {" << "\n"
|
||||
<< "\t" << "command_name\t" << check_command->GetName() << "\n"
|
||||
<< "\t" << "command_line\t" << check_command->GetCommandLine() << "\n"
|
||||
<< "\t" << "}" << "\n"
|
||||
<< "\n";
|
||||
}
|
||||
|
||||
if (event_command) {
|
||||
fp << "define command {" << "\n"
|
||||
<< "\t" << "command_name\t" << event_command->GetName() << "\n"
|
||||
<< "\t" << "command_line\t" << event_command->GetCommandLine() << "\n"
|
||||
<< "\t" << "}" << "\n"
|
||||
<< "\n";
|
||||
}
|
||||
BOOST_FOREACH(const Notification::Ptr& notification, owner->GetNotifications()) {
|
||||
NotificationCommand::Ptr notification_command = notification->GetNotificationCommand();
|
||||
if(!notification_command)
|
||||
continue;
|
||||
|
||||
fp << "define command {" << "\n"
|
||||
<< "\t" << "command_name\t" << notification_command->GetName() << "\n"
|
||||
<< "\t" << "command_line\t" << notification_command->GetCommandLine() << "\n"
|
||||
<< "\t" << "}" << "\n"
|
||||
<< "\n";
|
||||
}
|
||||
|
||||
}
|
||||
void CompatComponent::DumpDowntimes(std::ostream& fp, const Service::Ptr& owner, CompatObjectType type)
|
||||
{
|
||||
Host::Ptr host = owner->GetHost();
|
||||
|
@ -546,6 +586,8 @@ void CompatComponent::DumpServiceObject(std::ostream& fp, const Service::Ptr& se
|
|||
<< "\t" << "}" << "\n"
|
||||
<< "\n";
|
||||
}
|
||||
|
||||
DumpCommands(fp, service);
|
||||
}
|
||||
|
||||
void CompatComponent::DumpCustomAttributes(std::ostream& fp, const DynamicObject::Ptr& object)
|
||||
|
|
|
@ -65,6 +65,8 @@ private:
|
|||
String GetObjectsPath(void) const;
|
||||
String GetCommandPath(void) const;
|
||||
|
||||
void DumpCommands(std::ostream& fp, const Service::Ptr& owner);
|
||||
void DumpTimeperiods(std::ostream& fp, const Service::Ptr& owner);
|
||||
void DumpDowntimes(std::ostream& fp, const Service::Ptr& owner, CompatObjectType type);
|
||||
void DumpComments(std::ostream& fp, const Service::Ptr& owner, CompatObjectType type);
|
||||
void DumpHostStatus(std::ostream& fp, const Host::Ptr& host);
|
||||
|
|
|
@ -54,3 +54,8 @@ bool Command::ResolveMacro(const String& macro, const Dictionary::Ptr& cr, Strin
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
String Command::GetCommandLine(void) const
|
||||
{
|
||||
return Get("command");
|
||||
}
|
||||
|
|
|
@ -49,6 +49,8 @@ public:
|
|||
Array::Ptr GetExportMacros(void) const;
|
||||
virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const;
|
||||
|
||||
String GetCommandLine(void) const;
|
||||
|
||||
private:
|
||||
Attribute<Dictionary::Ptr> m_Macros;
|
||||
Attribute<Array::Ptr> m_ExportMacros;
|
||||
|
|
Loading…
Reference in New Issue