]> granicus.if.org Git - icinga2/commitdiff
Cli: Add agents.conf w/ default agent templates for 'agent update-config'
authorMichael Friedrich <michael.friedrich@netways.de>
Tue, 28 Oct 2014 18:46:10 +0000 (19:46 +0100)
committerMichael Friedrich <michael.friedrich@netways.de>
Tue, 28 Oct 2014 18:46:10 +0000 (19:46 +0100)
refs #7248

etc/CMakeLists.txt
etc/icinga2/conf.d/agent.conf [new file with mode: 0644]
lib/cli/agentupdateconfigcommand.cpp

index b4dbe57e09567899de2dd88b75f1a9ce9d73ebf0..03906863e8e6a53fed91c4b5d7542d70fd0001b3 100644 (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)
diff --git a/etc/icinga2/conf.d/agent.conf b/etc/icinga2/conf.d/agent.conf
new file mode 100644 (file)
index 0000000..b69913a
--- /dev/null
@@ -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" {
+
+}
+
index 018c7997ca738cb1601c53e80214fadeab2c8b74..e76b161b99cfb10ef3bec833ba5585abd2091308 100644 (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";