Hello, i am trying to make a monitoring team dashboard and need a set of sensors that can watch the current status of the PRTG server so i can pull these out to grafana. Do you know of a way/example of using the sensors already present in PRTG or using the REST XML sensor to return the PRTG status. Data i need is current alarms/warns/pauses and background tasks.

thanks sam


Article Comments

Hi Samuel,

if JSON is permissable you can retrieve all of specified information in JSON from the getstatus.htm function,

https://prtg.example.com/api/getstatus.htm?id=0&username=username&passhash=passhash

While there is a corresponding getstatus.xml function to return data in XML format, this does not include all of the fields the JSON version does, only including high level information such as the number of number of background tasks and active alarms.

If you require that the response be in XML, you can separately use the gettreenodestats.xml function to retrieve information regarding sensor totals

https://prtg.example.com/api/gettreenodestats.xml?username=username&passhash=passhash

Regards,

lordmilko


Mar, 2018 - Permalink

Hello Mr Milko (first thank you so much for the PRTG data source!!)

The /api/getstatus.htm query appears to not be able to return the up/down sens info as it shows object not found in the outputted page for these fields. gettreenodestats.xml works well outputting all the info i need however when trying to input these into the grafana plugin i get unexpected json character.

More than anything i am trying to create a sensor within PRTG so that our attached alarm system can let us know if we breach over a certain threshold of alarms, these sensors i will then add to grafana

cheers sma


Mar, 2018 - Permalink

If you are trying to create an EXE/Script Advanced sensor within PRTG that contains this information, the easiest way to extract this from PRTG is with PrtgAPI via the Get-PrtgStatus cmdlet

PS C:\> Get-PrtgStatus

Version                  : 18.1.38.11958
NewLogs                  : 1
NewAlarms                : 0
Alarms                   : 1
AcknowledgedAlarms       : 1
PartialAlarms            : 0
UnusualSensors           : 1
UpSensors                : 21
WarningSensors           : 1
...

You can store the result of Get-PrtgStatus in a variable and then turn each property you care about into a channel (which you should obviously do with PrtgAPI.CustomSensors :P)

$status = Get-PrtgStatus

Prtg {
    Result {
        Channel "Up"
        Value $status.UpSensors
    }

    Result {
        Channel "Down"
        Value $status.DownSensors
    }

    Result {
        Channel "Alarms"
        Value $status.Alarms
    }
}

Output:

<Prtg>
    <Result>
        <Channel>Up</Channel>
        <Value>199</Value>
    </Result>
    <Result>
        <Channel>Down</Channel>
        <Value />
    </Result>
    <Result>
        <Channel>Alarms</Channel>
        <Value>29</Value>
    </Result>
</Prtg>

By specifying the -Verbose argument to any PrtgAPI cmdlet you can see the URL it generates to retrieve the specified data.

I'm not sure why you would be getting object not found unless your user account potentially has limited permissions on your system

If Get-PrtgStatus also returns object not found, you can retrieve the information returned by gettreenodestats.xml via the Get-SensorTotals cmdlet


Mar, 2018 - Permalink

Holy heck it works! Also this is the first time i've used the custom sensor creator and wow... you really know how to make my job/life easier :) Thanks!


Mar, 2018 - Permalink

Hey lordmilko,

Thank you for helping the user and for pushing your great API-Application!

Best regards.


Mar, 2018 - Permalink