Skip to content

Commit

Permalink
Cli: Add agents.conf w/ default agent templates for 'agent update-con…
Browse files Browse the repository at this point in the history
…fig'

refs #7248
  • Loading branch information
Michael Friedrich committed Oct 28, 2014
1 parent 20a1766 commit 64298c3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions etc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 23 additions & 0 deletions etc/icinga2/conf.d/agent.conf
Original file line number Diff line number Diff line change
@@ -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" {

}

12 changes: 10 additions & 2 deletions lib/cli/agentupdateconfigcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 64298c3

Please sign in to comment.