Hi Community,
I’ve been trying to create a sensor which displays a shell stdout output as a value, so I can parse it to fetch some relevant info only, and to store it input_text helper (for example) so I can display it in the dashboard or manage it through templates. Basicaly, I would like to extract the date/time from the first line so I can monitor whether the command is executed everyday.
However, I cannot even manage to get the full stdout
into a sensor value. Upon creating the sensor according to documentation, sensor always displays “unknown”. This is what I have done so far:
This is the shell_command:
shell_command:
check_certs_asus: !secret check_certs_asus
Such secret contains the relevant command, which I know it works fine because if I call the shell_command service shell_command.check_certs_asus
from the service developer tool, the output is the expected content:
stdout: |-
Wed Feb 21 16:00:00 MET 2024
# INFO: Using main config file /tmp/mnt/USB_ASUS/entware/etc/nginx/config
Processing domain1.com
+ Checking domain name(s) of existing cert... unchanged.
+ Checking expire date of existing cert...
+ Valid till Mar 27 20:42:47 2024 GMT (Longer than 30 days). Skipping renew!
# INFO: Using main config file /tmp/mnt/USB_ASUS/entware/etc/nginx/config
Processing domain2.com
+ Checking domain name(s) of existing cert... unchanged.
+ Checking expire date of existing cert...
+ Valid till Mar 27 20:43:31 2024 GMT (Longer than 30 days). Skipping renew!
# INFO: Using main config file /tmp/mnt/USB_ASUS/entware/etc/nginx/config
Processing domain3.com
+ Checking domain name(s) of existing cert... unchanged.
+ Checking expire date of existing cert...
+ Valid till Mar 27 20:43:17 2024 GMT (Longer than 30 days). Skipping renew!
Wed Feb 21 16:00:06 MET 2024
stderr: Pseudo-terminal will not be allocated because stdin is not a terminal.
returncode: 0
As for the sensor template, this is what I have:
command_line:
- sensor:
command: !secret check_certs_asus
name: "Comprobar SSL"
From this point, I understand that the sensor.check_certs_asus
should be updated to the stdout output above, but it is not happening. Is this the right way to achieve this or should I try another approach? Any advice, please?
Thanks!