New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


Custom REST sensor and json path for Aerohive API

Votes:

0

Your Vote:

Up

Down

Greetings,

I'm looking for help on how to generate sensors from the Aerohive REST API. I have this dataset and I want to use the REST Sensor in PRTG

I'd like each sensor to have the "hostName" as the name and the "clients" as the value for the sensor.

[ { "audit": "Matched", "hostName": "AP20", "alarm": "Cleared", "interfaceIp": "192.168.3.94", "externalIp": "xxx.xxx.xxx.xxx", "topologyName": "Our Address", "nodeId": "9CXX1234BFXX", "connection": true, "deviceMode": "Portal", "clients": 0, "upTime": "1 Days, 18 Hrs 7 Mins 45 Secs", "hiveOS": "HiveOS 6.6r1b.2338", "deviceFunciton": "AP", "appSignature": "4.0.8", "countryCode": "(840) United States", "defaultGateWay": "192.168.1.20", "dhcpClient": "Enabled", "discoveryTime": "09-03-2014 12:11:58", "eth0LLDPPort": "37(interface alias)", "eth0LLDPSysId": "e055:xxxx:xxxx(mac address)", "eth0LLDPSysName": "Coreswitch2", "eth1LLDPPort": "-", "eth1LLDPSysId": "-", "eth1LLDPSysName": "-", "hive": "Out_Hive", "inOrOutDoor": "Indoor", "location": "B-2nd Floor", "mgtVlan": "1", "nativeVlan": "1", "netmask": "255.255.248.0", "networkPolicy": "Our Policy", "serialNumber": "02301407XXXXX", "wifi0Channel": "1", "wifi0Power": "11 dBm", "wifi0RadioProfile": "radio_ng0", "wifi1Channel": "44", "wifi1Power": "20 dBm", "wifi1RadioProfile": "radio_ac0", "hwmodel": "AP230" }, { "audit": "Matched", "hostName": "AP21", "alarm": "Cleared", "interfaceIp": "192.168.3.94", "externalIp": "xxx.xxx.xxx.xxx", "topologyName": "Our Address", "nodeId": "9CXX1234BFXX", "connection": true, "deviceMode": "Portal", "clients": 4, "upTime": "1 Days, 18 Hrs 7 Mins 26 Secs", "hiveOS": "HiveOS 6.6r1b.2338", "deviceFunciton": "AP", "appSignature": "4.0.8", "countryCode": "(840) United States", "defaultGateWay": "192.168.1.20", "dhcpClient": "Enabled", "discoveryTime": "09-03-2014 15:31:40", "eth0LLDPPort": "40(interface alias)", "eth0LLDPSysId": "e055:3dfc:55f2(mac address)", "eth0LLDPSysName": "Coreswitch2", "eth1LLDPPort": "-", "eth1LLDPSysId": "-", "eth1LLDPSysName": "-", "hive": "Our_Hive", "inOrOutDoor": "Indoor", "location": "B-2nd Floor", "mgtVlan": "1", "nativeVlan": "1", "netmask": "255.255.248.0", "networkPolicy": "Our Policy", "serialNumber": "02301407090105", "wifi0Channel": "11", "wifi0Power": "11 dBm", "wifi0RadioProfile": "radio_ng0", "wifi1Channel": "149", "wifi1Power": "20 dBm", "wifi1RadioProfile": "radio_ac0", "hwmodel": "AP230" } ]

aerohive prtg rest rest-api rest-api-sensor

Created on Feb 1, 2018 9:44:50 PM by  jasontucker (0) 1

Last change on Feb 2, 2018 9:02:49 AM by  Erhard Mikulik [Paessler Support]



11 Replies

Votes:

0

Your Vote:

Up

Down

Hi Jason,

You need to create a template that contains the definition of the data you want to retrieve:

  • Open up a text editor where you paste the following
{
	"prtg": {
		"result": [{
				"unit": "Count",
				"value": {"host " + $[ # 0].hostName: $[ * ].clients}
			}, ]
	}
}
  • Save the file with extension .template to directory "Custom Sensors\rest" located in PRTG's installation path, for example Aerohive.template
  • In PRTG head to Setup | System Administration | Administrative Tools and hit the button for reloading lookups and file lists.
  • Make sure to create a device in PRTG with the aerohive's IP.
  • Add the REST Custom Sensor to it.
  • For Query URL you only need to enter the portion that comes after the hostname, since the hostname/IP is being pulled from the device you've created before.

Keep in mind that you might need to take of authentication with a token maybe, see here the documentation of the Aerohive REST API.

Kind regards,

Erhard

Created on Feb 2, 2018 9:14:10 AM by  Erhard Mikulik [Paessler Support]

Last change on Feb 2, 2018 10:13:44 AM by  Erhard Mikulik [Paessler Support]



Votes:

0

Your Vote:

Up

Down

hi jason , can you please share the result of the template and hes output , i really need to verify which filed and how you present it .

will be great help , thx, Dor.

Created on Jun 18, 2018 2:07:39 PM by  dor shalom (0) 1



Votes:

0

Your Vote:

Up

Down

So in my case, I have REST Query return below JSON and I want to create a template so that sensor has values for name, connectionType, connectionStatus, ingressBytesTransferred, and egressBytesTransferred.

{
    "name": "GATEWAYA-CORPNET",
    "id": "/subscriptions/0if966538-zxxc-1tl0-qz2t-yn750x36pvn/resourceGroups/RESOURCEGROUP/providers/Microsoft.Network/connections/GATEWAYA-CORPNET",
    "etag": "W/\"lscitbit6-4xhq-cpik-5ne1-b4gh8vg41og\"",
    "type": "Microsoft.Network/connections",
    "location": "westus",
    "properties": {
        "provisioningState": "Succeeded",
        "resourceGuid": "chov25ovl-blrw-j5lo-zg9p-3drw1869azf",
        "virtualNetworkGateway1": {
            "id": "/subscriptions/0if966538-zxxc-1tl0-qz2t-yn750x36pvn/resourceGroups/RESOURCEGROUP/providers/Microsoft.Network/virtualNetworkGateways/GATEWAYA"
        },
        "localNetworkGateway2": {
            "id": "/subscriptions/0if966538-zxxc-1tl0-qz2t-yn750x36pvn/resourceGroups/RESOURCEGROUP/providers/Microsoft.Network/localNetworkGateways/CORPNET"
        },
        "connectionType": "IPsec",
        "routingWeight": 0,
        "sharedKey": "zvxx5z1gqadn8fglcdj6vx9nh2znwsaa",
        "enableBgp": false,
        "usePolicyBasedTrafficSelectors": false,
        "ipsecPolicies": [],
        "connectionStatus": "Connected",
        "ingressBytesTransferred": 6934594856,
        "egressBytesTransferred": 11377914688
    }
}

How do I accomplish this? I am having issue with unit and value in my template. Here is my template.

{ "prtg": { "description" : { "device": "Azure Virtual Network Gateway Connection", "query": "GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}?api-version=2018-04-01", "comment": "Documentation is on https://docs.microsoft.com/en-us/rest/api/network-gateway/virtualnetworkgatewayconnections/get" }, "result": [ { "channel": "ingressBytesTransferred", "unit": "BytesBandwidth", "value": $.properties.ingressBytesTransferred }, { "channel": "egressBytesTransferred", "unit": "BytesBandwidth", "value": $.properties.ingressBytesTransferred }, { "channel": "connectionType", "unit": "custom", "CustomUnit": (string), "value": $.properties.connectionType } ] } }

Created on Aug 20, 2018 8:35:47 PM by  Batman (0) 1

Last change on Aug 21, 2018 4:41:41 AM by  Felix Saure [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Well, PRTG cannot evaluate strings, you'll need to use lookups instead:

 {
                "channel": "connectionType",
		"unit": "count",
                "lookup": "name.of.your.lookup"
		"value": lookup($.properties.connectionType, "enter", "all", "available","connection","types")
      }

According to the value, it will be 0 to x, depending on how many values are possible. Additionally, you'll need to reference the lookup accordingly:

https://www.paessler.com/manuals/prtg/define_lookups

Created on Aug 21, 2018 8:32:54 AM by  Stephan Linke [Paessler Support]

Last change on Aug 21, 2018 8:38:01 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Can you please validate my syntax? I am getting a parsing error when creating a sensor. Following is my template

azure.VirtualNetworkGatewayConnection.template

{
  "prtg": {
    "description" : {
      "device": "Azure Virtual Network Gateway Connection",
      "query": "GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}?api-version=2018-04-01",
      "comment": "Documentation is on https://docs.microsoft.com/en-us/rest/api/network-gateway/virtualnetworkgatewayconnections/get"
    },
    "result": [
	  {
        "channel": "ingressBytesTransferred",
		"unit": "BytesBandwidth",
        "value": $.properties.ingressBytesTransferred
      },
	  {
        "channel": "egressBytesTransferred",
		"unit": "BytesBandwidth",
        "value": $.properties.ingressBytesTransferred
      },
	  {
        "channel": "connectionType",
		"unit": "count",
		"lookup": "azure.VirtualNetworkGatewayConnection.connectionType",
		"value": lookup($.properties.connectionType, "Ipsec", "Vnet2Vnet", "ExpressRoute", "VPNClient")
      },
	  {
        "channel": "connectionStatus",
		"unit": "count",
		"lookup": "azure.VirtualNetworkGatewayConnection.connectionStatus",
		"value": lookup($.properties.connectionStatus, "Unknown", "Connecting", "Connected" and "NotConnected")
      }
    ]
  }
}

And my lookup files are as following...

azure.VirtualNetworkGatewayConnection.connectionStatus.ovl

<?xml version="1.0" encoding="UTF-8"?>
  <ValueLookup id="azure.VirtualNetworkGatewayConnection.connectionStatus" desiredValue="0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PaeValueLookup.xsd">
    <Lookups>
      <SingleInt state="Connected" value="0">
        The connection has successfully connected.
      </SingleInt>
      <SingleInt state="Connecting" value="1">
        The connection is connected.
      </SingleInt>
      <SingleInt state="NotConnected" value="2">
        The connection is not connected.
      </SingleInt>
      <SingleInt state="Unknown" value="3">
        The connection is in unknown state.
      </SingleInt>
    </Lookups>
  </ValueLookup>

azure.VirtualNetworkGatewayConnection.connectionType.ovl

<?xml version="1.0" encoding="UTF-8"?>
  <ValueLookup id="azure.VirtualNetworkGatewayConnection.connectionType" desiredValue="0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PaeValueLookup.xsd">
    <Lookups>
      <SingleInt state="Ipsec" value="0">
        This is a site-to-site IPSec vpn connection.
      </SingleInt>
      <SingleInt state="Vnet2Vnet" value="1">
        This is a vnet-to-vnet vpn connection.
      </SingleInt>
      <SingleInt state="ExpressRoute" value="2">
        This is a ExpressRoute vpn connection.
      </SingleInt>
      <SingleInt state="VPNClient" value="3">
        This is a Point-to-Site vpn connection.
      </SingleInt>
    </Lookups>
  </ValueLookup>

Created on Aug 21, 2018 8:26:56 PM by  Batman (0) 1



Votes:

0

Your Vote:

Up

Down

Two mistakes were made:

  1. it's valuelookup instead of value in the .template file

  2. The channel lookup of the connectionStatus channel needs to be this:
"value": lookup($.properties.connectionStatus, "Unknown", "Connecting", "Connected", "NotConnected")

You have added an and, which doesn't belong there ;)


Kind regards,
Stephan Linke, Tech Support Team

Created on Aug 22, 2018 1:47:56 PM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Do you mean valuelookup instead of lookup or valuelookup instead of value? Also in the Aerohive dataset above, if I wanted to get the "hiveOS": "HiveOS 6.6r1b.2338" value, it would be a same issue as mine where PRTG cannot evaluate strings, correct?

Created on Aug 22, 2018 6:45:05 PM by  Batman (0) 1



Votes:

0

Your Vote:

Up

Down

After using following for connectionStatus…

{
        "channel": "connectionType",
		"unit": "count",
		"valuelookup": "azure.VirtualNetworkGatewayConnection.connectionType",
		"value": lookup($.properties.connectionType, "Ipsec", "Vnet2Vnet", "ExpressRoute", "VPNClient")
}

I still get Could not create channel connectionType: expected number but got IPsec (string). error

Created on Aug 22, 2018 7:42:09 PM by  Batman (0) 1



Votes:

0

Your Vote:

Up

Down

Both of my lookups are stored in lookups\custom folder and after refreshing Load Lookups and File Lists in PRTG Admin Tools the lookup files are not loading.

My lookup files syntax is simple copy/paste modification of the original prtg lookup files

<?xml version="1.0" encoding="UTF-8"?>
  <ValueLookup id="azure.VirtualNetworkGatewayConnection.connectionStatus" desiredValue="2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PaeValueLookup.xsd">
    <Lookups>
      <SingleInt state="Connected" value="2">
        Connected
      </SingleInt>
      <SingleInt state="Connecting" value="1">
        Connecting
      </SingleInt>
      <SingleInt state="NotConnected" value="0">
        NotConnected
      </SingleInt>
      <SingleInt state="None" value="3">
        Unknown
      </SingleInt>
    </Lookups>
  </ValueLookup>

<?xml version="1.0" encoding="UTF-8"?>
  <ValueLookup id="azure.VirtualNetworkGatewayConnection.connectionType" desiredValue="-1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PaeValueLookup.xsd">
    <Lookups>
      <SingleInt state="IPSec" value="-1">
        IPSec
      </SingleInt>
      <SingleInt state="Vnet2Vnet" value="1">
        Vnet2Vnet
      </SingleInt>
      <SingleInt state="ExpressRoute" value="2">
        ExpressRoute
      </SingleInt>
      <SingleInt state="VPNClient" value="3">
        VPNClient
      </SingleInt>
    </Lookups>
  </ValueLookup>

Created on Aug 22, 2018 10:37:23 PM by  Batman (0) 1



Votes:

0

Your Vote:

Up

Down

What actual error do you get within the Sensor? What does your whole .template look like? I actually meant valuelookup instead of just lookup :)


Kind regards,
Stephan Linke, Tech Support Team

Created on Aug 23, 2018 5:35:46 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

My .template looks like this...

azure.VirtualNetworkGatewayConnection.template

{
  "prtg": {
    "description" : {
      "device": "Azure Virtual Network Gateway Connection",
      "query": "GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}?api-version=2018-04-01",
      "comment": "Documentation is on https://docs.microsoft.com/en-us/rest/api/network-gateway/virtualnetworkgatewayconnections/get"
    },
    "result": [
	  {
        "channel": "ingressBytesTransferred",
		"unit": "BytesBandwidth",
        "value": $.properties.ingressBytesTransferred
      },
	  {
        "channel": "egressBytesTransferred",
		"unit": "BytesBandwidth",
        "value": $.properties.ingressBytesTransferred
      },
	  {
        "channel": "connectionType",
		"unit": "count",
		"valueLookup": "azure.VirtualNetworkGatewayConnection.connectionType",
		"value": lookup($.properties.connectionType,"IPsec", "Vnet2Vnet", "ExpressRoute", "VPNClient")
      },
	  {
        "channel": "connectionStatus",
		"unit": "count",
		"valueLookup": "azure.VirtualNetworkGatewayConnection.connectionStatus",
		"value": lookup($.properties.connectionStatus, "Unknown", "Connecting", "Connected", "NotConnected")
      }
    ]
  }
}

azure.VirtualNetworkGatewayConnection.connectionType.ovl

<?xml version="1.0" encoding="UTF-8"?>
  <ValueLookup id="azure.VirtualNetworkGatewayConnection.connectionType" desiredValue="0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PaeValueLookup.xsd">
    <Lookups>
      <SingleInt state="IPSec" value="0">
        IPSec
      </SingleInt>
      <SingleInt state="Vnet2Vnet" value="1">
        Vnet2Vnet
      </SingleInt>
      <SingleInt state="ExpressRoute" value="2">
        ExpressRoute
      </SingleInt>
      <SingleInt state="VPNClient" value="3">
        VPNClient
      </SingleInt>
    </Lookups>
  </ValueLookup>

azure.VirtualNetworkGatewayConnection.connectionStatus.ovl

<?xml version="1.0" encoding="UTF-8"?>
  <ValueLookup id="azure.VirtualNetworkGatewayConnection.connectionStatus" desiredValue="2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PaeValueLookup.xsd">
    <Lookups>
      <SingleInt state="NotConnected" value="0">
        NotConnected
      </SingleInt>
      <SingleInt state="Connecting" value="1">
        Connecting
      </SingleInt>
      <SingleInt state="Connected" value="2">
        Connected
      </SingleInt>
      <SingleInt state="Unknown" value="3">
        Unknown
      </SingleInt>
    </Lookups>
  </ValueLookup>

I don't get an error. I just can't reload the lookup to get the right value in PRTG console. All I get is 2 for connectionStatus and 0 or 1 for connectionType. I want PRTG to show GatewayConnectionName, ConnectionStatus, ConnectionType, ingressBytesTransferred and egressBytesTransferred.

Created on Aug 23, 2018 11:10:13 PM by  Batman (0) 1



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.