-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Adds detection of occupants with no connection. #14146
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -37,6 +37,8 @@ local tostring = tostring; | |||||
-- required parameter for custom muc component prefix, defaults to "conference" | ||||||
local muc_domain_prefix = module:get_option_string("muc_mapper_domain_prefix", "conference"); | ||||||
|
||||||
local leaked_rooms; | ||||||
|
||||||
--- handles request to get number of participants in all rooms | ||||||
-- @return GET response | ||||||
function handle_get_room_census(event) | ||||||
|
@@ -46,18 +48,37 @@ function handle_get_room_census(event) | |||||
end | ||||||
|
||||||
room_data = {} | ||||||
leaked_rooms = 0; | ||||||
for room in host_session.modules.muc.each_room() do | ||||||
if not is_healthcheck_room(room.jid) then | ||||||
local occupants = room._occupants; | ||||||
local participant_count = 0; | ||||||
local missing_connections_count = 0; | ||||||
|
||||||
if occupants then | ||||||
participant_count = iterators.count(room:each_occupant()) - 1; -- subtract focus | ||||||
else | ||||||
participant_count = 0 | ||||||
for _, o in room:each_occupant() do | ||||||
participant_count = participant_count + 1; | ||||||
|
||||||
-- let's check whether that occupant has connection in the full_sessions of prosody | ||||||
-- attempt to detect leaked occupants/rooms. | ||||||
if prosody.full_sessions[o.jid] == nil then | ||||||
missing_connections_count = missing_connections_count + 1; | ||||||
end | ||||||
end | ||||||
participant_count = participant_count - 1; -- subtract focus | ||||||
end | ||||||
|
||||||
local leaked = false; | ||||||
if participant_count > 0 and missing_connections_count == participant_count then | ||||||
leaked = true; | ||||||
leaked_rooms = leaked_rooms + 1; | ||||||
end | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
table.insert(room_data, { | ||||||
room_name = room.jid; | ||||||
participants = participant_count; | ||||||
created_time = room.created_timestamp; | ||||||
leaked = leaked; | ||||||
}); | ||||||
end | ||||||
end | ||||||
|
@@ -77,3 +98,9 @@ function module.load() | |||||
}; | ||||||
}); | ||||||
end | ||||||
|
||||||
-- we calculate the stats on the configured interval (60 seconds by default) | ||||||
local measure_leaked_rooms = module:measure('leaked_rooms', 'amount'); | ||||||
module:hook_global('stats-update', function () | ||||||
measure_leaked_rooms(leaked_rooms); | ||||||
end); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.