Hi, I have been trying to setup a Binary Command Line Sensor, the end goal being to monitor the state of some webservers. I have been looking at some other threads and I saw that there was a bug with Openssl in previous versions, but it looks like that was resolved, and I know there are some issues with some grep
flags not supported in the HA container, but I don’t think those are related to my problem, my sensor wasn’t using grep.
I am running Docker and with the Home-Assistant container, version 0.99.1.
Here is my Binary Sensor, which so far remains on OFF, and I have verified that the url is up.
- platform: command_line
name: "Webserver"
command: 'response=$(curl -LIk "https://mysite.com" -o /dev/null -w ''%{http_code}\n'' -s); test "$response" -ge 200 && echo "ON" || echo "OFF"'
device_class: connectivity
payload_on: ON
payload_off: OFF
I have tested running the command manually from inside the container and did get an issue with the double single quote around $response
, which the documentation mentions for escaping single quotes in the string. It works without the double single quotes from inside the container, so I have tried it both ways in my configuration.yaml
I haven’t seen any errors in the log. I know there are some other monitoring options but I don’t want to make any changes on the webserver side, just want to be able to do some alerting based on the webserver return code.
Any thoughts on where I can look to find out more what is actually going on when it tries to run my curl command, or documentation would be great.
Thanks!