compat: dump commands to objects.cache

service->notifications may create duplicates.
This commit is contained in:
Michael Friedrich 2013-07-01 20:12:03 +02:00
parent 91e36eb90d
commit 207b91224b
4 changed files with 51 additions and 0 deletions

View File

@ -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) void CompatComponent::DumpDowntimes(std::ostream& fp, const Service::Ptr& owner, CompatObjectType type)
{ {
Host::Ptr host = owner->GetHost(); Host::Ptr host = owner->GetHost();
@ -546,6 +586,8 @@ void CompatComponent::DumpServiceObject(std::ostream& fp, const Service::Ptr& se
<< "\t" << "}" << "\n" << "\t" << "}" << "\n"
<< "\n"; << "\n";
} }
DumpCommands(fp, service);
} }
void CompatComponent::DumpCustomAttributes(std::ostream& fp, const DynamicObject::Ptr& object) void CompatComponent::DumpCustomAttributes(std::ostream& fp, const DynamicObject::Ptr& object)

View File

@ -65,6 +65,8 @@ private:
String GetObjectsPath(void) const; String GetObjectsPath(void) const;
String GetCommandPath(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 DumpDowntimes(std::ostream& fp, const Service::Ptr& owner, CompatObjectType type);
void DumpComments(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); void DumpHostStatus(std::ostream& fp, const Host::Ptr& host);

View File

@ -54,3 +54,8 @@ bool Command::ResolveMacro(const String& macro, const Dictionary::Ptr& cr, Strin
return false; return false;
} }
String Command::GetCommandLine(void) const
{
return Get("command");
}

View File

@ -49,6 +49,8 @@ public:
Array::Ptr GetExportMacros(void) const; Array::Ptr GetExportMacros(void) const;
virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const; virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const;
String GetCommandLine(void) const;
private: private:
Attribute<Dictionary::Ptr> m_Macros; Attribute<Dictionary::Ptr> m_Macros;
Attribute<Array::Ptr> m_ExportMacros; Attribute<Array::Ptr> m_ExportMacros;