Last weekend I had pilight hang and eat every resource to the point of a system stall. Not good when I’m not home and the automated lights don’t go off at night.
So I just wanted to be able to see the current CPU usage from a ‘ps’ output instead of logging in and running a quick top or ps since not being home requires me logging in to a few different servers before I can see what I need to see.
my sensor setup is fine and is not producing errors.
the command I’m trying to run is ‘ps -C pilight-daemon -o %cpu | tail -1’
Running it as either a python script or shell script both result in a command failed.
UPDATE: noticed today that command_line sensor only runs if hass is run from the command line and not as a service. Trying to figure out a fix now.
You did read the documentation, right?
If the command fails when you do this:
sensor:
- platform: command_line
name: Pilight CPU Usage
command: "ps -C pilight-daemon -o %cpu | tail -1"
Why not write a bash script in ~/bin called check_pilight_cpu:
#!/bin/bash
ps -C pilight-daemon -o %cpu | tail -1
and then execute ~/bin/check_pilight_cpu in the “command” section of the sensor?
sensor:
- platform: command_line
name: Pilight CPU Usage
command: "~/bin/check_pilight_cpu"
Be sure to chmod 755 ~/bin/check_pilight_cpu:
chmod 755 ~/bin/check_pilight_cpu
and restart Home Assistant.
I hope I can be of help. If it does not work, I’ll let others help you out.
Would this not be cleaner and easier?
sensor:
- platform: systemmonitor
resources:
- type: processor_use
yeah, but I want to see just pilight
Unfortunately using processor_use doesn’t display accurately it seems. I’m using that now and it shows 10% but in top pilight is showing 25%. If pilight starts creeping up I want to know.
Tried that before and still the same. I’ve tried running it from the sensor, as a bash script and as a python script and it all says command failed.