* DB IDO schema update to version `1.12.0`
* schema files in `lib/db_ido_{mysql,pgsql}/schema` (source)
+ * Table `programstatus`: New column `program_version`
+ * Table `customvariables` and `customvariablestatus`: New column `is_json` (required for custom attribute array/dictionary support)
* New CLI commands #7245
* `icinga2 feature {enable,disable}` replaces `icinga2-{enable,disable}-feature` script #7250
* `icinga2 object list` replaces `icinga2-list-objects` script #7251
{host,service}group | notes | TEXT | NULL | -
{host,service}group | notes_url | TEXT | NULL | -
{host,service}group | action_url | TEXT | NULL | -
+ customvariable* | is_json | integer | 0 | Defines whether `varvalue` is a json encoded string from custom attributes, or not
Additional command custom variables populated from 'vars' dictionary.
Additional global custom variables populated from 'Vars' constant (object_id is NULL).
current_host_ | join | Prefix for attributes from implicit join with hosts table.
Not supported: `debug_info`.
-
-
#include "remote/endpoint.hpp"
#include "base/dynamicobject.hpp"
#include "base/dynamictype.hpp"
+#include "base/json.hpp"
#include "base/convert.hpp"
#include "base/objectlock.hpp"
#include "base/utility.hpp"
continue;
String value;
+ int is_json = 0;
- if (kv.second.IsObjectType<Array>())
- value = Utility::Join(kv.second, ';');
- else
+ if (kv.second.IsObjectType<Array>() || kv.second.IsObjectType<Dictionary>()) {
+ value = JsonEncode(kv.second);
+ is_json = 1;
+ } else
value = kv.second;
int overridden = custom_var_object->IsVarOverridden(kv.first) ? 1 : 0;
Dictionary::Ptr fields = make_shared<Dictionary>();
fields->Set("varname", kv.first);
fields->Set("varvalue", value);
+ fields->Set("is_json", is_json);
fields->Set("config_type", 1);
fields->Set("has_been_modified", overridden);
fields->Set("object_id", obj);
ObjectLock olock (vars);
BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
- if (kv.first.IsEmpty() || kv.second.IsObject())
+ if (kv.first.IsEmpty())
continue;
+ String value;
+ int is_json = 0;
+
+ if (kv.second.IsObjectType<Array>() || kv.second.IsObjectType<Dictionary>()) {
+ value = JsonEncode(kv.second);
+ is_json = 1;
+ } else
+ value = kv.second;
+
int overridden = custom_var_object->IsVarOverridden(kv.first) ? 1 : 0;
Log(LogDebug, "DbObject")
<< "' overridden: " << overridden;
Dictionary::Ptr fields = make_shared<Dictionary>();
- fields->Set("varname", Convert::ToString(kv.first));
- fields->Set("varvalue", Convert::ToString(kv.second));
+ fields->Set("varname", kv.first);
+ fields->Set("varvalue", value);
+ fields->Set("is_json", is_json);
fields->Set("has_been_modified", overridden);
fields->Set("status_update_time", DbValue::FromTimestamp(Utility::GetTime()));
fields->Set("object_id", obj);
if (vars) { /* This is sparta. */
for (int i = 1; i <= 6; i++) {
String key = "address" + Convert::ToString(i);
- String val = vars->Get(key);
- if (val.IsEmpty())
+ if (!vars->Contains(key))
continue;
+ String val = vars->Get(key);
+
fields->Set("contact_id", DbValue::FromObjectInsertID(user));
fields->Set("address_number", i);
fields->Set("address", val);
has_been_modified smallint default 0,
varname varchar(255) character set latin1 collate latin1_general_cs default NULL,
varvalue TEXT character set latin1 default '',
+ is_json smallint default 0,
PRIMARY KEY (customvariable_id),
UNIQUE KEY object_id_2 (object_id,config_type,varname),
KEY varname (varname)
has_been_modified smallint default 0,
varname varchar(255) character set latin1 collate latin1_general_cs default NULL,
varvalue TEXT character set latin1 default '',
+ is_json smallint default 0,
PRIMARY KEY (customvariablestatus_id),
UNIQUE KEY object_id_2 (object_id,varname),
KEY varname (varname)
ALTER TABLE icinga_contacts MODIFY alias TEXT character set latin1 default '';
ALTER TABLE icinga_hosts MODIFY alias TEXT character set latin1 default '';
+ALTER TABLE icinga_customvariables ADD COLUMN is_json smallint default 0;
+ALTER TABLE icinga_customvariablestatus ADD COLUMN is_json smallint default 0;
+
-- -----------------------------------------
-- update dbversion
-- -----------------------------------------
has_been_modified INTEGER default 0,
varname TEXT default '',
varvalue TEXT default '',
+ is_json INTEGER default 0,
CONSTRAINT PK_customvariable_id PRIMARY KEY (customvariable_id) ,
CONSTRAINT UQ_customvariables UNIQUE (object_id,config_type,varname)
) ;
has_been_modified INTEGER default 0,
varname TEXT default '',
varvalue TEXT default '',
+ is_json INTEGER default 0,
CONSTRAINT PK_customvariablestatus_id PRIMARY KEY (customvariablestatus_id) ,
CONSTRAINT UQ_customvariablestatus UNIQUE (object_id,varname)
) ;
ALTER TABLE icinga_programstatus ADD COLUMN program_version TEXT default NULL;
+ALTER TABLE icinga_customvariables ADD COLUMN is_json INTEGER default 0;
+ALTER TABLE icinga_customvariablestatus ADD COLUMN is_json INTEGER default 0;
+
+
-- -----------------------------------------
-- update dbversion
-- -----------------------------------------
--- /dev/null
+object Host "7560-server" {
+ import "test-generic-host"
+ address = "127.0.0.1"
+ check_command = "hostalive"
+
+ vars.interfaces += {
+ eth0 = {
+ port = 1
+ vlan = "internal"
+ address = "127.0.0.2"
+ qos = "enabled"
+ }
+ eth1 = {
+ port = 2
+ vlan = "mgmt"
+ address = "127.0.1.2"
+ }
+ eth2 = {
+ port = 3
+ vlan = "remote"
+ address = "127.0.2.2"
+ }
+ }
+}
+
+apply Service "if-" for (if_name => config in host.vars.interfaces) {
+ import "test-generic-service"
+ check_command = "ping4"
+
+ vars.qos = "disabled"
+ vars += config
+
+ display_name = "if-" + if_name + "-" + vars.vlan
+
+ notes = "Interface check for Port " + string(vars.port) + " in VLAN " + vars.vlan + " on Address " + vars.address + " QoS " + vars.qos
+ notes_url = "http://foreman.company.com/hosts/" + host.name
+ action_url = "http://snmp.checker.company.com/" + host.name + "if-" + if_name
+
+ assign where match("7560-*", host.name) && typeof(host.vars.interfaces) == typeof({})
+}
+