Hello,

I'm trying to monitor some RBMQ components like queue, connections and so on. I succeed to monitor those components and more using custom sensor (HTTP XML/REST Value) ,but I'm getting all the time randomly time outs, warning and down statuses (code: PE018) as the other sensors are working fine (ping and http).

Plus,

1. Other monitor systems like Nagios are working fine and not getting those timeouts not errors.

2. I'm using 60 sec interval scanning and I cannot use 5 min interval as it too long.

3. I used the following article, https://blog.cdemi.io/monitoring-rabbitmq-in-prtg/

I would appreciate your help.

Thanks,

Shay


Article Comments

Hello Shay,

Thank you for your KB-post.

Kindly note that we do not offer technical support for sensor customization, sorry.

Maybe some other user can help you with this, or the owner of the blog http://blog.cdemi.io

Best regards


Dec, 2016 - Permalink

Hi,

Thanks for the response. Can you please let me know what is the best recommended sensor to use for monitoring RabbitMQ server components?

Thanks, Shay


Dec, 2016 - Permalink

Hello,

Which exact server components do you want to monitor?


Dec, 2016 - Permalink

Hi,

At this moment I would like to monitor,

Consumers

Publish Messages

Queue

Connections

Messages in queue

In the near future I would like to monitor more components.

Thanks, Shay


Dec, 2016 - Permalink

Hello Shay,

Please note that PRTG does not have any default sensors designated for RabbitMQ monitoring.

You can try the following alternatives:

  • As already mentioned, as Rabbit MQ services provide an API which returns results via JSON, you can use HTTP XML/REST Value sensor to monitor this JSON output. Specify the node for the value of interest in the sensor settings and the sensor will return the corresponding value; please have a look also at this article.

Best regards


Dec, 2016 - Permalink

I just wrote a powershell script to use in an EXE/Script Advanced sensor. I include channels for "Message Publish Rate", "Message Count", Connections, Consumers, and Queues. You could certainly do others.

I adapted the script found here: https://helpdesk.paessler.com/en/support/solutions/articles/71263

Here's the script:

# Monitor stats from RabbitMQ in PRTG v0.1 20/01/2021
# Adapted from the script written to monitor Unifi Access Points Published Here: https://helpdesk.paessler.com/en/support/solutions/articles/71263
#
# Parameters in PRTG are: Controller's URI, Port, Username and Password. Example without placeholders:
# -server 'unifi.domain.tld' -port '8443' -username 'admin' -password 'somepassword'
#
# -server '%host' -port '8443' -site 'default' -username '%windowsuser' -password '%windowspassword'
# This second option requires the device's address in PRTG to be the controller's address, the credentials for windows devices
# must also match the log-in/password from the controller. This way you don't leave the password exposed in the sensor's settings.
#
# It's recommended to use larger scanning intervals for exe/xml scripts. Please also mind the 50 exe/script sensor's recommendation per probe.
# The sensor will not generate alerts by default, after creating your sensor, define limits accordingly.
# This sensor is to be considered experimental. 
#
#   Source(s):
#   https://blog.cdemi.io/monitoring-rabbitmq-in-prtg/
#	https://documentation.solarwinds.com/en/Success_Center/appoptics/content/kb/host_infrastructure/integrations/rabbitmq.htm
#	https://www.paessler.com/manuals/prtg/custom_sensors

param(
	[string]$server = 'testserver.domain.com',
	[string]$port = '15672',
	[string]$username = 'guest',
	[string]$password = 'guest',
	[switch]$debug = $false
)

#Ignore SSL Errors
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}  

#Define supported Protocols
[System.Net.ServicePointManager]::SecurityProtocol = @("Tls12","Tls11","Tls","Ssl3")


# Confirm Powershell Version.
if ($PSVersionTable.PSVersion.Major -lt 3) {
	Write-Output "<prtg>"
	Write-Output "<error>1</error>"
	Write-Output "<text>Powershell Version is $($PSVersionTable.PSVersion.Major) Requires at least 3. </text>"
	Write-Output "</prtg>"
	Exit
}


# Create $controller and $credential using multiple variables/parameters.
[string]$controller = "http://$($server):$($port)"
[string]$credential = "`{`"username`":`"$username`",`"password`":`"$password`"`}"

$pair = "$($username):$($password)"

$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))

$basicAuthValue = "Basic $encodedCreds"

$Headers = @{
    Authorization = $basicAuthValue
}

# Start debug timer
$queryMeasurement = [System.Diagnostics.Stopwatch]::StartNew()

# Perform the authentication and store the token to myWebSession
try {
$null = Invoke-Restmethod -Uri "$controller/api/overview" -Headers $Headers -ContentType "application/json; charset=utf-8"  -SessionVariable myWebSession
}catch{
	Write-Output "<prtg>"
	Write-Output "<error>1</error>"
	Write-Output "<text>Authentication Failed: $($_.Exception.Message)</text>"
	Write-Output "</prtg>"
	Exit
}

#Query API providing token from first query.
try {
$jsonresultat = Invoke-Restmethod -Uri "$controller/api/overview" -WebSession $myWebSession
}catch{
	Write-Output "<prtg>"
	Write-Output "<error>1</error>"
	Write-Output "<text>API Query Failed: $($_.Exception.Message)</text>"
	Write-Output "</prtg>"
	Exit
}

# Load File from Debug Log
# $jsonresultatFile = Get-Content '.\unifi_sensor2017-15-02-05-42-24_log.json'
# $jsonresultat = $jsonresultatFile | ConvertFrom-Json

# Stop debug timer
$queryMeasurement.Stop()


#Write Results

write-host "<prtg>"

Write-Host "<result>"
Write-Host "<channel>Message Publish Rate</channel>"
Write-Host "<value>$($jsonresultat.message_stats.publish_details.rate)</value>"
Write-Host "<float>1</float>"
Write-Host "</result>"

Write-Host "<result>"
Write-Host "<channel>Message Count</channel>"
Write-Host "<value>$($jsonresultat.queue_totals.messages)</value>"
Write-Host "</result>"

Write-Host "<result>"
Write-Host "<channel>Connections</channel>"
Write-Host "<value>$($jsonresultat.object_totals.connections)</value>"
Write-Host "</result>"

Write-Host "<result>"
Write-Host "<channel>Consumers</channel>"
Write-Host "<value>$($jsonresultat.object_totals.consumers)</value>"
Write-Host "</result>"

Write-Host "<result>"
Write-Host "<channel>Queues</channel>"
Write-Host "<value>$($jsonresultat.object_totals.queues)</value>"
Write-Host "</result>"

write-host "</prtg>"

# Write JSON file to disk when -debug is set. For troubleshooting only.
if ($debug){
	[string]$logPath = ((Get-ItemProperty -Path "hklm:SOFTWARE\Wow6432Node\Paessler\PRTG Network Monitor\Server\Core" -Name "Datapath").DataPath) + "Logs (Sensors)\"
	$timeStamp = (Get-Date -format yyyy-dd-MM-hh-mm-ss)

	$json = $jsonresultat | ConvertTo-Json
	$json | Out-File $logPath"rabbit_sensor$($timeStamp)_log.json"
}

Jan, 2021 - Permalink