Skip to content

Commit

Permalink
add server bbb_version to Redis model and adapt poll/servers/status r…
Browse files Browse the repository at this point in the history
…ake tasks
  • Loading branch information
Ithanil committed Apr 9, 2024
1 parent 2bae80e commit a3b67a4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
6 changes: 5 additions & 1 deletion app/models/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class Server < ApplicationRedisRecord
define_attribute_methods :id, :url, :secret, :tag, :enabled, :load, :online, :load_multiplier, :healthy_counter,
:unhealthy_counter, :state, :meetings, :users, :largest_meeting, :videos
:unhealthy_counter, :state, :meetings, :users, :largest_meeting, :videos, :bbb_version

# Unique ID for this server
application_redis_attr :id
Expand Down Expand Up @@ -49,6 +49,9 @@ class Server < ApplicationRedisRecord
# Indicator of total video streams in this server
application_redis_attr :videos

# Indicator of the BBB version of this server
application_redis_attr :bbb_version

def online=(value)
value = !!value
online_will_change! unless @online == value
Expand Down Expand Up @@ -104,6 +107,7 @@ def save!
pipeline.hset(server_key, 'users', users) if users_changed?
pipeline.hset(server_key, 'largest_meeting', largest_meeting) if largest_meeting_changed?
pipeline.hset(server_key, 'videos', videos) if videos_changed?
pipeline.hset(server_key, 'bbb_version', bbb_version) if bbb_version_changed?
pipeline.sadd?('servers', id) if id_changed?
state.present? ? save_with_state(pipeline) : save_without_state(pipeline)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/poll.rake
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ namespace :poll do
tasks = Server.all.map do |server|
Concurrent::Promises.future_on(pool) do
Rails.logger.debug { "Checking Version of id=#{server.id}" }
version = get_post_req(encode_bbb_uri('', server.url, server.secret)).xpath('/response/bbbVersion').text
puts version
bbb_version = get_post_req(encode_bbb_uri('', server.url, server.secret)).xpath('/response/bbbVersion').text
server.bbb_version = bbb_version
rescue StandardError => e
Rails.logger.warn("Unexpected error when checking version of server id=#{server.id}: #{e}")
ensure
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/servers.rake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ task servers: :environment do
end
puts("\tload: #{server.load.presence || 'unavailable'}")
puts("\tload multiplier: #{server.load_multiplier.nil? ? 1.0 : server.load_multiplier.to_d}")
puts("\tbbb version: #{server.bbb_version.nil? ? '' : server.bbb_version}")
puts("\ttag: #{server.tag.nil? ? '' : server.tag}")
puts("\t#{server.online ? 'online' : 'offline'}")
end
Expand Down
5 changes: 3 additions & 2 deletions lib/tasks/status.rake
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ task status: :environment do
include ApiHelper

servers_info = []
ServerInfo = Struct.new(:hostname, :state, :status, :meetings, :users, :largest, :videos, :load, :tag)
ServerInfo = Struct.new(:hostname, :state, :status, :meetings, :users, :largest, :videos, :load, :bbb_version, :tag)

Server.all.each do |server|
state = server.state
enabled = server.enabled
state = server.state.present? ? status_with_state(state) : status_without_state(enabled)

info = ServerInfo.new(URI.parse(server.url).host, state, server.online ? 'online' : 'offline', server.meetings, server.users,
server.largest_meeting, server.videos, server.load, server.tag)
server.largest_meeting, server.videos, server.load, server.bbb_version, server.tag)

# Convert to openstruct to allow dot syntax usage
servers_info.push(info)
Expand All @@ -33,6 +33,7 @@ server.largest_meeting, server.videos, server.load, server.tag)
t.add_column('LARGEST MEETING', &:largest)
t.add_column('VIDEOS', &:videos)
t.add_column('LOAD', &:load)
t.add_column('BBB VERSION', &:bbb_version)
t.add_column('TAG', &:tag)
end

Expand Down

0 comments on commit a3b67a4

Please sign in to comment.