View Single Post
Posts: 426 | Thanked: 1,812 times | Joined on Dec 2013
#474
I created an alternative workaround for the sensor services running amok in the background and eating cpu thus battery life.
I was not so happy that I need to compile a python library for the proposed fix to test, so I took a look at the python script and wrote my own version of it in a more simpler way in bash script.

You can download it from here: https://www.dropbox.com/s/86wvsayyg5...ensors.sh?dl=0

You don't need python just execute the script and let it running.
You can also use the service for systemd and edit it to use this bash script instead of the python one. I also did that here: https://www.dropbox.com/s/xs7rkzcpdh...l.service?dl=0
(see the .service file check_sensors.sh needs to be put into /home/nemo if you don't want to change the location)

In fact the bash script is so small I can attach the 29 lines directly here. What it does should be self explanatory:
Code:
#!/bin/bash
 
# This checks every 1/2 minute and kills if
# sensors.qcom process is eating more than 8% CPU for 1 minute
 
TERM=linux
export TERM
 
kill_count=0
 
while true; do
sensors_pid=$(ps aux | grep sensors.qcom | grep -v grep | awk '{print $2}')
cpu_usage=$(top -b -p $sensors_pid -n1 | grep $sensors_pid | awk '{print $9}') 
echo $cpu_usage
echo "CPU Usage of sensors.qcom: ${cpu_usage/.*}"
if [[ ${cpu_usage/.*} -ge 8 ]]; then
        if [[ $kill_count -ge 1 ]]; then
                echo "CPU Usage of sensors.qcom too high restarting..."
                systemctl restart sensorfwd
                kill_count=0
        else
                echo "CPU Usage of sensors.qcom too high! Setting kill_count + 1"
                kill_count=$((kill_count+1))
        fi
else
        echo "Nothing to do"
fi
sleep 30
done
If anyone with an bugzilla account could forward this to the bugtracker it would be great. (I don't have an account there and registration is disabled)
__________________
Donation for my sailfish apps via PayPal

Donate using Liberapay
 

The Following 9 Users Say Thank You to llelectronics For This Useful Post: