]> granicus.if.org Git - icinga2/commitdiff
Merge 'macros' and 'custom' attributes into 'vars', part 1.
authorMichael Friedrich <michael.friedrich@netways.de>
Thu, 3 Apr 2014 08:30:11 +0000 (10:30 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Thu, 3 Apr 2014 09:35:25 +0000 (11:35 +0200)
Refs #5855

29 files changed:
components/compat/statusdatawriter.cpp
components/livestatus/contactstable.cpp
components/livestatus/hostgroupstable.cpp
components/livestatus/hoststable.cpp
components/livestatus/servicegroupstable.cpp
components/livestatus/servicestable.cpp
doc/3.03-macros.md
doc/4.2-global-variables.md
etc/icinga2/conf.d/generic-host.conf
etc/icinga2/conf.d/localhost.conf
etc/icinga2/conf.d/users.conf
itl/command-common.conf
lib/base/dynamicobject.ti
lib/config/base-type.conf
lib/db_ido/hostdbobject.cpp
lib/db_ido/servicedbobject.cpp
lib/db_ido/userdbobject.cpp
lib/icinga/command.cpp
lib/icinga/compatutility.cpp
lib/icinga/compatutility.h
lib/icinga/host.cpp
lib/icinga/host.ti
lib/icinga/icinga-type.conf
lib/icinga/icingaapplication.cpp
lib/icinga/icingaapplication.h
lib/icinga/notification.cpp
lib/icinga/service.cpp
lib/icinga/service.ti
lib/icinga/user.cpp

index a786ab50a620678174c8948d3fc64f3f74c26da6..65e806c9e37ec4d90eb2d2f92f84568220a3b671 100644 (file)
@@ -516,13 +516,13 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s
 
 void StatusDataWriter::DumpCustomAttributes(std::ostream& fp, const DynamicObject::Ptr& object)
 {
-       Dictionary::Ptr custom = object->GetCustom();
+       Dictionary::Ptr vars = object->GetVars();
 
-       if (!custom)
+       if (!vars)
                return;
 
-       ObjectLock olock(custom);
-       BOOST_FOREACH(const Dictionary::Pair& kv, custom) {
+       ObjectLock olock(vars);
+       BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
                if (!kv.first.IsEmpty()) {
                        fp << "\t";
 
index d18f1217720cf4396b5c605bfff47ce3b50d1801..bf4653237dd8504d78d01baaa74cae21563fce7f 100644 (file)
@@ -47,9 +47,9 @@ void ContactsTable::AddColumns(Table *table, const String& prefix,
        table->AddColumn(prefix + "service_notifications_enabled", Column(&ContactsTable::ServiceNotificationsEnabledAccessor, objectAccessor));
        table->AddColumn(prefix + "in_host_notification_period", Column(&ContactsTable::InHostNotificationPeriodAccessor, objectAccessor));
        table->AddColumn(prefix + "in_service_notification_period", Column(&ContactsTable::InServiceNotificationPeriodAccessor, objectAccessor));
-       table->AddColumn(prefix + "custom_variable_names", Column(&ContactsTable::CustomVariableNamesAccessor, objectAccessor));
-       table->AddColumn(prefix + "custom_variable_values", Column(&ContactsTable::CustomVariableValuesAccessor, objectAccessor));
-       table->AddColumn(prefix + "custom_variables", Column(&ContactsTable::CustomVariablesAccessor, objectAccessor));
+       table->AddColumn(prefix + "vars_variable_names", Column(&ContactsTable::CustomVariableNamesAccessor, objectAccessor));
+       table->AddColumn(prefix + "vars_variable_values", Column(&ContactsTable::CustomVariableValuesAccessor, objectAccessor));
+       table->AddColumn(prefix + "vars_variables", Column(&ContactsTable::CustomVariablesAccessor, objectAccessor));
        table->AddColumn(prefix + "modified_attributes", Column(&ContactsTable::ModifiedAttributesAccessor, objectAccessor));
        table->AddColumn(prefix + "modified_attributes_list", Column(&ContactsTable::ModifiedAttributesListAccessor, objectAccessor));
 }
@@ -93,12 +93,12 @@ Value ContactsTable::EmailAccessor(const Value& row)
        if (!user)
                return Empty;
 
-       Dictionary::Ptr macros = user->GetMacros();
+       Dictionary::Ptr vars = user->GetVars();
 
-       if (!macros)
+       if (!vars)
                return Empty;
 
-       return macros->Get("email");
+       return vars->Get("email");
 }
 
 Value ContactsTable::PagerAccessor(const Value& row)
@@ -108,12 +108,12 @@ Value ContactsTable::PagerAccessor(const Value& row)
        if (!user)
                return Empty;
 
-       Dictionary::Ptr macros = user->GetMacros();
+       Dictionary::Ptr vars = user->GetVars();
 
-       if (!macros)
+       if (!vars)
                return Empty;
 
-       return macros->Get("pager");
+       return vars->Get("pager");
 }
 
 Value ContactsTable::HostNotificationPeriodAccessor(const Value& row)
@@ -204,17 +204,17 @@ Value ContactsTable::CustomVariableNamesAccessor(const Value& row)
        if (!user)
                return Empty;
 
-       Dictionary::Ptr custom = user->GetCustom();
+       Dictionary::Ptr vars = user->GetVars();
 
-       if (!custom)
+       if (!vars)
                return Empty;
 
        Array::Ptr cv = make_shared<Array>();
 
-       ObjectLock olock(custom);
+       ObjectLock olock(vars);
        String key;
        Value value;
-       BOOST_FOREACH(boost::tie(key, value), custom) {
+       BOOST_FOREACH(boost::tie(key, value), vars) {
                if (key == "notes" ||
                    key == "action_url" ||
                    key == "notes_url" ||
@@ -237,17 +237,17 @@ Value ContactsTable::CustomVariableValuesAccessor(const Value& row)
        if (!user)
                return Empty;
 
-       Dictionary::Ptr custom = user->GetCustom();
+       Dictionary::Ptr vars = user->GetVars();
 
-       if (!custom)
+       if (!vars)
                return Empty;
 
        Array::Ptr cv = make_shared<Array>();
 
-       ObjectLock olock(custom);
+       ObjectLock olock(vars);
        String key;
        Value value;
-       BOOST_FOREACH(boost::tie(key, value), custom) {
+       BOOST_FOREACH(boost::tie(key, value), vars) {
                if (key == "notes" ||
                    key == "action_url" ||
                    key == "notes_url" ||
@@ -270,17 +270,17 @@ Value ContactsTable::CustomVariablesAccessor(const Value& row)
        if (!user)
                return Empty;
 
-       Dictionary::Ptr custom = user->GetCustom();
+       Dictionary::Ptr vars = user->GetVars();
 
-       if (!custom)
+       if (!vars)
                return Empty;
 
        Array::Ptr cv = make_shared<Array>();
 
-       ObjectLock olock(custom);
+       ObjectLock olock(vars);
        String key;
        Value value;
-       BOOST_FOREACH(boost::tie(key, value), custom) {
+       BOOST_FOREACH(boost::tie(key, value), vars) {
                if (key == "notes" ||
                    key == "action_url" ||
                    key == "notes_url" ||
index 5ff8ad5bec9b8b4f5cfb9c4fdccbff91469c5854..8557959e55b69ecebebbea6af0f00d9fb894de5f 100644 (file)
@@ -85,32 +85,32 @@ Value HostGroupsTable::AliasAccessor(const Value& row)
 
 Value HostGroupsTable::NotesAccessor(const Value& row)
 {
-       Dictionary::Ptr custom = static_cast<HostGroup::Ptr>(row)->GetCustom();
+       Dictionary::Ptr vars = static_cast<HostGroup::Ptr>(row)->GetVars();
 
-       if (!custom)
+       if (!vars)
                return Empty;
 
-       return custom->Get("notes");
+       return vars->Get("notes");
 }
 
 Value HostGroupsTable::NotesUrlAccessor(const Value& row)
 {
-       Dictionary::Ptr custom = static_cast<HostGroup::Ptr>(row)->GetCustom();
+       Dictionary::Ptr vars = static_cast<HostGroup::Ptr>(row)->GetVars();
 
-       if (!custom)
+       if (!vars)
                return Empty;
 
-       return custom->Get("notes_url");
+       return vars->Get("notes_url");
 }
 
 Value HostGroupsTable::ActionUrlAccessor(const Value& row)
 {
-       Dictionary::Ptr custom = static_cast<HostGroup::Ptr>(row)->GetCustom();
+       Dictionary::Ptr vars = static_cast<HostGroup::Ptr>(row)->GetVars();
 
-       if (!custom)
+       if (!vars)
                return Empty;
 
-       return custom->Get("action_url");
+       return vars->Get("action_url");
 }
 
 Value HostGroupsTable::MembersAccessor(const Value& row)
index 281faeaff7514f68edabd765d0b9741a4606488c..243dd4f2d276476ce7c36e6a24cdbeb0a2d4d7c6 100644 (file)
@@ -1372,21 +1372,21 @@ Value HostsTable::CustomVariableNamesAccessor(const Value& row)
        if (!host)
                return Empty;
 
-       Dictionary::Ptr customvars;
+       Dictionary::Ptr vars;
 
        {
                ObjectLock olock(host);
-               customvars = CompatUtility::GetCustomVariableConfig(host);
+               vars = CompatUtility::GetCustomAttributeConfig(host);
        }
 
-       if (!customvars)
+       if (!vars)
                return Empty;
 
        Array::Ptr cv = make_shared<Array>();
 
        String key;
        Value value;
-       BOOST_FOREACH(boost::tie(key, value), customvars) {
+       BOOST_FOREACH(boost::tie(key, value), vars) {
                cv->Add(key);
        }
 
@@ -1400,21 +1400,21 @@ Value HostsTable::CustomVariableValuesAccessor(const Value& row)
        if (!host)
                return Empty;
 
-       Dictionary::Ptr customvars;
+       Dictionary::Ptr vars;
 
        {
                ObjectLock olock(host);
-               customvars = CompatUtility::GetCustomVariableConfig(host);
+               vars = CompatUtility::GetCustomAttributeConfig(host);
        }
 
-       if (!customvars)
+       if (!vars)
                return Empty;
 
        Array::Ptr cv = make_shared<Array>();
 
        String key;
        Value value;
-       BOOST_FOREACH(boost::tie(key, value), customvars) {
+       BOOST_FOREACH(boost::tie(key, value), vars) {
                cv->Add(value);
        }
 
@@ -1428,21 +1428,21 @@ Value HostsTable::CustomVariablesAccessor(const Value& row)
        if (!host)
                return Empty;
 
-       Dictionary::Ptr customvars;
+       Dictionary::Ptr vars;
 
        {
                ObjectLock olock(host);
-               customvars = CompatUtility::GetCustomVariableConfig(host);
+               vars = CompatUtility::GetCustomAttributeConfig(host);
        }
 
-       if (!customvars)
+       if (!vars)
                return Empty;
 
        Array::Ptr cv = make_shared<Array>();
 
        String key;
        Value value;
-       BOOST_FOREACH(boost::tie(key, value), customvars) {
+       BOOST_FOREACH(boost::tie(key, value), vars) {
                Array::Ptr key_val = make_shared<Array>();
                key_val->Add(key);
                key_val->Add(value);
index e3373d3cfe39c200dbc3dc30115095feb72b615c..6b6febfac75af29195af6f2a0b29612df27ac529 100644 (file)
@@ -76,32 +76,32 @@ Value ServiceGroupsTable::AliasAccessor(const Value& row)
 
 Value ServiceGroupsTable::NotesAccessor(const Value& row)
 {
-       Dictionary::Ptr custom = static_cast<ServiceGroup::Ptr>(row)->GetCustom();
+       Dictionary::Ptr vars = static_cast<ServiceGroup::Ptr>(row)->GetVars();
 
-       if (!custom)
+       if (!vars)
                return Empty;
 
-       return custom->Get("notes");
+       return vars->Get("notes");
 }
 
 Value ServiceGroupsTable::NotesUrlAccessor(const Value& row)
 {
-       Dictionary::Ptr custom = static_cast<ServiceGroup::Ptr>(row)->GetCustom();
+       Dictionary::Ptr vars = static_cast<ServiceGroup::Ptr>(row)->GetVars();
 
-       if (!custom)
+       if (!vars)
                return Empty;
 
-       return custom->Get("notes_url");
+       return vars->Get("notes_url");
 }
 
 Value ServiceGroupsTable::ActionUrlAccessor(const Value& row)
 {
-       Dictionary::Ptr custom = static_cast<ServiceGroup::Ptr>(row)->GetCustom();
+       Dictionary::Ptr vars = static_cast<ServiceGroup::Ptr>(row)->GetVars();
 
-       if (!custom)
+       if (!vars)
                return Empty;
 
-       return custom->Get("action_url");
+       return vars->Get("action_url");
 }
 
 Value ServiceGroupsTable::MembersAccessor(const Value& row)
index 664729d580db27ba222e5c0c0fa8850ee9e0ab3e..0fa3bfef2d29a1836e8f7dcaad7f0e7761fa7d75 100644 (file)
@@ -1049,21 +1049,21 @@ Value ServicesTable::CustomVariableNamesAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       Dictionary::Ptr customvars;
+       Dictionary::Ptr vars;
 
        {
                ObjectLock olock(service);
-               customvars = CompatUtility::GetCustomVariableConfig(service);
+               vars = CompatUtility::GetCustomAttributeConfig(service);
        }
 
-       if (!customvars)
+       if (!vars)
                return Empty;
 
        Array::Ptr cv = make_shared<Array>();
 
        String key;
        Value value;
-       BOOST_FOREACH(boost::tie(key, value), customvars) {
+       BOOST_FOREACH(boost::tie(key, value), vars) {
                cv->Add(key);
        }
 
@@ -1077,21 +1077,21 @@ Value ServicesTable::CustomVariableValuesAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       Dictionary::Ptr customvars;
+       Dictionary::Ptr vars;
 
        {
                ObjectLock olock(service);
-               customvars = CompatUtility::GetCustomVariableConfig(service);
+               vars = CompatUtility::GetCustomAttributeConfig(service);
        }
 
-       if (!customvars)
+       if (!vars)
                return Empty;
 
        Array::Ptr cv = make_shared<Array>();
 
        String key;
        Value value;
-       BOOST_FOREACH(boost::tie(key, value), customvars) {
+       BOOST_FOREACH(boost::tie(key, value), vars) {
                cv->Add(value);
        }
 
@@ -1105,21 +1105,21 @@ Value ServicesTable::CustomVariablesAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       Dictionary::Ptr customvars;
+       Dictionary::Ptr vars;
 
        {
                ObjectLock olock(service);
-               customvars = CompatUtility::GetCustomVariableConfig(service);
+               vars = CompatUtility::GetCustomAttributeConfig(service);
        }
 
-       if (!customvars)
+       if (!vars)
                return Empty;
 
        Array::Ptr cv = make_shared<Array>();
 
        String key;
        Value value;
-       BOOST_FOREACH(boost::tie(key, value), customvars) {
+       BOOST_FOREACH(boost::tie(key, value), vars) {
                Array::Ptr key_val = make_shared<Array>();
                key_val->Add(key);
                key_val->Add(value);
index ab1300cd1a50604a8e5cabfd5c8346f8945a4734..25488fca44484069b9b5499540dee75d93fe3a7d 100644 (file)
@@ -66,7 +66,7 @@ up macros:
 2. Service object
 3. Host object
 4. Command object
-5. Global macros in the IcingaMacros constant
+5. Global custom attributes in the IcingaVars constant
 
 This execution order allows you to define default values for macros in your
 command objects. The `my-ping` command shown above uses this to set default
index 169e10295a807450c1cba8835a116008300c73c7..6d018b39dc472bf7b1ee700171d6e9b2464ea714 100644 (file)
@@ -10,7 +10,7 @@ IcingaLocalStateDir       |**Read-only.** Contains the path of the local state d
 IcingaPkgDataDir          |**Read-only.** Contains the path of the package data directory. Defaults to IcingaPrefixDir + "/share/icinga2".
 IcingaStatePath           |**Read-write.** Contains the path of the Icinga 2 state file. Defaults to IcingaLocalStateDir + "/lib/icinga2/icinga2.state".
 IcingaPidPath             |**Read-write.** Contains the path of the Icinga 2 PID file. Defaults to IcingaLocalStateDir + "/run/icinga2/icinga2.pid".
-IcingaMacros              |**Read-write.** Contains a dictionary with global macros. Not set by default.
+IcingaVars                |**Read-write.** Contains a dictionary with global custom attributes. Not set by default.
 IcingaNodeName            |**Read-write.** Contains the cluster node name. Set to the local hostname by default.
 ApplicationType           |**Read-write.** Contains the name of the Application type. Defaults to "icinga/IcingaApplication".
 IcingaEnableNotifications |**Read-write.** Whether notifications are globally enabled. Defaults to true.
index 28be6ae8a3aad949841863400013c49f36d55b4e..659071c2d0a856de64992a793f98a40a88ce99ef 100644 (file)
@@ -12,7 +12,7 @@ apply Service "ping4" {
   check_command = "ping4"
 
   assign where "generic-host" in host.templates
-  ignore where !host.macros.address
+  ignore where !host.vars.address
 }
 
 apply Service "ping6" {
@@ -21,7 +21,7 @@ apply Service "ping6" {
   check_command = "ping6"
 
   assign where "generic-host" in host.templates
-  ignore where !host.macros.address6
+  ignore where !host.vars.address6
 }
 
 template Host "linux-server" {
index 60c5f519baea8250a8aa14b0fda3c74d0ef8ee5f..c0212a0f1c351df034ee46ffc7b5a4d130ca706e 100644 (file)
@@ -6,8 +6,8 @@
 object Host "localhost" {
   import "linux-server"
 
-  macros.address = "127.0.0.1"
-  macros.address6 = "::1"
+  vars.address = "127.0.0.1"
+  vars.address6 = "::1"
 }
 
 apply Service "icinga" {
index 50183957d3cb720d3934e5d28b1d8315797baf1a..762184f568da8e0d1438cc797651318f3c890203 100644 (file)
@@ -9,13 +9,11 @@ object User "icingaadmin" {
   display_name = "Icinga 2 Admin"
   groups = [ "icingaadmins" ]
 
-  macros = {
-    name = "Icinga 2 Admin"
-    email = "icinga@localhost"
-    pager = "icingaadmin@localhost.localdomain"
-  }
+  vars.name = "Icinga 2 Admin"
+  vars.email = "icinga@localhost"
+  vars.pager = "icingaadmin@localhost.localdomain"
 
-  custom.notes = "This is the Icinga 2 Admin account."
+  vars.notes = "This is the Icinga 2 Admin account."
 }
 
 
index 28afbab6e456c0d29165b228295c4ed7db5cc8e6..73e3536e00bd2e92647fec70f81fabfe8c7b132e 100644 (file)
@@ -30,16 +30,14 @@ object CheckCommand "ping4" {
                "-t", "$timeout$"
        ],
 
-       macros = {
-               wrta = 100,
-               wpl = 5,
+       vars.wrta = 100,
+       vars.wpl = 5,
 
-               crta = 200,
-               cpl = 15,
+       vars.crta = 200,
+       vars.cpl = 15,
 
-               packets = 5,
-               timeout = 0
-       }
+       vars.packets = 5,
+       vars.timeout = 0
 }
 
 object CheckCommand "ping6" {
@@ -55,16 +53,14 @@ object CheckCommand "ping6" {
                "-t", "$timeout$"
        ],
 
-       macros = {
-               wrta = 100,
-               wpl = 5,
+       vars.wrta = 100,
+       vars.wpl = 5,
 
-               crta = 200,
-               cpl = 15,
+       vars.crta = 200,
+       vars.cpl = 15,
 
-               packets = 5,
-               timeout = 0
-       }
+       vars.packets = 5,
+       vars.timeout = 0
 }
 
 object CheckCommand "dummy" {
@@ -76,19 +72,15 @@ object CheckCommand "dummy" {
                "$text$"
        ],
 
-       macros = {
-               state = 0,
-               text = "Check was successful."
-       }
+       vars.state = 0,
+       vars.text = "Check was successful."
 }
 
 object CheckCommand "passive" {
        import "dummy",
 
-       macros = {
-               state = 3,
-               text = "No Passive Check Result Received."
-       }
+       vars.state = 3,
+       vars.text = "No Passive Check Result Received."
 }
 
 object CheckCommand "tcp" {
@@ -165,7 +157,7 @@ object CheckCommand "ssmtp" {
                "-p", "$port$"
        ],
 
-       macros.port = 465
+       vars.port = 465
 }
 
 object CheckCommand "ntp_time" {
@@ -195,10 +187,8 @@ object CheckCommand "disk" {
                "-c", "$cfree$%"
        ],
 
-       macros = {
-               wfree = 20,
-               cfree = 10,
-       }
+       vars.wfree = 20,
+       vars.cfree = 10,
 }
 
 object CheckCommand "users"{
@@ -210,10 +200,8 @@ object CheckCommand "users"{
                "-c", "$cgreater$"
        ],
 
-       macros = {
-               wgreater = 20,
-               cgreater = 50,
-       }
+       vars.wgreater = 20,
+       vars.cgreater = 50,
 }
 
 object CheckCommand "processes"{
@@ -225,10 +213,8 @@ object CheckCommand "processes"{
                "-c", "$cgreater$"
        ],
 
-       macros = {
-               wgreater = 250,
-               cgreater = 400,
-       }
+       vars.wgreater = 250,
+       vars.cgreater = 400,
 }
 
 object CheckCommand "load"{
@@ -240,15 +226,13 @@ object CheckCommand "load"{
                "-c", "$cload1$,$cload5$,$cload15$"
        ],
 
-       macros = {
-               wload1 = 5.0,
-               wload5 = 4.0,
-               wload15 = 3.0,
+       vars.wload1 = 5.0,
+       vars.wload5 = 4.0,
+       vars.wload15 = 3.0,
 
-               cload1 = 10.0,
-               cload5 = 6.0,
-               cload15 = 4.0
-       }
+       vars.cload1 = 10.0,
+       vars.cload5 = 6.0,
+       vars.cload15 = 4.0
 }
 
 object CheckCommand "snmp"{
@@ -261,13 +245,13 @@ object CheckCommand "snmp"{
                "-C", "$community$"
        ],
 
-       macros.community = "public"
+       vars.community = "public"
 }
 
 object CheckCommand "snmp-uptime"{
        import "snmp",
 
-       macros.oid = "1.3.6.1.2.1.1.3.0"
+       vars.oid = "1.3.6.1.2.1.1.3.0"
 }
 
 object CheckCommand "icinga"{
@@ -290,5 +274,5 @@ object CheckCommand "snmp-extend"{
                "$plugin$"
        ],
 
-       macros.community = "public"
+       vars.community = "public"
 }
index 682eb228d07589c4fc16d985189d95658972447a..ca18ea159e62d7d57ac0f3f45123f4b3bb06bc21 100644 (file)
@@ -7,7 +7,7 @@ abstract class DynamicObject
        [config, get_protected] String type (TypeName);
        [config, get_protected] Array::Ptr templates;
        [config] Dictionary::Ptr methods;
-       [config] Dictionary::Ptr custom;
+       [config] Dictionary::Ptr vars;
        [config] Array::Ptr domains;
        [config] Array::Ptr authorities;
        [get_protected] bool active;
index 66411d72697c95003e3ee847d70347c5bbc09192..d4648e741d26cfce4880ffaca2130f9076681071 100644 (file)
@@ -30,7 +30,7 @@
 
        %attribute %dictionary "methods",
 
-       %attribute %dictionary "custom" {
+       %attribute %dictionary "vars" {
                %attribute %string "*"
        },
 
index 2d8692378c001ca20bb4d89d9b0cdcf25948c31e..787e84ecfd1e6a68213c4e7f7216281be1eea343 100644 (file)
@@ -277,18 +277,18 @@ void HostDbObject::OnConfigUpdate(void)
        }
 
        /* custom variables */
-       Dictionary::Ptr customvars;
+       Dictionary::Ptr vars;
        {
                ObjectLock olock(host);
-               customvars = CompatUtility::GetCustomVariableConfig(host);
+               vars = CompatUtility::GetCustomAttributeConfig(host);
        }
 
-       if (customvars) {
-               Log(LogDebug, "ido", "Dumping host customvars for '" + host->GetName() + "'");
+       if (vars) {
+               Log(LogDebug, "ido", "Dumping host vars for '" + host->GetName() + "'");
 
-               ObjectLock olock (customvars);
+               ObjectLock olock (vars);
 
-               BOOST_FOREACH(const Dictionary::Pair& kv, customvars) {
+               BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
                        if (!kv.first.IsEmpty()) {
                                Log(LogDebug, "db_ido", "host customvar key: '" + kv.first + "' value: '" + Convert::ToString(kv.second) + "'");
 
index 208e516fa9c315238b21504fb88fef43688e7de4..cdc94252f93c35b317f32747445b2446096a5641 100644 (file)
@@ -264,19 +264,19 @@ void ServiceDbObject::OnConfigUpdate(void)
        }
 
        /* custom variables */
-       Dictionary::Ptr customvars;
+       Dictionary::Ptr vars;
 
        {
                ObjectLock olock(service);
-               customvars = CompatUtility::GetCustomVariableConfig(service);
+               vars = CompatUtility::GetCustomAttributeConfig(service);
        }
 
-       if (customvars) {
-               Log(LogDebug, "db_ido", "Dumping service customvars for '" + service->GetName() + "'");
+       if (vars) {
+               Log(LogDebug, "db_ido", "Dumping service vars for '" + service->GetName() + "'");
 
-               ObjectLock olock(customvars);
+               ObjectLock olock(vars);
 
-               BOOST_FOREACH(const Dictionary::Pair& kv, customvars) {
+               BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
                        if (!kv.first.IsEmpty()) {
                                Log(LogDebug, "db_ido", "service customvar key: '" + kv.first + "' value: '" + Convert::ToString(kv.second) + "'");
 
index f5cdb95df7a7f55404131786f1a500a16ea313e7..01389bcb4db47a6010fb175c1b9a58e3fa9f971b 100644 (file)
@@ -42,11 +42,11 @@ Dictionary::Ptr UserDbObject::GetConfigFields(void) const
 
        fields->Set("alias", user->GetDisplayName());
 
-       Dictionary::Ptr macros = user->GetMacros();
+       Dictionary::Ptr vars = user->GetVars();
 
-       if (macros) { /* Yuck. */
-               fields->Set("email_address", macros->Get("email"));
-               fields->Set("pager_address", macros->Get("pager"));
+       if (vars) { /* Yuck. */
+               fields->Set("email_address", vars->Get("email"));
+               fields->Set("pager_address", vars->Get("pager"));
        }
 
        fields->Set("host_timeperiod_object_id", user->GetNotificationPeriod());
@@ -93,12 +93,12 @@ void UserDbObject::OnConfigUpdate(void)
        /* contact addresses */
        Log(LogDebug, "db_ido", "contact addresses for '" + user->GetName() + "'");
 
-       Dictionary::Ptr macros = user->GetMacros();
+       Dictionary::Ptr vars = user->GetVars();
 
-       if (macros) { /* This is sparta. */
+       if (vars) { /* This is sparta. */
                for (int i = 1; i <= 6; i++) {
                        String key = "address" + Convert::ToString(i);
-                       String val = macros->Get(key);
+                       String val = vars->Get(key);
 
                        if (val.IsEmpty())
                                continue;
index cb0c8ef07ccc19b62c43945332c0d790dca6cc08..f419f52b49215ec47af17b8321522b8dc1f71606 100644 (file)
@@ -25,10 +25,10 @@ REGISTER_TYPE(Command);
 
 bool Command::ResolveMacro(const String& macro, const CheckResult::Ptr&, String *result) const
 {
-       Dictionary::Ptr macros = GetMacros();
+       Dictionary::Ptr vars = GetVars();
 
-       if (macros && macros->Contains(macro)) {
-               *result = macros->Get(macro);
+       if (vars && vars->Contains(macro)) {
+               *result = vars->Get(macro);
                return true;
        }
 
index 5012161841d1557e89d492eccd15e9b3441179bc..252b3385b366190034969e69758404a6fb535083 100644 (file)
@@ -73,12 +73,12 @@ String CompatUtility::GetHostAddress(const Host::Ptr& host)
 {
        ASSERT(host->OwnsLock());
 
-       Dictionary::Ptr macros = host->GetMacros();
+       Dictionary::Ptr vars = host->GetVars();
 
        String address;
 
-       if (macros)
-               address = macros->Get("address");
+       if (vars)
+               address = vars->Get("address");
 
        if (address.IsEmpty())
                address = host->GetName();
@@ -90,12 +90,12 @@ String CompatUtility::GetHostAddress6(const Host::Ptr& host)
 {
        ASSERT(host->OwnsLock());
 
-       Dictionary::Ptr macros = host->GetMacros();
+       Dictionary::Ptr vars = host->GetVars();
 
        String address6;
 
-       if (macros)
-               address6 = macros->Get("address6");
+       if (vars)
+               address6 = vars->Get("address6");
 
        if (address6.IsEmpty())
                address6 = host->GetName();
@@ -107,11 +107,11 @@ Host2dCoords CompatUtility::GetHost2dCoords(const Host::Ptr& host)
 {
        ASSERT(host->OwnsLock());
 
-       Dictionary::Ptr custom = host->GetCustom();
+       Dictionary::Ptr vars = host->GetVars();
        Host2dCoords bag;
 
-       if (custom) {
-               String coords = custom->Get("2d_coords");
+       if (vars) {
+               String coords = vars->Get("2d_coords");
                bag.have_2d_coords = (!coords.IsEmpty() ? 1 : 0);
 
                std::vector<String> tokens;
@@ -428,67 +428,71 @@ int CompatUtility::GetServiceInNotificationPeriod(const Service::Ptr& service)
        return 1;
 }
 
-/* custom attr */
-Dictionary::Ptr CompatUtility::GetCustomVariableConfig(const DynamicObject::Ptr& object)
+/* vars attr */
+Dictionary::Ptr CompatUtility::GetCustomAttributeConfig(const DynamicObject::Ptr& object)
 {
        ASSERT(object->OwnsLock());
 
-       Dictionary::Ptr custom;
+       Dictionary::Ptr vars;
 
        if (object->GetType() == DynamicType::GetByName("Host")) {
-               custom = static_pointer_cast<Host>(object)->GetCustom();
+               vars = static_pointer_cast<Host>(object)->GetVars();
        } else if (object->GetType() == DynamicType::GetByName("Service")) {
-               custom = static_pointer_cast<Service>(object)->GetCustom();
+               vars = static_pointer_cast<Service>(object)->GetVars();
        } else if (object->GetType() == DynamicType::GetByName("User")) {
-               custom = static_pointer_cast<User>(object)->GetCustom();
+               vars = static_pointer_cast<User>(object)->GetVars();
        } else {
-               Log(LogDebug, "icinga", "unknown object type for custom vars");
+               Log(LogDebug, "icinga", "unknown object type for vars vars");
                return Dictionary::Ptr();
        }
 
-       Dictionary::Ptr customvars = make_shared<Dictionary>();
+       Dictionary::Ptr varsvars = make_shared<Dictionary>();
 
-       if (!custom)
+       if (!vars)
                return Dictionary::Ptr();
 
-       ObjectLock olock(custom);
-       BOOST_FOREACH(const Dictionary::Pair& kv, custom) {
+       ObjectLock olock(vars);
+       BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
                if (!kv.first.IsEmpty()) {
-                       if (kv.first != "notes" &&
+                       if (kv.first != "address" &&
+                           kv.first != "address6" &&
+                           kv.first != "email" &&
+                           kv.first != "pager" &&
+                           kv.first != "notes" &&
                            kv.first != "action_url" &&
                            kv.first != "notes_url" &&
                            kv.first != "icon_image" &&
                            kv.first != "icon_image_alt" &&
                            kv.first != "statusmap_image" &&
                            kv.first != "2d_coords")
-                               customvars->Set(kv.first, kv.second);
+                               varsvars->Set(kv.first, kv.second);
                }
        }
 
-       return customvars;
+       return varsvars;
 }
 
 String CompatUtility::GetCustomAttributeConfig(const DynamicObject::Ptr& object, const String& name)
 {
        ASSERT(object->OwnsLock());
 
-       Dictionary::Ptr custom;
+       Dictionary::Ptr vars;
 
        if (object->GetType() == DynamicType::GetByName("Host")) {
-               custom = static_pointer_cast<Host>(object)->GetCustom();
+               vars = static_pointer_cast<Host>(object)->GetVars();
        } else if (object->GetType() == DynamicType::GetByName("Service")) {
-               custom = static_pointer_cast<Service>(object)->GetCustom();
+               vars = static_pointer_cast<Service>(object)->GetVars();
        } else if (object->GetType() == DynamicType::GetByName("User")) {
-               custom = static_pointer_cast<User>(object)->GetCustom();
+               vars = static_pointer_cast<User>(object)->GetVars();
        } else {
-               Log(LogDebug, "icinga", "unknown object type for custom attributes");
+               Log(LogDebug, "icinga", "unknown object type for vars attributes");
                return Empty;
        }
 
-       if (!custom)
+       if (!vars)
                return Empty;
 
-       return custom->Get(name);
+       return vars->Get(name);
 }
 
 /* notifications */
index 8c64eee554f1ab2ddfd8daeb80f9cbc15a7d345c..836eedef357146155a9375e3a63fcb10c29d5da4 100644 (file)
@@ -121,7 +121,7 @@ public:
 
        /* custom attribute */
        static String GetCustomAttributeConfig(const DynamicObject::Ptr& object, const String& name);
-       static Dictionary::Ptr GetCustomVariableConfig(const DynamicObject::Ptr& object);
+       static Dictionary::Ptr GetCustomAttributeConfig(const DynamicObject::Ptr& object);
 
        /* check result */
        static String GetCheckResultOutput(const CheckResult::Ptr& cr);
index 486cf4229f72bf2f5a8750127984ed38137bbb83..baeba55c08869bd3b92d3a83c0790d88089b44fb 100644 (file)
@@ -502,13 +502,13 @@ bool Host::ResolveMacro(const String& macro, const CheckResult::Ptr&, String *re
                }
        }
 
+       Dictionary::Ptr vars = GetVars();
+
        if (macro.SubStr(0, 5) == "_HOST") {
-               Dictionary::Ptr custom = GetCustom();
-               *result = custom ? custom->Get(macro.SubStr(5)) : "";
+               *result = vars ? vars->Get(macro.SubStr(5)) : "";
                return true;
        }
 
-       Dictionary::Ptr macros = GetMacros();
 
        String name = macro;
 
@@ -517,8 +517,8 @@ bool Host::ResolveMacro(const String& macro, const CheckResult::Ptr&, String *re
        else if (macro == "HOSTADDRESS6")
                name = "address6";
 
-       if (macros && macros->Contains(name)) {
-               *result = macros->Get(name);
+       if (vars && vars->Contains(name)) {
+               *result = vars->Get(name);
                return true;
        }
 
index a82b3a877242a60114ba3da153ae746bb7bbab91..921a0a1c6befc38103a8fc4930fb4b79063b3a02 100644 (file)
@@ -14,7 +14,6 @@ class Host : DynamicObject
                }}}
        };
        [config] Array::Ptr groups;
-       [config] Dictionary::Ptr macros;
        [config] String check;
        [config, protected] Dictionary::Ptr services (ServiceDescriptions);
        [config] Dictionary::Ptr dependencies (DependencyDescriptions);
index 5853519c9c675912cbd1f3be1bd2024ff0cf4397..c5bd6ef0d04b0ac47efb02c68a5c07d99a48d7f7 100644 (file)
        %attribute %array "groups" {
                %attribute %name(HostGroup) "*"
        },
-
-       %attribute %dictionary "macros" {
-               %attribute %string "*"
-       }
 }
 
 %type HostGroup {
 
        %attribute %string "display_name",
 
-       %attribute %dictionary "macros" {
-               %attribute %string "*"
-       },
-
        %require "check_command",
        %attribute %name(CheckCommand) "check_command",
        %attribute %number "max_check_attempts",
        %require "service",
        %attribute %string "service",
 
-       %attribute %dictionary "macros" {
-               %attribute %string "*"
-       },
-
        %attribute %array "users" {
                %attribute %name(User) "*"
        },
 %type User {
        %attribute %string "display_name",
 
-       %attribute %dictionary "macros" {
-               %attribute %string "*"
-       },
-
        %attribute %array "groups" {
                %attribute %name(UserGroup) "*"
        },
        %attribute %array "escape_macros" {
                %attribute %string "*"
        },
-       %attribute %dictionary "macros" {
-           %attribute %string "*"
-       },
        %attribute %number "timeout"
 /*    } */
 }
index c9ed80f8a4678a34151f60947eb058273f323330..82148c6f7bd8aa15dc2476415be9960640e66373 100644 (file)
@@ -116,9 +116,9 @@ IcingaApplication::Ptr IcingaApplication::GetInstance(void)
        return static_pointer_cast<IcingaApplication>(Application::GetInstance());
 }
 
-Dictionary::Ptr IcingaApplication::GetMacros(void) const
+Dictionary::Ptr IcingaApplication::GetVars(void) const
 {
-       ScriptVariable::Ptr sv = ScriptVariable::GetByName("IcingaMacros");
+       ScriptVariable::Ptr sv = ScriptVariable::GetByName("IcingaVars");
 
        if (!sv)
                return Dictionary::Ptr();
@@ -152,10 +152,10 @@ bool IcingaApplication::ResolveMacro(const String& macro, const CheckResult::Ptr
                return true;
        }
 
-       Dictionary::Ptr macros = GetMacros();
+       Dictionary::Ptr vars = GetVars();
 
-       if (macros && macros->Contains(macro)) {
-               *result = macros->Get(macro);
+       if (vars && vars->Contains(macro)) {
+               *result = vars->Get(macro);
                return true;
        }
 
index b9f9e80e1d66492787d26e6f72e0fd2b3fc38c79..e77d5c25fe7b04e41dd58db0f6a1d413ca6569d8 100644 (file)
@@ -47,7 +47,7 @@ public:
        static IcingaApplication::Ptr GetInstance(void);
 
        String GetPidPath(void) const;
-       Dictionary::Ptr GetMacros(void) const;
+       Dictionary::Ptr GetVars(void) const;
         String GetNodeName(void) const;
 
        virtual bool ResolveMacro(const String& macro, const CheckResult::Ptr& cr, String *result) const;
index 922e765cd0adfd603050dfec5d13541c99ceee15..ee7b830bc220fb64d61b3949350536b634aaa09b 100644 (file)
@@ -341,16 +341,16 @@ void Notification::ExecuteNotificationHelper(NotificationType type, const User::
 
 bool Notification::ResolveMacro(const String& macro, const CheckResult::Ptr&, String *result) const
 {
+       Dictionary::Ptr vars = GetVars();
+
        if (macro.SubStr(0, 13) == "_NOTIFICATION") {
-               Dictionary::Ptr custom = GetCustom();
-               *result = custom ? custom->Get(macro.SubStr(13)) : "";
+               *result = vars ? vars->Get(macro.SubStr(13)) : "";
                return true;
        }
 
-       Dictionary::Ptr macros = GetMacros();
 
-       if (macros && macros->Contains(macro)) {
-               *result = macros->Get(macro);
+       if (vars && vars->Contains(macro)) {
+               *result = vars->Get(macro);
                return true;
        }
 
index c2b0de52c4fc5139372f122d9e1bbbadf19248b0..45431afac41f626e6492a46f38c21328678bf15a 100644 (file)
@@ -373,16 +373,16 @@ bool Service::ResolveMacro(const String& macro, const CheckResult::Ptr& cr, Stri
                }
        }
 
+       Dictionary::Ptr vars = GetVars();
+
        if (macro.SubStr(0, 8) == "_SERVICE") {
-               Dictionary::Ptr custom = GetCustom();
-               *result = custom ? custom->Get(macro.SubStr(8)) : "";
+               *result = vars ? vars->Get(macro.SubStr(8)) : "";
                return true;
        }
 
-       Dictionary::Ptr macros = GetMacros();
 
-       if (macros && macros->Contains(macro)) {
-               *result = macros->Get(macro);
+       if (vars && vars->Contains(macro)) {
+               *result = vars->Get(macro);
                return true;
        }
 
index c47a64163e7262b1360212dbdd55afe5581f4694..95437165170c1eb9d47780126a075608090c7542 100644 (file)
@@ -29,7 +29,6 @@ class Service : DynamicObject
                                return m_DisplayName;
                }}}
        };
-       [config] Dictionary::Ptr macros;
        [config] Array::Ptr groups;
        [config, protected] String check_command (CheckCommandRaw);
        [config] int max_check_attempts (MaxCheckAttemptsRaw) {
index 5bfcd0e8a48d2ee1c559cd19527c178a18656801..966c08f902bb54269cf128976dcd6bfb300bd064 100644 (file)
@@ -75,12 +75,12 @@ bool User::ResolveMacro(const String& macro, const CheckResult::Ptr&, String *re
                *result = GetDisplayName();
                return true;
        } else if (macro.SubStr(0, 5) == "_USER") {
-               Dictionary::Ptr custom = GetCustom();
-               *result = custom ? custom->Get(macro.SubStr(5)) : "";
+               Dictionary::Ptr vars = GetVars();
+               *result = vars ? vars->Get(macro.SubStr(5)) : "";
                return true;
        } else if (macro.SubStr(0, 8) == "_CONTACT") {
-               Dictionary::Ptr custom = GetCustom();
-               *result = custom ? custom->Get(macro.SubStr(8)) : "";
+               Dictionary::Ptr vars = GetVars();
+               *result = vars ? vars->Get(macro.SubStr(8)) : "";
                return true;
        } else {
                String tmacro;
@@ -92,10 +92,10 @@ bool User::ResolveMacro(const String& macro, const CheckResult::Ptr&, String *re
                else
                        tmacro = macro;
 
-               Dictionary::Ptr macros = GetMacros();
+               Dictionary::Ptr vars = GetVars();
 
-               if (macros && macros->Contains(tmacro)) {
-                       *result = macros->Get(tmacro);
+               if (vars && vars->Contains(tmacro)) {
+                       *result = vars->Get(tmacro);
                        return true;
                }