Add a fix to correctly register child nodes to the cloud via a parent (#12241)
* Add a trigger to populate the node_instance table. This will allow older agent versions pre v1.31 to connect to the cloud via the parent * Minor fix : Make the trigger creation a separate statement
Stelios Fragkakis committed
Feb 25, 2022 at 09:04 UTC
44c6382e2b9bc92e9a0cbfb56d6994e28bd1d7a2
1 file changed
+3
database/sqlite/sqlite_functions.c
+3
@@ -40,6 +40,9 @@ const char *database_config[] = {
40
"CREATE VIEW IF NOT EXISTS v_chart_hash as SELECT ch.*, chm.chart_id FROM chart_hash ch, chart_hash_map chm "
41
"WHERE ch.hash_id = chm.hash_id;",
42
43
+ "CREATE TRIGGER IF NOT EXISTS ins_host AFTER INSERT ON host BEGIN INSERT INTO node_instance (host_id, date_created)"
44
+ " SELECT new.host_id, strftime(\"%s\") WHERE new.host_id NOT IN (SELECT host_id FROM node_instance); END;",
45
+
46
"CREATE TRIGGER IF NOT EXISTS tr_v_chart_hash INSTEAD OF INSERT on v_chart_hash BEGIN "
47
"INSERT INTO chart_hash (hash_id, type, id, name, family, context, title, unit, plugin, "
48
"module, priority, chart_type, last_used) "