I'm going to share our BBB status sensor Powershell script as an answer.
9 Replies
<# .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://kb.paessler.com/en/topic/64817-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> "@ )
Hi there,
Thanks a lot for sharing your script with us.
We appreciate that.
Kind regards,
Birk Guttmann, Tech Support Team
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
Created on Jun 2, 2020 11:13:41 AM by
MPIDR
(10)
Last change on Jun 2, 2020 2:38:20 PM by
Birk Guttmann [Paessler Support]
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
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
Thank you very much!
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
Hi Frank,
you can enter several parameter in the option field.
-parameter1 "Example1" -parameter2 "Example2"
Kind regards
Felix Wiesneth - Team Tech Support
Perfect - Script works for me now!
Hints:
- Modify the script as MDIPR mentioned.
- Save the script as PS1-File (eg. bbb.ps1) into the folder "custom sensors\EXEXML\"
- Install the sensor "Program/Script (advanced)"
- In the section "parameter" enter the following:
-serverurl "https:YOURSERVER/bigbluebutton/api" -secret "BBBSECRET"
Best, Frank
Created on Sep 13, 2021 12:43:50 PM by
FrankBBB
(0)
Last change on Sep 13, 2021 2:44:09 PM by
Felix Wiesneth [Paessler Support]
Please log in or register to enter your reply.
Add comment