How to obtain/cat CPU Core Temp from ISA Adapter?
I'm building a script in Linux to monitor my active core temps;
Then manually enable the ACPI Fan on the event when the CORE 0 TEMP hits 40 Degrees.
I have already built the fan script that works on demand by hitting a command into the bash terminal for simplicity it is called fanon.
However I want to know how to CAT this CORE 0 temp output to a variable in a bash script called gettemp, that updates on an interval say every 2 seconds.
By using watch sensors I get the following output in the terminal.
acpitz-virtual-0
Adapter: Virtual device
temp1: +45.0°C (crit = +256.0°C)
temp2: +36.0°C (crit = +105.0°C)
temp3: +32.0°C (crit = +105.0°C)
temp4: +24.1°C (crit = +105.0°C)
temp5: +100.0°C (crit = +110.0°C)
coretemp-isa-0000
Adapter: ISA adapter
Core 0: +41.0°C (crit = +100.0°C) <--- This is the temp I need!
Core 1: +38.0°C (crit = +100.0°C)
Core 0 Temp needs to be found in a way so that I can do the following:
Core0Temp=$(cat /PATH/TO/ISA/TEMP/GOES/HERE)
Core1Temp=$(cat /PATH/TO/ISA/TEMP2/GOES/HERE)
And then from that I can do
if [ $Core0Temp -gt "40" ]; then
echo "Exceeding Temp Value. Enabling Fan."
/var/tempmon/fanon
elif [ $Core0Temp -lt "40" ]; then
echo "Turning Fan Off."
/var/tempmon/fanoff
fi
and if anyone is wondering why I need to create my own thermal mechanism, it is simply because, I am using a Compaq NX-6310 Business Laptop.
It has poor (manufacturers) ability handling of ACPI Thermal Events and its connection to the ACPI Fan, is diabolical. Many searches on Google have only showed me how to manually enable the cooling system. As shown below.
echo "Enabling ACPI FAN... "
echo 1 > /sys/class/thermal/cooling_device2/cur_state
echo "Fan Enabled... "
To disable the fan, the following is executed by sudo.
echo "Disabling ACPI FAN..."
echo 0 > /sys/class/thermal/cooling_device2/cur_state
echo "Fan Disabled..."
So I need to build this script to enable the thermal chip to report the temp, and enable the fan accordingly, like you would expect on any bog standard laptop. I just can't find where the actual core temps are located. Watch sensors can find them but I can't.
bash debian cpu acpi
add a comment |
I'm building a script in Linux to monitor my active core temps;
Then manually enable the ACPI Fan on the event when the CORE 0 TEMP hits 40 Degrees.
I have already built the fan script that works on demand by hitting a command into the bash terminal for simplicity it is called fanon.
However I want to know how to CAT this CORE 0 temp output to a variable in a bash script called gettemp, that updates on an interval say every 2 seconds.
By using watch sensors I get the following output in the terminal.
acpitz-virtual-0
Adapter: Virtual device
temp1: +45.0°C (crit = +256.0°C)
temp2: +36.0°C (crit = +105.0°C)
temp3: +32.0°C (crit = +105.0°C)
temp4: +24.1°C (crit = +105.0°C)
temp5: +100.0°C (crit = +110.0°C)
coretemp-isa-0000
Adapter: ISA adapter
Core 0: +41.0°C (crit = +100.0°C) <--- This is the temp I need!
Core 1: +38.0°C (crit = +100.0°C)
Core 0 Temp needs to be found in a way so that I can do the following:
Core0Temp=$(cat /PATH/TO/ISA/TEMP/GOES/HERE)
Core1Temp=$(cat /PATH/TO/ISA/TEMP2/GOES/HERE)
And then from that I can do
if [ $Core0Temp -gt "40" ]; then
echo "Exceeding Temp Value. Enabling Fan."
/var/tempmon/fanon
elif [ $Core0Temp -lt "40" ]; then
echo "Turning Fan Off."
/var/tempmon/fanoff
fi
and if anyone is wondering why I need to create my own thermal mechanism, it is simply because, I am using a Compaq NX-6310 Business Laptop.
It has poor (manufacturers) ability handling of ACPI Thermal Events and its connection to the ACPI Fan, is diabolical. Many searches on Google have only showed me how to manually enable the cooling system. As shown below.
echo "Enabling ACPI FAN... "
echo 1 > /sys/class/thermal/cooling_device2/cur_state
echo "Fan Enabled... "
To disable the fan, the following is executed by sudo.
echo "Disabling ACPI FAN..."
echo 0 > /sys/class/thermal/cooling_device2/cur_state
echo "Fan Disabled..."
So I need to build this script to enable the thermal chip to report the temp, and enable the fan accordingly, like you would expect on any bog standard laptop. I just can't find where the actual core temps are located. Watch sensors can find them but I can't.
bash debian cpu acpi
add a comment |
I'm building a script in Linux to monitor my active core temps;
Then manually enable the ACPI Fan on the event when the CORE 0 TEMP hits 40 Degrees.
I have already built the fan script that works on demand by hitting a command into the bash terminal for simplicity it is called fanon.
However I want to know how to CAT this CORE 0 temp output to a variable in a bash script called gettemp, that updates on an interval say every 2 seconds.
By using watch sensors I get the following output in the terminal.
acpitz-virtual-0
Adapter: Virtual device
temp1: +45.0°C (crit = +256.0°C)
temp2: +36.0°C (crit = +105.0°C)
temp3: +32.0°C (crit = +105.0°C)
temp4: +24.1°C (crit = +105.0°C)
temp5: +100.0°C (crit = +110.0°C)
coretemp-isa-0000
Adapter: ISA adapter
Core 0: +41.0°C (crit = +100.0°C) <--- This is the temp I need!
Core 1: +38.0°C (crit = +100.0°C)
Core 0 Temp needs to be found in a way so that I can do the following:
Core0Temp=$(cat /PATH/TO/ISA/TEMP/GOES/HERE)
Core1Temp=$(cat /PATH/TO/ISA/TEMP2/GOES/HERE)
And then from that I can do
if [ $Core0Temp -gt "40" ]; then
echo "Exceeding Temp Value. Enabling Fan."
/var/tempmon/fanon
elif [ $Core0Temp -lt "40" ]; then
echo "Turning Fan Off."
/var/tempmon/fanoff
fi
and if anyone is wondering why I need to create my own thermal mechanism, it is simply because, I am using a Compaq NX-6310 Business Laptop.
It has poor (manufacturers) ability handling of ACPI Thermal Events and its connection to the ACPI Fan, is diabolical. Many searches on Google have only showed me how to manually enable the cooling system. As shown below.
echo "Enabling ACPI FAN... "
echo 1 > /sys/class/thermal/cooling_device2/cur_state
echo "Fan Enabled... "
To disable the fan, the following is executed by sudo.
echo "Disabling ACPI FAN..."
echo 0 > /sys/class/thermal/cooling_device2/cur_state
echo "Fan Disabled..."
So I need to build this script to enable the thermal chip to report the temp, and enable the fan accordingly, like you would expect on any bog standard laptop. I just can't find where the actual core temps are located. Watch sensors can find them but I can't.
bash debian cpu acpi
I'm building a script in Linux to monitor my active core temps;
Then manually enable the ACPI Fan on the event when the CORE 0 TEMP hits 40 Degrees.
I have already built the fan script that works on demand by hitting a command into the bash terminal for simplicity it is called fanon.
However I want to know how to CAT this CORE 0 temp output to a variable in a bash script called gettemp, that updates on an interval say every 2 seconds.
By using watch sensors I get the following output in the terminal.
acpitz-virtual-0
Adapter: Virtual device
temp1: +45.0°C (crit = +256.0°C)
temp2: +36.0°C (crit = +105.0°C)
temp3: +32.0°C (crit = +105.0°C)
temp4: +24.1°C (crit = +105.0°C)
temp5: +100.0°C (crit = +110.0°C)
coretemp-isa-0000
Adapter: ISA adapter
Core 0: +41.0°C (crit = +100.0°C) <--- This is the temp I need!
Core 1: +38.0°C (crit = +100.0°C)
Core 0 Temp needs to be found in a way so that I can do the following:
Core0Temp=$(cat /PATH/TO/ISA/TEMP/GOES/HERE)
Core1Temp=$(cat /PATH/TO/ISA/TEMP2/GOES/HERE)
And then from that I can do
if [ $Core0Temp -gt "40" ]; then
echo "Exceeding Temp Value. Enabling Fan."
/var/tempmon/fanon
elif [ $Core0Temp -lt "40" ]; then
echo "Turning Fan Off."
/var/tempmon/fanoff
fi
and if anyone is wondering why I need to create my own thermal mechanism, it is simply because, I am using a Compaq NX-6310 Business Laptop.
It has poor (manufacturers) ability handling of ACPI Thermal Events and its connection to the ACPI Fan, is diabolical. Many searches on Google have only showed me how to manually enable the cooling system. As shown below.
echo "Enabling ACPI FAN... "
echo 1 > /sys/class/thermal/cooling_device2/cur_state
echo "Fan Enabled... "
To disable the fan, the following is executed by sudo.
echo "Disabling ACPI FAN..."
echo 0 > /sys/class/thermal/cooling_device2/cur_state
echo "Fan Disabled..."
So I need to build this script to enable the thermal chip to report the temp, and enable the fan accordingly, like you would expect on any bog standard laptop. I just can't find where the actual core temps are located. Watch sensors can find them but I can't.
bash debian cpu acpi
bash debian cpu acpi
edited 57 mins ago
user90255
1543312
1543312
asked Jan 22 '18 at 18:19
MasterCassidyMasterCassidy
64
64
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
The ACPI temperatures are under /sys/class/thermal
, yes, but the lm_sensors
hardware monitoring sensors are under /sys/class/hwmon/
.
On my system, there are three sub-directories under /sys/class/hwmon/
: there are hwmon0
, hwmon1
and hwmon2
. In my case, the coretemp
module happens to be hwmon1
: on your system this may be different. You can identify each sub-directory simply by doing cat /sys/class/hwmon/hwmonN/name
, where N is the number.
The coretemp
temperature values are on my system at /sys/class/hwmon/hwmon1/temp2_input
and /sys/class/hwmon/hwmon1/temp3_input
. The numbers on those tempN_input
filenames may also be different for you, depending on the exact CPU model. The values will be integer numbers of thousandths of degrees Celsius, i.e. 41000 will be 41.0 degrees Celsius.
I like this. very technical. a very interesting response.
– MasterCassidy
Jan 22 '18 at 22:28
add a comment |
If you have sysfs mounted, which you should by default, you can find the temp readout in /sys/class/thermal/thermal_zoneX/temp
.
On my machine the following did the trick
$ cat /sys/class/thermal/thermal_zone0/temp
27800
$ cat /sys/class/thermal/thermal_zone1/temp
29800
$ sensors
acpitz-virtual-0
Adapter: Virtual device
temp1: +27.8°C (crit = +105.0°C)
temp2: +29.8°C (crit = +105.0°C)
So would you say that temp1 is = to core 0 temp and temp2 is = to core 1 temp? as i am specifically after obtaining the ISA Temp Values, the ones reported from : coretemp-isa-0000 and not the temps from : acpitz-virtual-0 as these appear to be different temps from different devices (for added clarity is why i ask)
– MasterCassidy
Jan 22 '18 at 19:50
as when i run the command sensors temp 1 is reporting on idle +45 whilst core 0 is reporting +37. ahhhhh 'epiphany' i think i have figured it out...! i think i may be able to pipe this through | grep and then use awk... to grab the data needed... and then just simply figure out a way to loop it on a continuous cycle to grab the same data every 2 seconds or so. and then it can run its check, on the temps of the cores, based on the integer values retrieved, and then once it hits its variable check, start and stop the ACPI fan based on that integer value recieved from the pipe - i shall try this.
– MasterCassidy
Jan 22 '18 at 20:00
But these are ACPI thermal zones, and not what lm-sensors reports incoretemp-isa-0000
... which I think is not available in/sys
or/proc
.
– dirkt
Jan 22 '18 at 21:23
add a comment |
11 Hours Later.. It is alive!
--
The Birth of the ACPI Thermal CPU Superscript.
i name it, tempmon!
i figured it all out.
- I figured out how to get that Temp Value...
- And i turned my findings into a superscript...
it has been an immense coding session just for this script...
hours debugging and testing, but it works like a dream...
although not quite finished, a few tweaks here and there but,
it works, and it is continuous!
- It checks the temps,
- turns the ACPI fan on and off based on the readings of the core 0 temp,
and when it returns to low temp...
- it automatically re-runs itself, within the same process!
- with tput and setaf, $($tput $setaf $xwhite), its color coded, but you can remove those tags and keep it basic.
It must be run as SUDO/ROOT
I will place the whole finished script below - As it incorporates so many commands, without the full things, it wont serve the question i posed hours ago justice, without fully, and completely answering and solving my own question without FULL CODE!
Also as this fix is actually a serious bug-fix for those within the HP Community for the Compaq NX-6310 Business Laptop! and others - perhaps, other users of this type of Laptop, may find this useful, and perhaps others with likewise ACPI Thermal Issues from the ACPI not triggering the ACPI Fan itself, in Linux Debian 9... and boom, overheating = laptop freezes.
http://forum.notebookreview.com/threads/acpi-issues-overheating-badly-due-to-fan-not-coming-on-hp-nx6325.113746/
# 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.
You might findfancontrol
useful — install it, then runsudo pwmconfig
.
– Stephen Kitt
Jan 23 '18 at 10:54
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f418919%2fhow-to-obtain-cat-cpu-core-temp-from-isa-adapter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
The ACPI temperatures are under /sys/class/thermal
, yes, but the lm_sensors
hardware monitoring sensors are under /sys/class/hwmon/
.
On my system, there are three sub-directories under /sys/class/hwmon/
: there are hwmon0
, hwmon1
and hwmon2
. In my case, the coretemp
module happens to be hwmon1
: on your system this may be different. You can identify each sub-directory simply by doing cat /sys/class/hwmon/hwmonN/name
, where N is the number.
The coretemp
temperature values are on my system at /sys/class/hwmon/hwmon1/temp2_input
and /sys/class/hwmon/hwmon1/temp3_input
. The numbers on those tempN_input
filenames may also be different for you, depending on the exact CPU model. The values will be integer numbers of thousandths of degrees Celsius, i.e. 41000 will be 41.0 degrees Celsius.
I like this. very technical. a very interesting response.
– MasterCassidy
Jan 22 '18 at 22:28
add a comment |
The ACPI temperatures are under /sys/class/thermal
, yes, but the lm_sensors
hardware monitoring sensors are under /sys/class/hwmon/
.
On my system, there are three sub-directories under /sys/class/hwmon/
: there are hwmon0
, hwmon1
and hwmon2
. In my case, the coretemp
module happens to be hwmon1
: on your system this may be different. You can identify each sub-directory simply by doing cat /sys/class/hwmon/hwmonN/name
, where N is the number.
The coretemp
temperature values are on my system at /sys/class/hwmon/hwmon1/temp2_input
and /sys/class/hwmon/hwmon1/temp3_input
. The numbers on those tempN_input
filenames may also be different for you, depending on the exact CPU model. The values will be integer numbers of thousandths of degrees Celsius, i.e. 41000 will be 41.0 degrees Celsius.
I like this. very technical. a very interesting response.
– MasterCassidy
Jan 22 '18 at 22:28
add a comment |
The ACPI temperatures are under /sys/class/thermal
, yes, but the lm_sensors
hardware monitoring sensors are under /sys/class/hwmon/
.
On my system, there are three sub-directories under /sys/class/hwmon/
: there are hwmon0
, hwmon1
and hwmon2
. In my case, the coretemp
module happens to be hwmon1
: on your system this may be different. You can identify each sub-directory simply by doing cat /sys/class/hwmon/hwmonN/name
, where N is the number.
The coretemp
temperature values are on my system at /sys/class/hwmon/hwmon1/temp2_input
and /sys/class/hwmon/hwmon1/temp3_input
. The numbers on those tempN_input
filenames may also be different for you, depending on the exact CPU model. The values will be integer numbers of thousandths of degrees Celsius, i.e. 41000 will be 41.0 degrees Celsius.
The ACPI temperatures are under /sys/class/thermal
, yes, but the lm_sensors
hardware monitoring sensors are under /sys/class/hwmon/
.
On my system, there are three sub-directories under /sys/class/hwmon/
: there are hwmon0
, hwmon1
and hwmon2
. In my case, the coretemp
module happens to be hwmon1
: on your system this may be different. You can identify each sub-directory simply by doing cat /sys/class/hwmon/hwmonN/name
, where N is the number.
The coretemp
temperature values are on my system at /sys/class/hwmon/hwmon1/temp2_input
and /sys/class/hwmon/hwmon1/temp3_input
. The numbers on those tempN_input
filenames may also be different for you, depending on the exact CPU model. The values will be integer numbers of thousandths of degrees Celsius, i.e. 41000 will be 41.0 degrees Celsius.
answered Jan 22 '18 at 22:10
telcoMtelcoM
19.3k12448
19.3k12448
I like this. very technical. a very interesting response.
– MasterCassidy
Jan 22 '18 at 22:28
add a comment |
I like this. very technical. a very interesting response.
– MasterCassidy
Jan 22 '18 at 22:28
I like this. very technical. a very interesting response.
– MasterCassidy
Jan 22 '18 at 22:28
I like this. very technical. a very interesting response.
– MasterCassidy
Jan 22 '18 at 22:28
add a comment |
If you have sysfs mounted, which you should by default, you can find the temp readout in /sys/class/thermal/thermal_zoneX/temp
.
On my machine the following did the trick
$ cat /sys/class/thermal/thermal_zone0/temp
27800
$ cat /sys/class/thermal/thermal_zone1/temp
29800
$ sensors
acpitz-virtual-0
Adapter: Virtual device
temp1: +27.8°C (crit = +105.0°C)
temp2: +29.8°C (crit = +105.0°C)
So would you say that temp1 is = to core 0 temp and temp2 is = to core 1 temp? as i am specifically after obtaining the ISA Temp Values, the ones reported from : coretemp-isa-0000 and not the temps from : acpitz-virtual-0 as these appear to be different temps from different devices (for added clarity is why i ask)
– MasterCassidy
Jan 22 '18 at 19:50
as when i run the command sensors temp 1 is reporting on idle +45 whilst core 0 is reporting +37. ahhhhh 'epiphany' i think i have figured it out...! i think i may be able to pipe this through | grep and then use awk... to grab the data needed... and then just simply figure out a way to loop it on a continuous cycle to grab the same data every 2 seconds or so. and then it can run its check, on the temps of the cores, based on the integer values retrieved, and then once it hits its variable check, start and stop the ACPI fan based on that integer value recieved from the pipe - i shall try this.
– MasterCassidy
Jan 22 '18 at 20:00
But these are ACPI thermal zones, and not what lm-sensors reports incoretemp-isa-0000
... which I think is not available in/sys
or/proc
.
– dirkt
Jan 22 '18 at 21:23
add a comment |
If you have sysfs mounted, which you should by default, you can find the temp readout in /sys/class/thermal/thermal_zoneX/temp
.
On my machine the following did the trick
$ cat /sys/class/thermal/thermal_zone0/temp
27800
$ cat /sys/class/thermal/thermal_zone1/temp
29800
$ sensors
acpitz-virtual-0
Adapter: Virtual device
temp1: +27.8°C (crit = +105.0°C)
temp2: +29.8°C (crit = +105.0°C)
So would you say that temp1 is = to core 0 temp and temp2 is = to core 1 temp? as i am specifically after obtaining the ISA Temp Values, the ones reported from : coretemp-isa-0000 and not the temps from : acpitz-virtual-0 as these appear to be different temps from different devices (for added clarity is why i ask)
– MasterCassidy
Jan 22 '18 at 19:50
as when i run the command sensors temp 1 is reporting on idle +45 whilst core 0 is reporting +37. ahhhhh 'epiphany' i think i have figured it out...! i think i may be able to pipe this through | grep and then use awk... to grab the data needed... and then just simply figure out a way to loop it on a continuous cycle to grab the same data every 2 seconds or so. and then it can run its check, on the temps of the cores, based on the integer values retrieved, and then once it hits its variable check, start and stop the ACPI fan based on that integer value recieved from the pipe - i shall try this.
– MasterCassidy
Jan 22 '18 at 20:00
But these are ACPI thermal zones, and not what lm-sensors reports incoretemp-isa-0000
... which I think is not available in/sys
or/proc
.
– dirkt
Jan 22 '18 at 21:23
add a comment |
If you have sysfs mounted, which you should by default, you can find the temp readout in /sys/class/thermal/thermal_zoneX/temp
.
On my machine the following did the trick
$ cat /sys/class/thermal/thermal_zone0/temp
27800
$ cat /sys/class/thermal/thermal_zone1/temp
29800
$ sensors
acpitz-virtual-0
Adapter: Virtual device
temp1: +27.8°C (crit = +105.0°C)
temp2: +29.8°C (crit = +105.0°C)
If you have sysfs mounted, which you should by default, you can find the temp readout in /sys/class/thermal/thermal_zoneX/temp
.
On my machine the following did the trick
$ cat /sys/class/thermal/thermal_zone0/temp
27800
$ cat /sys/class/thermal/thermal_zone1/temp
29800
$ sensors
acpitz-virtual-0
Adapter: Virtual device
temp1: +27.8°C (crit = +105.0°C)
temp2: +29.8°C (crit = +105.0°C)
answered Jan 22 '18 at 19:45
imbuedHopeimbuedHope
1968
1968
So would you say that temp1 is = to core 0 temp and temp2 is = to core 1 temp? as i am specifically after obtaining the ISA Temp Values, the ones reported from : coretemp-isa-0000 and not the temps from : acpitz-virtual-0 as these appear to be different temps from different devices (for added clarity is why i ask)
– MasterCassidy
Jan 22 '18 at 19:50
as when i run the command sensors temp 1 is reporting on idle +45 whilst core 0 is reporting +37. ahhhhh 'epiphany' i think i have figured it out...! i think i may be able to pipe this through | grep and then use awk... to grab the data needed... and then just simply figure out a way to loop it on a continuous cycle to grab the same data every 2 seconds or so. and then it can run its check, on the temps of the cores, based on the integer values retrieved, and then once it hits its variable check, start and stop the ACPI fan based on that integer value recieved from the pipe - i shall try this.
– MasterCassidy
Jan 22 '18 at 20:00
But these are ACPI thermal zones, and not what lm-sensors reports incoretemp-isa-0000
... which I think is not available in/sys
or/proc
.
– dirkt
Jan 22 '18 at 21:23
add a comment |
So would you say that temp1 is = to core 0 temp and temp2 is = to core 1 temp? as i am specifically after obtaining the ISA Temp Values, the ones reported from : coretemp-isa-0000 and not the temps from : acpitz-virtual-0 as these appear to be different temps from different devices (for added clarity is why i ask)
– MasterCassidy
Jan 22 '18 at 19:50
as when i run the command sensors temp 1 is reporting on idle +45 whilst core 0 is reporting +37. ahhhhh 'epiphany' i think i have figured it out...! i think i may be able to pipe this through | grep and then use awk... to grab the data needed... and then just simply figure out a way to loop it on a continuous cycle to grab the same data every 2 seconds or so. and then it can run its check, on the temps of the cores, based on the integer values retrieved, and then once it hits its variable check, start and stop the ACPI fan based on that integer value recieved from the pipe - i shall try this.
– MasterCassidy
Jan 22 '18 at 20:00
But these are ACPI thermal zones, and not what lm-sensors reports incoretemp-isa-0000
... which I think is not available in/sys
or/proc
.
– dirkt
Jan 22 '18 at 21:23
So would you say that temp1 is = to core 0 temp and temp2 is = to core 1 temp? as i am specifically after obtaining the ISA Temp Values, the ones reported from : coretemp-isa-0000 and not the temps from : acpitz-virtual-0 as these appear to be different temps from different devices (for added clarity is why i ask)
– MasterCassidy
Jan 22 '18 at 19:50
So would you say that temp1 is = to core 0 temp and temp2 is = to core 1 temp? as i am specifically after obtaining the ISA Temp Values, the ones reported from : coretemp-isa-0000 and not the temps from : acpitz-virtual-0 as these appear to be different temps from different devices (for added clarity is why i ask)
– MasterCassidy
Jan 22 '18 at 19:50
as when i run the command sensors temp 1 is reporting on idle +45 whilst core 0 is reporting +37. ahhhhh 'epiphany' i think i have figured it out...! i think i may be able to pipe this through | grep and then use awk... to grab the data needed... and then just simply figure out a way to loop it on a continuous cycle to grab the same data every 2 seconds or so. and then it can run its check, on the temps of the cores, based on the integer values retrieved, and then once it hits its variable check, start and stop the ACPI fan based on that integer value recieved from the pipe - i shall try this.
– MasterCassidy
Jan 22 '18 at 20:00
as when i run the command sensors temp 1 is reporting on idle +45 whilst core 0 is reporting +37. ahhhhh 'epiphany' i think i have figured it out...! i think i may be able to pipe this through | grep and then use awk... to grab the data needed... and then just simply figure out a way to loop it on a continuous cycle to grab the same data every 2 seconds or so. and then it can run its check, on the temps of the cores, based on the integer values retrieved, and then once it hits its variable check, start and stop the ACPI fan based on that integer value recieved from the pipe - i shall try this.
– MasterCassidy
Jan 22 '18 at 20:00
But these are ACPI thermal zones, and not what lm-sensors reports in
coretemp-isa-0000
... which I think is not available in /sys
or /proc
.– dirkt
Jan 22 '18 at 21:23
But these are ACPI thermal zones, and not what lm-sensors reports in
coretemp-isa-0000
... which I think is not available in /sys
or /proc
.– dirkt
Jan 22 '18 at 21:23
add a comment |
11 Hours Later.. It is alive!
--
The Birth of the ACPI Thermal CPU Superscript.
i name it, tempmon!
i figured it all out.
- I figured out how to get that Temp Value...
- And i turned my findings into a superscript...
it has been an immense coding session just for this script...
hours debugging and testing, but it works like a dream...
although not quite finished, a few tweaks here and there but,
it works, and it is continuous!
- It checks the temps,
- turns the ACPI fan on and off based on the readings of the core 0 temp,
and when it returns to low temp...
- it automatically re-runs itself, within the same process!
- with tput and setaf, $($tput $setaf $xwhite), its color coded, but you can remove those tags and keep it basic.
It must be run as SUDO/ROOT
I will place the whole finished script below - As it incorporates so many commands, without the full things, it wont serve the question i posed hours ago justice, without fully, and completely answering and solving my own question without FULL CODE!
Also as this fix is actually a serious bug-fix for those within the HP Community for the Compaq NX-6310 Business Laptop! and others - perhaps, other users of this type of Laptop, may find this useful, and perhaps others with likewise ACPI Thermal Issues from the ACPI not triggering the ACPI Fan itself, in Linux Debian 9... and boom, overheating = laptop freezes.
http://forum.notebookreview.com/threads/acpi-issues-overheating-badly-due-to-fan-not-coming-on-hp-nx6325.113746/
# 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.
You might findfancontrol
useful — install it, then runsudo pwmconfig
.
– Stephen Kitt
Jan 23 '18 at 10:54
add a comment |
11 Hours Later.. It is alive!
--
The Birth of the ACPI Thermal CPU Superscript.
i name it, tempmon!
i figured it all out.
- I figured out how to get that Temp Value...
- And i turned my findings into a superscript...
it has been an immense coding session just for this script...
hours debugging and testing, but it works like a dream...
although not quite finished, a few tweaks here and there but,
it works, and it is continuous!
- It checks the temps,
- turns the ACPI fan on and off based on the readings of the core 0 temp,
and when it returns to low temp...
- it automatically re-runs itself, within the same process!
- with tput and setaf, $($tput $setaf $xwhite), its color coded, but you can remove those tags and keep it basic.
It must be run as SUDO/ROOT
I will place the whole finished script below - As it incorporates so many commands, without the full things, it wont serve the question i posed hours ago justice, without fully, and completely answering and solving my own question without FULL CODE!
Also as this fix is actually a serious bug-fix for those within the HP Community for the Compaq NX-6310 Business Laptop! and others - perhaps, other users of this type of Laptop, may find this useful, and perhaps others with likewise ACPI Thermal Issues from the ACPI not triggering the ACPI Fan itself, in Linux Debian 9... and boom, overheating = laptop freezes.
http://forum.notebookreview.com/threads/acpi-issues-overheating-badly-due-to-fan-not-coming-on-hp-nx6325.113746/
# 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.
You might findfancontrol
useful — install it, then runsudo pwmconfig
.
– Stephen Kitt
Jan 23 '18 at 10:54
add a comment |
11 Hours Later.. It is alive!
--
The Birth of the ACPI Thermal CPU Superscript.
i name it, tempmon!
i figured it all out.
- I figured out how to get that Temp Value...
- And i turned my findings into a superscript...
it has been an immense coding session just for this script...
hours debugging and testing, but it works like a dream...
although not quite finished, a few tweaks here and there but,
it works, and it is continuous!
- It checks the temps,
- turns the ACPI fan on and off based on the readings of the core 0 temp,
and when it returns to low temp...
- it automatically re-runs itself, within the same process!
- with tput and setaf, $($tput $setaf $xwhite), its color coded, but you can remove those tags and keep it basic.
It must be run as SUDO/ROOT
I will place the whole finished script below - As it incorporates so many commands, without the full things, it wont serve the question i posed hours ago justice, without fully, and completely answering and solving my own question without FULL CODE!
Also as this fix is actually a serious bug-fix for those within the HP Community for the Compaq NX-6310 Business Laptop! and others - perhaps, other users of this type of Laptop, may find this useful, and perhaps others with likewise ACPI Thermal Issues from the ACPI not triggering the ACPI Fan itself, in Linux Debian 9... and boom, overheating = laptop freezes.
http://forum.notebookreview.com/threads/acpi-issues-overheating-badly-due-to-fan-not-coming-on-hp-nx6325.113746/
# 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.
11 Hours Later.. It is alive!
--
The Birth of the ACPI Thermal CPU Superscript.
i name it, tempmon!
i figured it all out.
- I figured out how to get that Temp Value...
- And i turned my findings into a superscript...
it has been an immense coding session just for this script...
hours debugging and testing, but it works like a dream...
although not quite finished, a few tweaks here and there but,
it works, and it is continuous!
- It checks the temps,
- turns the ACPI fan on and off based on the readings of the core 0 temp,
and when it returns to low temp...
- it automatically re-runs itself, within the same process!
- with tput and setaf, $($tput $setaf $xwhite), its color coded, but you can remove those tags and keep it basic.
It must be run as SUDO/ROOT
I will place the whole finished script below - As it incorporates so many commands, without the full things, it wont serve the question i posed hours ago justice, without fully, and completely answering and solving my own question without FULL CODE!
Also as this fix is actually a serious bug-fix for those within the HP Community for the Compaq NX-6310 Business Laptop! and others - perhaps, other users of this type of Laptop, may find this useful, and perhaps others with likewise ACPI Thermal Issues from the ACPI not triggering the ACPI Fan itself, in Linux Debian 9... and boom, overheating = laptop freezes.
http://forum.notebookreview.com/threads/acpi-issues-overheating-badly-due-to-fan-not-coming-on-hp-nx6325.113746/
# 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.
edited Jan 23 '18 at 6:51
answered Jan 23 '18 at 6:42
MasterCassidyMasterCassidy
64
64
You might findfancontrol
useful — install it, then runsudo pwmconfig
.
– Stephen Kitt
Jan 23 '18 at 10:54
add a comment |
You might findfancontrol
useful — install it, then runsudo pwmconfig
.
– Stephen Kitt
Jan 23 '18 at 10:54
You might find
fancontrol
useful — install it, then run sudo pwmconfig
.– Stephen Kitt
Jan 23 '18 at 10:54
You might find
fancontrol
useful — install it, then run sudo pwmconfig
.– Stephen Kitt
Jan 23 '18 at 10:54
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f418919%2fhow-to-obtain-cat-cpu-core-temp-from-isa-adapter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown