Skip to content

Commit

Permalink
bbb version metric optional
Browse files Browse the repository at this point in the history
  • Loading branch information
greenstatic committed Mar 21, 2024
1 parent 376f27a commit 3406cdd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
19 changes: 12 additions & 7 deletions bbb-exporter/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class BigBlueButtonCollector:
recordings_metrics_base_dir = settings.recordings_metrics_base_dir
recordings_metrics_from_disk = settings.RECORDINGS_METRICS_READ_FROM_DISK

bbb_version_from_disk = settings.BBB_VERSION_READ_FROM_DISK

last_scrape_meetings = set([])
unique_meetings_count = 0

Expand Down Expand Up @@ -114,17 +116,13 @@ def collect(self):
yield self.metric_unique_meetings_count(meetings)
yield self.metric_unique_breakout_rooms_count(meetings)

if self.bbb_version_from_disk:
self.metric_bbb_version()

bbb_exporter = GaugeMetricFamily("bbb_exporter", "BigBlueButton Exporter version", labels=["version"])
bbb_exporter.add_metric([settings.VERSION], 1)
yield bbb_exporter

# read BBB version from disk
with open("/etc/bigbluebutton/bigbluebutton-release", "r") as f:
bbb_release = f.read()
bbb_version = GaugeMetricFamily("bbb_version", "BigBlueButton version", labels=["version"])
bbb_version.add_metric([bbb_release.strip().split("=")[1]], 1)
yield bbb_version

logging.info("Finished collecting metrics from BigBlueButton API")

def metric_meetings(self, meetings):
Expand Down Expand Up @@ -332,6 +330,13 @@ def metric_unique_breakout_rooms_count(self, meetings):
metric = CounterMetricFamily('bbb_unique_breakout_rooms', "Unique breakout rooms counter")
metric.add_metric([], self.unique_breakout_rooms_count)
return metric

def metric_bbb_version(self):
with open("/etc/bigbluebutton/bigbluebutton-release", "r") as f:
bbb_release = f.read()
bbb_version = GaugeMetricFamily("bbb_version", "BigBlueButton version", labels=["version"])
bbb_version.add_metric([bbb_release.strip().split("=")[1]], 1)
yield bbb_version

@staticmethod
def _get_participant_count_by_client(meetings):
Expand Down
6 changes: 5 additions & 1 deletion bbb-exporter/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
MAJOR = 0
MINOR = 7
BUGFIX = 0
INFO = "preview2"
INFO = "preview3"

VERSION = "{}.{}.{}".format(MAJOR, MINOR, BUGFIX)
if INFO:
Expand Down Expand Up @@ -41,8 +41,12 @@

RECORDINGS_METRICS_READ_FROM_DISK = False if os.getenv("RECORDINGS_METRICS_READ_FROM_DISK",
"false").lower() == "false" else True


recordings_metrics_base_dir = "/var/bigbluebutton"

BBB_VERSION_READ_FROM_DISK = False if os.getenv("BBB_VERSION_READ_FROM_DISK", "false").lower() == "false" else True

# Global (gasp.) variable flag that is used to mark if communicating with BigBlueButton's API is possible.
# Used to set the `bbb_api_up` metric.
_api_up = False
4 changes: 4 additions & 0 deletions extras/docker-compose.exporter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ services:
ports:
- "127.0.0.1:9688:9688"
volumes:

# Can be removed if `BBB_VERSION_READ_FROM_DISK` is set to false (or omitted).
- "/etc/bigbluebutton/bigbluebutton-release:/etc/bigbluebutton/bigbluebutton-release:ro"

# Can be removed if `RECORDINGS_METRICS_READ_FROM_DISK` is set to false (or omitted).
# See https://bigbluebutton-exporter.greenstatic.dev/exporter-user-guide/#optimizations for details.
- "/var/bigbluebutton:/var/bigbluebutton:ro"
Expand All @@ -16,6 +19,7 @@ services:
# - 'host-fqdn:PUBLIC.HOST.IP.ADDRESS'
# - 'bbb.example.com:1.2.3.4' # example
environment:
BBB_VERSION_READ_FROM_DISK: "true"
RECORDINGS_METRICS_READ_FROM_DISK: "true"
env_file:
- secrets.env
Expand Down

0 comments on commit 3406cdd

Please sign in to comment.