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)
--- /dev/null
+/*
+ * 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" {
+
+}
+
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";
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";