Hi,

I am trying to get your RESTAPI working and am getting an error returned

"Last Message: '=' is an unexpected token. The expected token is ';'. Line 29, position 94.:

In the PRTG screen when it polls the url

Using the a REST Client I enter the following request

Get https://192.168.208.72/api/4.0/edges/edge-1/status

And I get a response of

HTTP/1.1 200 OK

<?xml version="1.0" encoding="UTF-8"?>
<edgeStatus>
    <timestamp>1507850357296</timestamp>
    <systemStatus>good</systemStatus>
    <activeVseHaIndex>0</activeVseHaIndex>
    <edgeStatus>GREEN</edgeStatus>
    <publishStatus>APPLIED</publishStatus>
    <version>165</version>
    <edgeVmStatus/>
    <featureStatuses>
        <featureStatus>
            <service>routing</service>
            <status>Applied</status>
        </featureStatus>
        <featureStatus>
            <service>highAvailability</service>
            <status>not_configured</status>
        </featureStatus>
        <featureStatus>
            <service>ipsec</service>
            <status>down</status>
        </featureStatus>
        <featureStatus>
            <service>nat</service>
            <status>Applied</status>
        </featureStatus>
        <featureStatus>
            <service>sslvpn</service>
            <status>up</status>
        </featureStatus>
        <featureStatus>
            <service>loadBalancer</service>
            <status>down</status>
        </featureStatus>
        <featureStatus>
            <service>l2vpn</service>
            <status>not_configured</status>
        </featureStatus>
        <featureStatus>
            <service>firewall</service>
            <status>Applied</status>
        </featureStatus>
        <featureStatus>
            <service>dhcp</service>
            <status>up</status>
        </featureStatus>
        <featureStatus>
            <service>syslog</service>
            <status>down</status>
        </featureStatus>
        <featureStatus>
            <service>dns</service>
            <status>up</status>
        </featureStatus>
    </featureStatuses>
</edgeStatus>

How can I turn this info into a sensor? This is for VMware NSX.

Regards Trevor


Article Comments

Hello there, we appreciate your contact.

How did you attempt to monitor this with PRTG?

Essentially, the best sensor for the job is the REST Custom sensor. However, none of the statuses in the XML are numerical, they appear to be: Up, Down, Applied and not_configured.

Since PRTG expects numerical values, you will need to apply the Lookup function in the rest custom template:

lookup({mysource.string}, string, string, ....)

After that the sensor should be successfully deployed and will display all corresponding numerical values in the sensor's overview. The next step is creating a corresponding PRTG Lookup to define the corresponding Text and alert level, something like this:

<?xml version="1.0" encoding="UTF-8"?>
  <ValueLookup id="prtg.customlookups.something" desiredValue="0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PaeValueLookup.xsd" undefinedState="Warning">
    <Lookups>
      <SingleInt state="Ok" value="0">Up</SingleInt>
	  <SingleInt state="Error" value="1">Down</SingleInt>
      <SingleInt state="Error" value="2">Applied</SingleInt>
	  <SingleInt state="Error" value="3">Not Configured</SingleInt>
    </Lookups>
  </ValueLookup>

The other alternative would be to write a custom sensor (Powershell, exe, etc) to evaluate the XML and produce a PRTG-compliant output: HTTP Data Advanced - JSON response formatting

You can find further details about the Custom Sensors API on the following URL or within your PRTG's web-interface under Setup > PRTG API.

Best Regards,
Luciano Lingnau [Paessler Support]


Oct, 2017 - Permalink