I'm going to share our BBB status sensor Powershell script as an answer.


Article Comments

<#
.SYNOPSIS
PRTG Sensor for BBB server

.PARAMETER serverurl
Full URL to BBB API, e.g. https://your-server/bigbluebutton/api
(no trainling slash please!)

.PARAMETER secret
BBB-Secret (get it by running "bbb-conf --secret")
#>
Param(
	[Parameter( Mandatory=$true)]
    [string]$serverurl,
	[Parameter( Mandatory=$true)]
    [string]$secret
    )
 
# Strange hack to get proper output encoding
# see https://helpdesk.paessler.com/en/support/solutions/articles/76000063275-how-can-i-show-special-characters-with-exe-script-sensors#reply-210863
ping localhost -n 1 | Out-Null
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8

# Powershell is stupid and tries TLS1.0 by default, then dies at Invoke-WebRequest :-(
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
 
$api = "getMeetings"

$hasher = [System.Security.Cryptography.SHA1]::Create()
# calculate checksum - see https://docs.bigbluebutton.org/dev/api.html
$bytes = [byte[]][char[]]("$api$secret")
$hash = $hasher.ComputeHash($bytes)
# and convert to hex format
$secret = (($hash | foreach { $_.ToString("X2") }) -join "").toLower()

# build API call url including checksum
$fullurl = "$serverurl/$($api)?&checksum=$secret"
#echo $fullurl
$response = Invoke-WebRequest -URI $fullurl

function send-error
{
	Param([string]$message)
# neccessary for correct output encoding
[Console]::WriteLine(@"
<?xml version=`"1.0`" encoding=`"UTF-8`" ?>
<prtg>
    <error>1</error>
	<text>
	$message
	</text>
</prtg>
"@ )
}

if ($response.StatusCode -ne 200) {
	send-error "Invalid HTTP response code: $($response.StatusCode) - $($response.Content)"
	exit
}

#for debugging:
#echo $response.Content

# convert response to XML object
$xml = [xml]$response.Content
if ($xml.response.returncode -ne "SUCCESS") {
	send-error "API call failed: $($xml.response.message)"
	exit
}

# XML structure:
# response
#   meetings
#     meeting
#       meetingName
#       running (true)
#       participantCount (int)
#		listenerCount (int)
#		voiceParticipantCount (int)
#		videoCount (int)
#		isBreakout -> I'm not sure whether to count them, probably yes

$meetingcount = 0
$runningcount = 0
$participantCount = 0
$listenerCount = 0
$voiceParticipantCount = 0
$videoCount = 0
$resultmessage = "OK"

if ($xml.response.meetings) {
	if ($xml.response.meetings.meeting) {
		$meetingcount = 1
	}
	if ($xml.response.meetings.meeting.Count -gt 0) {
		$meetingcount = $xml.response.meetings.meeting.Count
	}
	$running = $xml.response.meetings | ? { $_.meeting.running -eq "true" }
	foreach ($m in $running.meeting) {
		$runningcount++;
		$participantCount += $m.participantCount
		$listenerCount += $m.listenerCount
		$voiceParticipantCount += $m.voiceParticipantCount
		$videoCount += $m.videoCount
	}
} else {
	$resultmessage = "no active meetings"
}

$result += @"
		<result>
			<value>$meetingcount</value>
			<unit>count</unit>
			<channel>Total meetings</channel>
		</result>
		<result>
			<value>$runningcount</value>
			<unit>count</unit>
			<channel>Total meetings running</channel>
		</result>
		<result>
			<value>$participantCount</value>
			<unit>count</unit>
			<channel>Total participants</channel>
		</result>
		<result>
			<value>$listenerCount</value>
			<unit>count</unit>
			<channel>Total listeners</channel>
		</result>
		<result>
			<value>$voiceParticipantCount</value>
			<unit>count</unit>
			<channel>Total voice participants</channel>
		</result>
		<result>
			<value>$videoCount</value>
			<unit>count</unit>
			<channel>Total video streams</channel>
		</result>
		<text>
		$resultmessage
		</text>
"@

# neccessary for correct output encoding
[Console]::WriteLine(@"
<?xml version=`"1.0`" encoding=`"UTF-8`" ?>
<prtg>
$result
</prtg>
"@ )

Apr, 2020 - Permalink

Hi there,

Thanks a lot for sharing your script with us.

We appreciate that.


Kind regards,
Birk Guttmann, Tech Support Team


Apr, 2020 - Permalink

Hi,

"$response = Invoke-WebRequest -URI $fullurl" should include the "-UseBasicParsing" parameter to avoid error message related to the command not being implemented.

"$response = Invoke-WebRequest -URI $fullurl -UseBasicParsing"

Regards, MPIDR


Jun, 2020 - Permalink

Hi,

thank you very much for sharing this script!

I saved it under "custom sensors\EXE\bbb.ps1" and added a new sensor "Program/Script sensor".

Could please give me an advice how to enter the parameters (what is the exact syntax)?

Many thanks!

Frank


Sep, 2021 - Permalink

Hello Frank,

To enter the parameters use quotation marks to correctly escape the parameters, for example, if the values contain spaces. In tab Settings in option Parameters of your sensor you will need to enter it like following:

-parameter "Example" 

Kind regards

Felix Wiesneth - Team Tech Support


Sep, 2021 - Permalink

Thank you very much!


Sep, 2021 - Permalink

Sorry, one more question: I have to enter 2 parameters (serverurl and secret). What should I enter in the option "Parameter" of the sensor? Many thanks!

Frank


Sep, 2021 - Permalink

Hi Frank,

you can enter several parameter in the option field.

-parameter1 "Example1" -parameter2 "Example2"

Kind regards

Felix Wiesneth - Team Tech Support


Sep, 2021 - Permalink

Perfect - Script works for me now!

Hints:

  1. Modify the script as MDIPR mentioned.
  2. Save the script as PS1-File (eg. bbb.ps1) into the folder "custom sensors\EXEXML\"
  3. Install the sensor "Program/Script (advanced)"
  4. In the section "parameter" enter the following: -serverurl "https:YOURSERVER/bigbluebutton/api" -secret "BBBSECRET"

Best, Frank


Sep, 2021 - Permalink