Make CLI monitoring less 'expensive'

We try to **not** influence OS behaviour so let's try to renice our monitoring function from 0 to 19 and also minimize fs stats.
This commit is contained in:
Thomas Kaiser 2017-12-15 11:44:21 +01:00 committed by GitHub
parent d93ad66f39
commit de0df7fbe8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -275,6 +275,9 @@ MonitorMode() {
# Allow armbianmonitor to return back to armbian-config
trap "echo ; exit 0" 0 1 2 3 15
# Try to renice to 19 to not interfere with OS behaviour
renice 19 $BASHPID >/dev/null 2>&1
LastUserStat=0
LastNiceStat=0
@ -303,7 +306,8 @@ MonitorMode() {
[ -f "${Sensors}/pmictemp" ] && DisplayHeader="${DisplayHeader} PMIC" || PMICTemp='n/a'
DCIN=$(CheckDCINVoltage)
[ -f "${DCIN}" ] && DisplayHeader="${DisplayHeader} DC-IN" || DCIN='n/a'
[ -f /sys/devices/virtual/thermal/cooling_device0/cur_state ] && DisplayHeader="${DisplayHeader} C.St."
[ -f /sys/devices/virtual/thermal/cooling_device0/cur_state ] \
&& DisplayHeader="${DisplayHeader} C.St." || CoolingState='n/a'
echo -e "Stop monitoring using [ctrl]-[c]"
[ $(echo "${SleepInterval} * 10" | bc | cut -d. -f1) -le 15 2>/dev/null ] \
&& echo "Warning: High update frequency (${SleepInterval} sec) might change system behaviour!"
@ -359,7 +363,7 @@ MonitorMode() {
fi
[ "X${DCIN}" != "Xn/a" ] && \
(DCINvoltage=$(awk '{printf ("%0.2f",$1/1000000); }' <"${DCIN}") ; echo -e " $(printf "%5s" ${DCINvoltage})V\c")
[ -f /sys/devices/virtual/thermal/cooling_device0/cur_state ] && printf " %d/%d" $(cat /sys/devices/virtual/thermal/cooling_device0/cur_state) $(cat /sys/devices/virtual/thermal/cooling_device0/max_state)
[ "X${CoolingState}" != "Xn/a" ] && printf " %d/%d" $(cat /sys/devices/virtual/thermal/cooling_device0/cur_state) $(cat /sys/devices/virtual/thermal/cooling_device0/max_state)
[ "$c" == "s" ] && sleep 0.3 || sleep ${SleepInterval}
done
} # MonitorMode