HWiNFO has a plugin called "Remote Sensor Monitor" that provides hardware sensor values over a small webserver on the host system (https://www.hwinfo.com/addons.php)
Small example output here (also available here, if formatting below is broken: https://pastebin.com/wPqaf5YQ)
[ { "SensorApp": "HWiNFO", "SensorClass": "CPU [#0]: Intel Core i7-8700K", "SensorName": "Core #0 Clock", "SensorValue": "4099,016", "SensorUnit": "MHz", "SensorUpdateTime": 1535033257 }, { "SensorApp": "HWiNFO", "SensorClass": "CPU [#0]: Intel Core i7-8700K: DTS", "SensorName": "Core #0", "SensorValue": "35", "SensorUnit": "°C", "SensorUpdateTime": 1535033257 }, { "SensorApp": "HWiNFO", "SensorClass": "CPU [#0]: Intel Core i7-8700K: DTS", "SensorName": "CPU Package", "SensorValue": "36", "SensorUnit": "°C", "SensorUpdateTime": 1535033257 }, { "SensorApp": "HWiNFO", "SensorClass": "CPU [#0]: Intel Core i7-8700K: DTS", "SensorName": "Core Max", "SensorValue": "36", "SensorUnit": "°C", "SensorUpdateTime": 1535033257 }, { "SensorApp": "HWiNFO", "SensorClass": "CPU [#0]: Intel Core i7-8700K: DTS", "SensorName": "Core #0 Thermal Throttling", "SensorValue": "0", "SensorUnit": "Yes/No", "SensorUpdateTime": 1535033257 }, { "SensorApp": "HWiNFO", "SensorClass": "S.M.A.R.T.: Crucial_CT525MX300SSD1 (162913483656)", "SensorName": "Drive Remaining Life", "SensorValue": "98", "SensorUnit": "%", "SensorUpdateTime": 1535033257 } ]
By using http://jsonpath.com/ I am able to create a working filter that (as an example) extracts the "CPU Package" value in a specific SensorClass named "CPU [#0]: Intel Core i7-8700K: DTS".
$.[?(@.SensorClass == 'CPU [#0]: Intel Core i7-8700K: DTS' && @.SensorName == 'CPU Package')].SensorValue
As a result I get the following output:
[ "36" ]
I have created a .template on the PRTG server with the following content:
{ "prtg": { "description" : { "device": "192.168.1.51:55555", "query": "/", "comment": "demo" }, "result": [ { "channel": "Temperature", "value": $.[?(@.SensorClass == 'CPU [#0]: Intel Core i7-8700K: DTS' && @.SensorName == 'CPU Package')].SensorValue, "unit": "Temperature" } ] } }
Using this template on the "REST Custom BETA" sensor produces this error:
16:08:41 TYRELL REST Custom BETA REST Custom Warning Parsing error: { "prtg": { "description" : { "device": "192.168.1.51:55555", "query": "/", "comment": "demo" }, "result": [ { "channel": "Temperature", "value": $.[?(@.SensorClass == 'CPU [#0]: Intel Core i7-8700K: DTS' && @.SensorName == 'CPU Package')].SensorValue, "unit": "Temperature" } ] } } :11:20 - 11:21 unexpected "[" while scanning JSON select expected Ident, "." or "*".
I might be mistaken, but as far as I can tell, this is because there are square brackets in the output of the jsonpath filter used.
So my question is: Is there any way to get the square brackets stripped away without having to use external parsing of the json output? (Or is there something else causing the error here?)
Add comment