11 horas depois .. Está vivo!
O nascimento do Superscript CPU térmica ACPI.
eu nomeio, tempmon!
eu entendi tudo.
- Descobri como obter esse valor de temperatura ...
- E eu transformei minhas descobertas em um sobrescrito ...
tem sido uma imensa sessão de codificação apenas para este script ...
horas de depuração e testes, mas funciona como um sonho ...
embora não tenha acabado, alguns ajustes aqui e ali, mas
funciona e é contínuo!
- Verifica os temporários
- liga e desliga o ventilador da ACPI com base nas leituras do núcleo 0 temp,
e quando retorna a baixa temperatura ...
- re-executa automaticamente, dentro do mesmo processo!
- com tput e setaf, $ ($ tput $ setaf $ xwhite), é codificado por cores, mas você pode remover essas tags e mantê-las básicas.
Deve ser executado como SUDO / ROOT
Vou colocar todo o roteiro finalizado abaixo - Como ele incorpora tantos comandos, sem as coisas completas, ele não servirá a pergunta que eu coloquei há horas atrás, sem justiça, completamente respondendo e resolvendo minha própria pergunta sem CÓDIGO CHEIO!
Além disso, essa correção é, na verdade, uma correção séria de erros para os usuários da Comunidade HP para o laptop de negócios Compaq NX-6310! e outros - talvez, outros usuários deste tipo de Laptop, possam achar isto útil, e talvez outros com Similaridades Térmicas ACPI da ACPI não acionando o próprio Ventilador ACPI, no Linux Debian 9 ... e boom, superaquecimento = congelamento de laptop .
link
# HP COMPAQ NX6310 - Reported Issue over@http://forum.notebookreview.com/threads/acpi-issues-overheating-badly-due-to-fan-not-coming-on-hp-nx6325.113746/
#!/bin/bash
# TEMPMON - THE CPU/ACPI THERMAL MONITORING MECHANISM
#FOR THE COMPAQ NX6310 ACPI-CPU-THERMAL FAN ISSUE
#######################
# STACK EXCHANGE QUESTION: BY SHAUN SHORTY CASSIDY.
# https://unix.stackexchange.com/questions/418919/how-to-obtain-cat-cpu-core-temp-from-isa-adapter-debian/418935#418935
# How to obtain/cat CPU Core Temp from ISA Adapter? - Debian
# STATUS: SOLVED BY THIS SCRIPT.
######################
# Clear the Terminal
#-------------------------------------------------------------------------------------------------
clear
# Enter into script directory
cd /var/tempmon/
# Include Terminal Color Sheet.
. ./style/colors
## Using Sed from:
## https://stackoverflow.com/questions/16623835/remove-a-fixed-prefix-
suffix-from-a-string-in-bash
## CREATE PREFIX AND SUFFIX FOR STRING MANIPULATION.
tempSuffix=".0°C"
tempPrefix="+"
## SET UP GUI INTERFACE
echo "$($tput $setaf $xwhite)----------------------------------------------------"
echo "$($tput $setaf $xcyan) tempmon | The CPU/ACPI Thermal Monitoring Script!"
echo "$($tput $setaf $xred)----------------------------------------------------"
## GET THE CORE TEMPS AT SCRIPT STARTUP.
echo "$($tput $setaf $xwhite)Getting Core 0 temp from Sensors."
echo "$($tput $setaf $xwhite)Getting Core 1 temp from Sensors."
echo "$($tput $setaf $xmagenta)Getting ACPI Fan Status from Sensors."
sleep 0.1
#-------------------------------------------------------------------------------------------------
## READ THE SENSORS
Core0Temp=$(sensors | grep -i "Core 0:" | awk '{print $3}')
Core1Temp=$(sensors | grep -i "Core 1:" | awk '{print $3}')
## SETUP THE ACPI FAN SENSOR
# FAN SENSOR FILE
Fan0_File="/sys/class/thermal/cooling_device2/cur_state"
# FAN SENSOR STATUS
Fan0_Status=$(cat $Fan0_File)
# FAN MODULE ON
Fan0_On="1"
# FAN MODULE OFF
Fan0_Off="0"
#-------------------------------------------------------------------------------------------------
echo "$($tput $setaf $xred)----------------------------------------------------"
echo "$($tput $setaf $xcyan)Configuring Core 0 temp into Readable Format."
echo "$($tput $setaf $xwhite)Configuring Core 1 temp into Readable Format."
## CONFIGURE THE TEMPS FOR THE SCRIPTS USE.
sleep 0.1
Core0Temp1=$(echo "$Core0Temp" | sed -e "s/^$tempPrefix//" -e "s/$tempSuffix$//")
Core1Temp1=$(echo "$Core1Temp" | sed -e "s/^$tempPrefix//" -e "s/$tempSuffix$//")
echo "$($tput $setaf $xred)----------------------------------------------------"
echo "$($tput $setaf $xcyan)Starting CPU Monitor: Core Temp 0: "$Core0Temp1""$tempSuffix
echo "$($tput $setaf $xwhite)Starting CPU Monitor: Core Temp 1: "$Core1Temp1""$tempSuffix
## SET THE TEMP MARKER - STARTING TEMP
## SET THE TEMP START - THRESHOLD TEMP
#-------------------------------------------------------------------------------------------------
tempMarker="35"
tempIDLE=$(echo $tempMarker)
tempStart="35"
sleep 0.1
echo "$($tput $setaf $xred)----------------------------------------------------"
echo "$($tput $setaf $xwhite)Setting Initial Temp Marker @ "$tempMarker$tempSuffix
echo "$($tput $setaf $xwhite)Setting Initial Temp Threshold @ "$tempStart$tempSuffix
sleep 0.1
echo "$($tput $setaf $xred)----------------------------------------------------"
## IF CPU CORE 0 TEMP IS GREATER THAN IDLE TEMP OF 35;THEN RUN LOOP..
## (HAS TO BE LOW TO TRIGGER THE LOOP)
#------------------------------------------------------------------------------------------------- #
while true; do
if [ $Core0Temp1 -gt $tempMarker ]; then
## THEN NOTIFY TERMINAL THAT TEMP HAS EXCEEDED THRESHOLD TEMP
echo "$($tput $setaf $xyellow)###################################################"
echo "$($tput $setaf $xwhite) Exceeding Temp of: $($tput $setaf $xcyan)"$tempStart$tempSuffix
echo "$($tput $setaf $xyellow)###################################################"
## NOTIFY USER THAT MACHINE IS ENABLING THE ACPI FAN... (REQUIRES SUDO TO DO)
echo "$($tput $setaf $xred)======================================================="
echo "$($tput $setaf $xcyan)-------------- Checking the ACPI Fan."
echo "$($tput $setaf $xwhite)====================================================="
## THEN ENABLE THE FAN UNTIL;
## but before enabling the fan... we must check to see if it is already active...
## no point turning on a lightbulb when its already on...
if [ $Fan0_Status -eq $Fan0_On ]; then
echo "$($tput $setaf $xyellow)/////////////////////////////////////////////"
echo "$($tput $setaf $xwhite) ERROR! --- ACPI Fan 0: Already Enabled!"
echo "$($tput $setaf $xyellow)/////////////////////////////////////////////"
elif [ $Fan0_Status -eq $Fan0_Off ]; then
echo $Fan0_On > $Fan0_File
echo "$($tput $setaf $xyellow)/////////////////////////////////////////////"
echo "$($tput $setaf $xwhite) ACPI Fan 0: Enabling..."
echo "$($tput $setaf $xyellow)/////////////////////////////////////////////"
fi
echo "----------------------------------------------------"
## Until Loop: https://stackoverflow.com/questions/29692893/read-variable-until-output-is-greater-than-a-certain-value-in-bash
#-------------------------------------------------------------------------------------------------------------
until [ ${Core0Temp1} -lt $tempStart ]; do
sleep 1
## CORE 0 TEMP RETURNS TO LESS THAN THE THRESHOLD TEMP;
## RUN EVERY SECOND
## ON EVERY SECOND GET UPDATED TEMP VALUES
## AND ON EVERY SECOND GET THE ACPI FAN CURRENT STATUS (SUDO NEEDED!)
Fan0_Status=$(cat $Fan0_File)
if [ $Fan0_Status -eq $Fan0_On ]; then
sleep 1
echo "$($tput $setaf $xyellow)/////////////////////////////////////////////"
echo "$($tput $setaf $xwhite) ACPI_FAN0 IS ENABLED"
echo "$($tput $setaf $xyellow)/////////////////////////////////////////////"
elif [ $Fan0_Status -eq $Fan0_Off ]; then
sleep 1
echo "$($tput $setaf $xyellow)/////////////////////////////////////////////"
echo "$($tput $setaf $xwhite) ACPI_FAN0 IS DISABLED"
echo "$($tput $setaf $xyellow)/////////////////////////////////////////////"
fi
Core0Temp=$(sensors | grep -i "Core 0:" | awk '{print $3}')
Core0Temp1=$(echo "$Core0Temp" | sed -e "s/^$tempPrefix//" -e "s/$tempSuffix$//")
## DISPLAY THE UPDATED TEMP VALUES TO THE TERMINAL
echo "Core 0 Temp IS: "$Core0Temp1""$tempSuffix
## THEN ALSO EVERY SECOND, RUN A CHECK TO SEE IF THE TEMP
## HAS RETURNED TO LESS THAN THE THRESHOLD TEMP
if [ $Core0Temp1 -lt $tempStart ]; then
## IF THE TEMP HAS RETURNED TO LESS THAN THE THRESHOLD TEMP
## THEN DISABLE THE FAN AND NOTIFY TERMINAL
## but again, run a check to first see if it is active.
## you cant turn of a light thats already off right? ;)
## if active then disable. if not, then dont. cause its off.
if [ $Fan0_Status -eq $Fan0_Off ]; then
echo "$($tput $setaf $xyellow)/////////////////////////////////////////////"
echo "$($tput $setaf $xwhite)/ ERROR! /"
echo "$($tput $setaf $xyellow)/////////////////////////////////////////////"
echo "$($tput $setaf $xwhite)/ ACPI Fan 0: Already Disabled! /"
echo "$($tput $setaf $xyellow)/////////////////////////////////////////////"
elif [ $Fan0_Status -eq $Fan0_On ]; then
echo $Fan0_Off > $Fan0_File
echo "$($tput $setaf $xcyan)###################################################" #
echo "$($tput $setaf $xyellow)------------ACPI Fan 0: Disabled ./"
echo "$($tput $setaf $xcyan)###################################################" #
fi
echo "$($tput $setaf $xwhite)###################################################"
echo "$($tput $setaf $xcyan)--------- Core Temp Returned to: @"$tempStart""$tempSuffix
echo "$($tput $setaf $xwhite)###################################################"
fi
done
#-------------------------------------------------------------------------------------------------
#fi # this fi gets moved down under the return block.
#-------------------------------------------------------------------------------------------------
## So what do we do if the temp is less than the predefined temp?
## We repeat the until function but, in a reverse order.
## this is so that the script runs in a kind of (>---<>---<) see saw effect...
## back and fourth, to and fro right.
until [ ${Core0Temp1} -gt $tempStart ]; do
sleep 1
## CORE 0 TEMP RETURNS TO LESS THAN THE THRESHOLD TEMP;
## RUN EVERY SECOND
## ON EVERY SECOND GET UPDATED TEMP VALUES
## AND ON EVERY SECOND GET THE ACPI FAN CURRENT STATUS (SUDO NEEDED!)
Fan0_Status=$(cat $Fan0_File)
if [ $Fan0_Status -eq $Fan0_Off ]; then
sleep 1
echo "$($tput $setaf $xwhite)/////////////////////////////////////////////"
echo "$($tput $setaf $xwhite)--------------------ACPI_FAN0 IS DISABLED./"
echo "$($tput $setaf $xwhite)/////////////////////////////////////////////"
elif [ $Fan0_Status -eq $Fan0_On ]; then
sleep 1
echo "$($tput $setaf $xwhite)/////////////////////////////////////////////"
echo "$($tput $setaf $xwhite)--------------------ACPI_FAN0 IS ENABLED/./"
echo "$($tput $setaf $xwhite)/////////////////////////////////////////////"
fi
Core0Temp=$(sensors | grep -i "Core 0:" | awk '{print $3}')
Core0Temp1=$(echo "$Core0Temp" | sed -e "s/^$tempPrefix//" -e "s/$tempSuffix$//")
## DISPLAY THE UPDATED TEMP VALUES TO THE TERMINAL
echo "$($tput $setaf $xwhite)==============================================="
echo "$($tput $setaf $xwhite) Core 0 Temp IS: "$Core0Temp1""$tempSuffix
echo "$($tput $setaf $xwhite)==============================================="
## THEN ALSO EVERY SECOND, RUN A CHECK TO SEE IF THE TEMP
## HAS RETURNED TO LESS THAN THE THRESHOLD TEMP
if [ $Core0Temp1 -gt $tempStart ]; then
## IF THE TEMP HAS RETURNED TO greater THAN THE THRESHOLD TEMP
## THEN ENABLE THE FAN AND NOTIFY TERMINAL
## but again, run a check to first see if it is active.
## you cant turn ON a light thats already ON right? ;)
## if active then disable. if not, then dont. cause its off.
if [ $Fan0_Status -eq $Fan0_On ]; then
echo "$($tput $setaf $xyellow)/////////////////////////////////////////////"
echo "$($tput $setaf $xwhite) ERROR! /"
echo "$($tput $setaf $xyellow)/////////////////////////////////////////////"
echo "$($tput $setaf $xwhite) ACPI Fan 0: Already Enabled! /"
echo "$($tput $setaf $xyellow)/////////////////////////////////////////////"
elif [ $Fan0_Status -eq $Fan0_Off ]; then
echo $Fan0_On > $Fan0_File
echo "$($tput $setaf $xred)-------------------------------------------" #
echo "$($tput $setaf $xwhite)................ACPI Fan 0: Enabled.."
echo "$($tput $setaf $xred)-------------------------------------------" #
fi
echo "$($tput $setaf $xred)###################################################"
echo "$($tput $setaf $xwhite)............Core Temp dropping below: @"$tempStart""$tempSuffix
echo "$($tput $setaf $xred)###################################################"
echo "$($tput $reset)"
fi
done
#-------------------------------------------------------------------------------------------------
fi
done
#END OF SUPERSCRIPT.