Assuming the REST response below:
{
"alert": [],
"amps": [],
"cloud": {},
"connections": {
"LISTEN": 68,
"ESTABLISHED": 261,
"SYN_SENT": 0,
"SYN_RECV": 0,
"initiated": 0,
"terminated": 0
},
"processlist": [
{
"pid": 8368,
"cpu_times": [
3.140625,
224.3125,
0,
0
],
"cmdline": [
"C:\\Users\\MKANET\\AppData\\Local\\Programs\\Python\\Python310\\python.exe",
"C:\\Users\\MKANET\\AppData\\Local\\Programs\\Python\\Python310\\Scripts\\glances.exe",
"-w",
"-0",
"--disable-autodiscover",
"--disable-plugin",
"docker",
"--config",
"C:\\Users\\MKANET\\AppData\\Local\\Programs\\Python\\Python310\\scripts\\glances.conf",
"-q"
],
"username": "TITAN\\MKANET"
},
I would like to capture the first 2 lines listed in "cmdline":[ ]
. Below, is my best attempt at doing this; which is wrong. It only displays the first line as the sensor state, It doesn’t list the 2 lines as attributes in this sensor.
rest:
- resource: http://192.168.1.55:61208/api/3/all
sensor:
- name: process_0_cmdline
value_template: '{{ value_json.processlist.0.cmdline.0 | default }}'
json_attributes_path: "$.processlist.0.cmdline.[0,1]"
json_attributes:
-[0]
-[1]