I am doing a rest query to a webservice and getting a string for a status value not a number.

In my case it is NewRelic, and I want to monitor the service health for one of my services.

The NewRelic API returns Green, Yellow, Red or Gray - depending on the service status within that particular application.

I can happily return this information to PRTG but I can't do anything with it.

I'm hoping there is a way to do a "reverse lookup" similar to how this can be done with an SNMP Custom Sensor so that I can get an Alarm when it is Red and a Warning when it is Yellow


Article Comments

You'll need to come up with a PowerShell script that evaluates the result and puts it into a numerical form. Like this:

$Result = (Invoke-Webrequest <NewRelicURl>).Content

if($Result -eq "Green")
{ Write-Host "0:Application State OK"; exit 0; }
if($Result -eq "Yellow")
{ Write-Host "0:Application State WARNING"; exit 1; }
if($Result -eq "Red")
{ Write-Host "0:Application State DOWN"; exit 2; }
if($Result -eq "Gray")
{ Write-Host "0:Application State Unknown"; exit 1; }

Note that this is just a mockup and may need tinkering to suit your needs.


Kind regards,
Stephan Linke, Tech Support Team


Mar, 2018 - Permalink