changeset 3068:380f92276e57

mod_pubsub_stats: Make the node used configurable
author Kim Alvefur <zash@zash.se>
date Tue, 29 May 2018 05:34:05 +0200 (2018-05-29)
parents b01ef74c9fc0
children e1db146984a0
files mod_pubsub_stats/mod_pubsub_stats.lua
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mod_pubsub_stats/mod_pubsub_stats.lua	Tue May 29 05:31:56 2018 +0200
+++ b/mod_pubsub_stats/mod_pubsub_stats.lua	Tue May 29 05:34:05 2018 +0200
@@ -5,6 +5,8 @@
 
 local actor = module.host .. "/modules/" .. module.name;
 
+local node = module:get_option_string(module.name .. "_node", "stats");
+
 local function publish_stats(stats, stats_extra)
 	local id = "current";
 	local xitem = st.stanza("item", { id = id })
@@ -16,15 +18,15 @@
 		xitem:tag("stat", { name = name, unit = unit, value = tostring(value) }):up();
 	end
 
-	local ok, err = pubsub.service:publish("stats", actor, id, xitem);
+	local ok, err = pubsub.service:publish(node, actor, id, xitem);
 	if not ok then
 		module:log("error", "Error publishing stats: %s", err);
 	end
 end
 
 function module.load()
-	pubsub.service:create("stats", true);
-	pubsub.service:set_affiliation("stats", true, actor, "publisher");
+	pubsub.service:create(node, true);
+	pubsub.service:set_affiliation(node, true, actor, "publisher");
 end
 
 module:hook_global("stats-updated", function (event)
@@ -32,5 +34,5 @@
 end);
 
 function module.unload()
-	pubsub.service:delete("stats", true);
+	pubsub.service:delete(node, true);
 end