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[?@.firmware.channel=="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[?@.Type.Value=="TouchPanel"].Status, "result": [ { "channel": "TouchPanel Status", "value": lookup($.Status.Peripherals.ConnectedDevice[?@.Type.Value=="TouchPanel"].Status, "ResponseTimedOut", "Connected", "Unpairing", "LostConnection") } ] } }
Article Comments
Hi Birk,
no same error :-/
What about the filter expression? with or without the brackets ()?
[?@.Type.Value=="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
Mar, 2019 - Permalink
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 {}."
?!?
Mar, 2019 - Permalink
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
Mar, 2019 - Permalink
Could you try the following syntax instead:
"value": $.Status.Peripherals.ConnectedDevice[?@.Type.Value=="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
Mar, 2019 - Permalink
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[?@.Type.Value=="TouchPanel"].Status.value.(lookup(@, "ResponseTimedOut", "Connected", "Unpairing", "LostConnection")) } ] } }:13:90 - 13:91 unexpected "(" while scanning JSON select expected Ident, "." or "*".
:-/
Apr, 2019 - Permalink
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
Apr, 2019 - Permalink
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[?@.Type=="TouchPanel"].Status)[0], "ResponseTimedOut", "Connected", "Unpairing", "LostConnection") } ], "text": $.Status.Peripherals.ConnectedDevice[?@.Type=="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
Apr, 2019 - Permalink
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
May, 2019 - Permalink
Ah, so it's not a JSON array when there's only one connected? Something like this might work:
lookup($($.Status.Peripherals.ConnectedDevice[?@.Type=="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
May, 2019 - Permalink
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:
Please let me know if this solves your issue.
Kind regards,
Birk Guttmann, Tech Support Team
Mar, 2019 - Permalink