What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

REST API Sensor - Filter Expression doesnt work - Cisco Telepresence Devices

Votes:

0

Hi there,

i already build some custom sensors (templates) to monitor our cisco telepresence endpoints. All doing well except that one:

The expression filter doesn't work for me. With jsonpath.com my JSONPath Syntax looks ok and gave me the correct value.

The sensor in PRTG gave me this error: "Could no evaluate channel value of TouchPanel Status: expected type string for parameter 0 but got []interface {}."

Regarding the documention https://www.paessler.com/manuals/prtg/rest_custom_sensor


You can filter matches with [?<expression>]. This expression matches 35985021 in the example above because the first device is the only one with a beta channel: $.devices[[email protected]=="beta"].networks.a.rx_bytes ---

my jsonpath (working at http://jsonpath.com/ and http://www.jsonquerytool.com/#/JSONPath)

$.Status.Peripherals.ConnectedDevice[?(@.Type.Value=="TouchPanel")].Status I also tried without the () Doesn't work either.

Any hints?

Greetings from Berlin, Sebastian

Here my json output of the telepresence device

{
  "Status":{
    "Peripherals":{
      "ConnectedDevice":[
        {
          "id":"1004",
          "HardwareInfo":{
            "Value":"102310-1"
          },
          "ID":{
            "Value":"xx:xx:xx:xx:xx:xx"
          },
          "Name":{
            "Value":"Cisco TelePresence Touch"
          },
          "SoftwareInfo":{
            "Value":"ce9.6.1.4516ae5aaa1"
          },
          "Status":{
            "Value":"Connected"
          },
          "Type":{
            "Value":"TouchPanel"
          },
          "UpgradeStatus":{
            "Value":"None"
          }
        },
        {
          "id":"1016",
          "HardwareInfo":{
            "Value":"iPhone10,4"
          },
          "ID":{
            "Value":"xxxxx"
          },
          "Name":{
            "Value":"iPhone8"
          },
          "SoftwareInfo":{
            "Value":"ios-2.0.3"
          },
          "Status":{
            "Value":"Connected"
          },
          "Type":{
            "Value":"Byod"
          },
          "UpgradeStatus":{
            "Value":"None"
          }
        }
      ]
    }
  }
}

my template

{
 "prtg": {
  "description" : {
   "device": "Cisco Telepresence Devices",
   "query": "/getxml?location=status/Peripherals/ConnectedDevice",
   "comment":"Shows peripheral devices that are currently connected to the endpoint. via Expression filtered if Type = TouchPanel show Status",
  },
  "text": $.Status.Peripherals.ConnectedDevice[[email protected]=="TouchPanel"].Status,
  "result": [
   {
    "channel": "TouchPanel Status",
    "value": lookup($.Status.Peripherals.ConnectedDevice[[email protected]=="TouchPanel"].Status, "ResponseTimedOut", "Connected", "Unpairing", "LostConnection")
   }
   ]
 }
}

api cisco custom-sensor rest

Created on Mar 13, 2019 3:49:03 PM



10 Replies

Votes:

0

Hi there,

I think I found a small mistake in your template. The result needs to be pointed directly to the status value. It should look like the following:

{
 "prtg": {
  "description" : {
   "device": "Cisco Telepresence Devices",
   "query": "/getxml?location=status/Peripherals/ConnectedDevice",
   "comment":"Shows peripheral devices that are currently connected to the endpoint. via Expression filtered if Type = TouchPanel show Status",
  },
  "text": $.Status.Peripherals.ConnectedDevice[[email protected]=="TouchPanel"].Status.value,
  "result": [
   {
    "channel": "TouchPanel Status",
    "value": lookup($.Status.Peripherals.ConnectedDevice[[email protected]=="TouchPanel"].Status.value, "ResponseTimedOut", "Connected", "Unpairing", "LostConnection")
   }
   ]
 }
}


Please let me know if this solves your issue.


Kind regards,
Birk Guttmann, Tech Support Team

Created on Mar 14, 2019 2:57:33 PM by  Birk Guttmann [Paessler Support]



Votes:

0

Hi Birk,

no same error :-/

What about the filter expression? with or without the brackets ()?

[[email protected]=="TouchPanel"]

[?(@.Type.Value=="TouchPanel")]

But both doesnt work.

This one: $.Status.Peripherals.ConnectedDevice[0].Status.Value works btw. so i think there is some error with filter expression module?

BR Sebastian

Created on Mar 14, 2019 3:21:46 PM



Votes:

0

Hi there,

ok 1st learning:

Always use the rest.exe.

the above output is from the endpoint console (xpreferences outputmode json) but it seems to differ from the web output :-/ sorry for the confusion.

so this is the output from the rest.exe

{
  "Status": {
    "Peripherals": {
      "ConnectedDevice": [
        {
          "-item": 3191,
          "-maxOccurrence": "n",
          "HardwareInfo": "102310-1",
          "ID": "00:62:ec:8d:e8:36",
          "Name": "Cisco TelePresence Touch",
          "SoftwareInfo": "ce9.6.1.4516ae5aaa1",
          "Status": "Connected",
          "Type": "TouchPanel",
          "UpgradeStatus": "None"
        },
        {
          "-item": 3483,
          "-maxOccurrence": "n",
          "HardwareInfo": "proximity-desktop-osx",
          "ID": "e7e162b0",
          "Name": "marab",
          "SoftwareInfo": "desktop-3.0.0",
          "Status": "Connected",
          "Type": "Byod",
          "UpgradeStatus": "None"
        }
      ]
    },
    "apiVersion": 4,
    "product": "Cisco Codec",
    "version": "ce9.6.1.4516ae5aaa1"
  }
}

But still the same:

with $.Status.Peripherals.ConnectedDevice[?(@.Type == "TouchPanel")].Status

in JSONPath it is working in PRTG still the "Could no evaluate channel value of TouchPanel Status: expected type string for parameter 0 but got []interface {}."

?!?

Created on Mar 15, 2019 11:13:43 AM



Votes:

0

I'll forward this to the developer so he can check it out :) Not sure what's missing here either :D


PRTGapi | Feature Requests | WMI Issues | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team

Created on Mar 18, 2019 7:21:29 AM by  Stephan Linke [Paessler Support]



Votes:

0

Could you try the following syntax instead: "value": $.Status.Peripherals.ConnectedDevice[[email protected]=="TouchPanel"].Status.value.(lookup(@, "ResponseTimedOut", "Connected", "Unpairing", "LostConnection"))

It's basically the same as yours, but with the syntax appended instead of prepended, since you're retrieving possible multiple results. Let me know if it worked! :)


PRTGapi | Feature Requests | WMI Issues | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team

Created on Mar 18, 2019 8:03:36 AM by  Stephan Linke [Paessler Support]



Votes:

0

Hi Stephan,

now i got this:

Parsing error: { "prtg": { "description" : { "device": "Cisco Telepresence Devices", "query": "/getxml?location=status/Peripherals/ConnectedDevice", "comment":"Shows peripheral devices that are currently connected to the endpoint. via Expression filtered if Type = TouchPanel show Status", }, "text": $.Status.Peripherals.ConnectedDevice[?(@.Type == "TouchPanel")].Status, "result": [ { "channel": "TouchPanel Status", "value": $.Status.Peripherals.ConnectedDevice[[email protected]=="TouchPanel"].Status.value.(lookup(@, "ResponseTimedOut", "Connected", "Unpairing", "LostConnection")) } ] } }:13:90 - 13:91 unexpected "(" while scanning JSON select expected Ident, "." or "*".

:-/

Created on Apr 1, 2019 11:16:14 AM

Last change on Apr 1, 2019 6:46:01 PM by  Stephan Linke [Paessler Support]



Votes:

0

I've forwarded it to the corresponding developer - may take a bit until I hear from him, though.


PRTGapi | Feature Requests | WMI Issues | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team

Created on Apr 5, 2019 10:30:20 AM by  Stephan Linke [Paessler Support]



Votes:

0

I beg your pardon, this took way longer than anticipated. The actual correct template would be this one:

{
 "prtg": {
  "description" : {
   "device": "Cisco Telepresence Devices",
   "query": "/getxml?location=status/Peripherals/ConnectedDevice",
   "comment":"Shows peripheral devices that are currently connected to the endpoint. via Expression filtered if Type = TouchPanel show Status",
  },
  "result": [
   {
    "channel": "TouchPanel Status",
    "value": lookup($($.Status.Peripherals.ConnectedDevice[[email protected]=="TouchPanel"].Status)[0], "ResponseTimedOut", "Connected", "Unpairing", "LostConnection")
   }
   ],
   "text": $.Status.Peripherals.ConnectedDevice[[email protected]=="TouchPanel"].Status,
 }
}

Just tested it with your sample output and it yields the following:



Now you just need to come up with a corresponding lookup :)


PRTGapi | Feature Requests | WMI Issues | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team

Created on Apr 17, 2019 11:06:29 AM by  Stephan Linke [Paessler Support]



Votes:

0

Hi Stephan,

yes no it is working. But unfortunately the output can be in the forms.

1. the working one, with an array the touchpanel and a desktop with the proximity client is connected

{
  "Status": {
    "Peripherals": {
      "ConnectedDevice": [
        {
          "-item": 1004,
          "-maxOccurrence": "n",
          "HardwareInfo": "102310-1",
          "ID": "00:00:00:00:00:00",
          "Name": "Cisco TelePresence Touch",
          "SerialNumber": "00000000000",
          "SoftwareInfo": "ce9.7.1.30bff6140aa",
          "Status": "Connected",
          "Type": "TouchPanel",
          "UpgradeStatus": "None"
        },
        {
          "-item": 1068,
          "-maxOccurrence": "n",
          "HardwareInfo": "proximity-desktop-osx",
          "ID": "a9f300fe",
          "Name": "username",
          "SerialNumber": "unknown",
          "SoftwareInfo": "desktop-3.0.3",
          "Status": "Connected",
          "Type": "Byod",
          "UpgradeStatus": "None"
        }
      ]
    },
    "apiVersion": 4,
    "product": "Cisco Codec",
    "version": "ce9.7.1.30bff6140aa"
  }
}


and the not working one

2. without an array because only one device (the touchpanel) is connected)

{
  "Status": {
    "Peripherals": {
      "ConnectedDevice": {
        "-item": 1004,
        "-maxOccurrence": "n",
        "HardwareInfo": "102310-1",
        "ID": "00:00:00:00:00:00",
        "Name": "Cisco TelePresence Touch",
        "SerialNumber": "0000000000",
        "SoftwareInfo": "ce9.7.1.30bff6140aa",
        "Status": "Connected",
        "Type": "TouchPanel",
        "UpgradeStatus": "None"
      }
    },
    "apiVersion": 4,
    "product": "Cisco Codec",
    "version": "ce9.7.1.30bff6140aa"
  }
}

Do you or the developer have an idea how to fix that?

Sebastian

Created on May 9, 2019 2:47:35 PM

Last change on May 9, 2019 2:50:11 PM by  Stephan Linke [Paessler Support]



Votes:

0

Ah, so it's not a JSON array when there's only one connected? Something like this might work:

lookup($($.Status.Peripherals.ConnectedDevice[[email protected]=="TouchPanel"].Status), "ResponseTimedOut", "Connected", "Unpairing", "LostConnection")

Note the missing [0]. So for devices like that, only another Sensor would work I guess. Not sure if you can discern between the two in the first place - like, if they're hardwired and won't change without you getting notified?


PRTGapi | Feature Requests | WMI Issues | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team

Created on May 10, 2019 7:49:49 AM by  Stephan Linke [Paessler Support]




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.