Cli: Add agents.conf w/ default agent templates for 'agent update-config'

refs #7248
This commit is contained in:
Michael Friedrich 2014-10-28 19:46:10 +01:00
parent 20a176680a
commit 64298c35ef
3 changed files with 34 additions and 2 deletions

View File

@ -26,6 +26,7 @@ install_if_not_exists(${CMAKE_CURRENT_BINARY_DIR}/icinga2/init.conf ${CMAKE_INST
install_if_not_exists(icinga2/icinga2.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2)
install_if_not_exists(${CMAKE_CURRENT_BINARY_DIR}/icinga2/constants.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2)
install_if_not_exists(icinga2/zones.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2)
install_if_not_exists(icinga2/conf.d/agent.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/commands.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/downtimes.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/groups.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)

View File

@ -0,0 +1,23 @@
/*
* Host and Service templates for the Agent Setup.
*/
/**
* Provides settings for agent hosts managed by 'icinga2 repository'.
* Define your global agent attributes here, for example custom
* attributes used for notifications, etc.
*/
template Host "agent-host" {
}
/**
* Provides settings for agent services managed by 'icinga2 repository'.
* Define your global agent attributes here, for example custom
* attributes used for notifications, etc.
*/
template Service "agent-service" {
}

View File

@ -118,9 +118,13 @@ int AgentUpdateConfigCommand::Run(const boost::program_options::variables_map& v
Dictionary::Ptr host_attrs = make_shared<Dictionary>();
host_attrs->Set("__name", host);
host_attrs->Set("name", host);
host_attrs->Set("check_command", "dummy"); //TODO: add a repository-host template
host_attrs->Set("check_command", "dummy");
host_attrs->Set("zone", zone);
Array::Ptr host_imports = make_shared<Array>();
host_imports->Add("agent-host"); //default host agent template
host_attrs->Set("import", host_imports);
if (!RepositoryUtility::AddObject(host, "Host", host_attrs)) {
Log(LogCritical, "cli")
<< "Cannot add agent host '" << host << "' to the config repository!\n";
@ -159,9 +163,13 @@ int AgentUpdateConfigCommand::Run(const boost::program_options::variables_map& v
service_attrs->Set("__name", long_name);
service_attrs->Set("name", service);
service_attrs->Set("host_name", host); //Required for host-service relation
service_attrs->Set("check_command", "dummy"); //TODO: add a repository-service template
service_attrs->Set("check_command", "dummy");
service_attrs->Set("zone", zone);
Array::Ptr service_imports = make_shared<Array>();
service_imports->Add("agent-service"); //default service agent template
service_attrs->Set("import", service_imports);
if (!RepositoryUtility::AddObject(service, "Service", service_attrs)) {
Log(LogCritical, "cli")
<< "Cannot add agent host '" << host << "' to the config repository!\n";