psensors
psensors
Debugging left in here for debugging purposes
Making scripts lm sensor treshholds
So i use lm sensor to watch my memory dimms. lets say you have a number where 30c you want that color to be magenta and at 34 you want it to be red. this will before your high alarm of 37 in psensor where you get an audible and visual alarm. its just a visual cue to tell you magenta the memory is under load. at red it is about to alarm. I pulled this script off of the stack exchange and tested it and it works.
make a file called colorize.awk and put this in it
#!/usr/bin/awk -f
BEGIN {
DEFAULT_COLOR = "\033[;m";
RED = "\033[1;31m";
MAGENTA = "\033[1;35m";
# Dimm thresholds
dimm_high = 34; #its getting close to an alarm
dimm_middle = 30; #we want a warning its under load
}
function colorize(temp, mid_trsh, high_trsh) {
new_color = "";
temp_number = temp;
gsub("[^0-9]","",temp_number);
gsub(".$","",temp_number);
if(temp_number >= high_trsh)
new_color = RED;
else if (temp_number >= mid_trsh)
new_color = MAGENTA;
return new_color temp DEFAULT_COLOR;
}
{ $2 = "\t" colorize($2, dimm_middle, dimm_high); }
{ print; }
usage
sensors | ./colorize.awk
or
watch -c 'sensors | ./colorize.awk'
this is from inside the same directory as colorize.awk
if you have it in /usr/bin/colorize.awk
sensors | colorize.awk
or
watch -c 'sensors | colorize.awk'
my command
watch -c 'sensors | grep -v "AUX\|in0\|in1\|in2\|in3\|in4\|in5\|in6\|in7\|in8\|in9\|in11\|in13\|fan2\|fan3\|fan4\|fan5\|fan6"|./colorize.awk'

I just set dimm_high and dimm_middle to 17 to show you what the script looks like when it goes over the value.
this will change the color of your watch sensors display and also sensors command.
source: https://unix.stackexchange.com/question ... om-sensors
now that is a little extreme. but if youre doing this for a living and needing to keep a close eye on overclocked ram it would be worth it. in my case I use gsat stress testing and my memory will reach a maximum for 35c under extreme loads. that is at a high voltage of 1.58v.
some memory might behave differently they could have bad heat spreaders or bad air flow ect. some people even run over 1.6v. so you will error out on tRFC at high temperature. and high temperature kills components. so if we are getting 40c you stop the testing and adjust your voltage and timings to maintain a <40c. or risk permanent damage.
Next I will make a simple script to change the alarm when it comes in on lm sensor. ( ALARM ).
we want this to be red. now if you use watch -d sensors when alarm comes in it will blink. but it will blink for a short while and then ALARM will be the same color as everything else so you could miss it.
this should be red. then this would be the only script we need for lm sensor. I will post when I have the script done and include it in the server script module for psensor.
Making scripts lm sensor treshholds
So i use lm sensor to watch my memory dimms. lets say you have a number where 30c you want that color to be magenta and at 34 you want it to be red. this will before your high alarm of 37 in psensor where you get an audible and visual alarm. its just a visual cue to tell you magenta the memory is under load. at red it is about to alarm. I pulled this script off of the stack exchange and tested it and it works.
make a file called colorize.awk and put this in it
#!/usr/bin/awk -f
BEGIN {
DEFAULT_COLOR = "\033[;m";
RED = "\033[1;31m";
MAGENTA = "\033[1;35m";
# Dimm thresholds
dimm_high = 34; #its getting close to an alarm
dimm_middle = 30; #we want a warning its under load
}
function colorize(temp, mid_trsh, high_trsh) {
new_color = "";
temp_number = temp;
gsub("[^0-9]","",temp_number);
gsub(".$","",temp_number);
if(temp_number >= high_trsh)
new_color = RED;
else if (temp_number >= mid_trsh)
new_color = MAGENTA;
return new_color temp DEFAULT_COLOR;
}
{ $2 = "\t" colorize($2, dimm_middle, dimm_high); }
{ print; }
usage
sensors | ./colorize.awk
or
watch -c 'sensors | ./colorize.awk'
this is from inside the same directory as colorize.awk
if you have it in /usr/bin/colorize.awk
sensors | colorize.awk
or
watch -c 'sensors | colorize.awk'
my command
watch -c 'sensors | grep -v "AUX\|in0\|in1\|in2\|in3\|in4\|in5\|in6\|in7\|in8\|in9\|in11\|in13\|fan2\|fan3\|fan4\|fan5\|fan6"|./colorize.awk'

I just set dimm_high and dimm_middle to 17 to show you what the script looks like when it goes over the value.
this will change the color of your watch sensors display and also sensors command.
source: https://unix.stackexchange.com/question ... om-sensors
now that is a little extreme. but if youre doing this for a living and needing to keep a close eye on overclocked ram it would be worth it. in my case I use gsat stress testing and my memory will reach a maximum for 35c under extreme loads. that is at a high voltage of 1.58v.
some memory might behave differently they could have bad heat spreaders or bad air flow ect. some people even run over 1.6v. so you will error out on tRFC at high temperature. and high temperature kills components. so if we are getting 40c you stop the testing and adjust your voltage and timings to maintain a <40c. or risk permanent damage.
Next I will make a simple script to change the alarm when it comes in on lm sensor. ( ALARM ).
we want this to be red. now if you use watch -d sensors when alarm comes in it will blink. but it will blink for a short while and then ALARM will be the same color as everything else so you could miss it.
this should be red. then this would be the only script we need for lm sensor. I will post when I have the script done and include it in the server script module for psensor.
Last edited by dreadbird on 23 Dec 2024, 08:43, edited 5 times in total.
psensors
Debugging purposes

Draft
#!/usr/bin/awk -f
BEGIN {
DEFAULT_COLOR = "\033[;m";
RED = "\033[1;31m";
MAGENTA = "\033[1;35m";
# CPU_thresholds
dimm_high = 15;
dimm_middle = 35;
}
function colorize(temp, mid_trsh, high_trsh) {
new_color = "";
temp_number = temp;
gsub("[^0-9]","",temp_number);
gsub(".$","",temp_number);
if(temp_number >= high_trsh)
new_color = RED;
else if (temp_number >= mid_trsh)
new_color = MAGENTA;
else if (temp_number = "ALARM")
new_color = RED;
return new_color temp DEFAULT_COLOR;
}
# change /Dimm/ to your label
/Dimm/ { $2 = "\t" colorize($2, dimm_middle, dimm_high); }
/ALARM/ { $6 = "\t" colorize($6, dimm_middle, dimm_high); }
{ print; }
Final script (in module)
make colorize.awk
put in /usr/bin/
#! /usr/bin/awk -f
BEGIN {
DEFAULT_COLOR = "\033[;m";
RED = "\033[1;31m";
MAGENTA = "\033[1;35m";
# CPU_thresholds
dimm_high = 35;
dimm_middle = 30;
}
function colorize(temp, mid_trsh, high_trsh) {
new_color = "";
temp_number = temp;
gsub("[^0-9]","",temp_number);
gsub(".$","",temp_number);
if(temp_number >= high_trsh)
new_color = RED;
else if (temp_number >= mid_trsh)
new_color = MAGENTA;
# else (temp_number = "ALARM")
# new_color = RED;
return new_color temp DEFAULT_COLOR;
}
function colorizealarm(temp, mid_trsh, high_trsh) {
new_color = "";
temp_number = temp;
gsub("[^0-9]","",temp_number);
gsub(".$","",temp_number);
new_color = RED;
return new_color temp DEFAULT_COLOR;
}
#Change Dimm to your label or keyword
/Dimm/ { $2 = "\t" colorize($2, dimm_middle, dimm_high); }
/ALARM/ { $6 = "\t" colorizealarm($6, dimm_middle, dimm_high); }
{ print; }
How does the script work
$2 means anythinig 2 parts in
$6 means anything 6 parts in (thats wher ALARM comes in)
it then sends the value into colorize or colorize function and compares. Is this a number or is this "ALARM". and sets the colors.
Usage
watch -c 'sensors | grep -v "textwhatyoudontwant\|textofwhatyoudontwant2"|colorize.awk'
or
watch sensors |colorize.awk
or
watch -c 'sensors | grep "Dimm" |colorize.awk' #shows only Dimm lines with the colorize script

Draft
#!/usr/bin/awk -f
BEGIN {
DEFAULT_COLOR = "\033[;m";
RED = "\033[1;31m";
MAGENTA = "\033[1;35m";
# CPU_thresholds
dimm_high = 15;
dimm_middle = 35;
}
function colorize(temp, mid_trsh, high_trsh) {
new_color = "";
temp_number = temp;
gsub("[^0-9]","",temp_number);
gsub(".$","",temp_number);
if(temp_number >= high_trsh)
new_color = RED;
else if (temp_number >= mid_trsh)
new_color = MAGENTA;
else if (temp_number = "ALARM")
new_color = RED;
return new_color temp DEFAULT_COLOR;
}
# change /Dimm/ to your label
/Dimm/ { $2 = "\t" colorize($2, dimm_middle, dimm_high); }
/ALARM/ { $6 = "\t" colorize($6, dimm_middle, dimm_high); }
{ print; }
Final script (in module)
make colorize.awk
put in /usr/bin/
#! /usr/bin/awk -f
BEGIN {
DEFAULT_COLOR = "\033[;m";
RED = "\033[1;31m";
MAGENTA = "\033[1;35m";
# CPU_thresholds
dimm_high = 35;
dimm_middle = 30;
}
function colorize(temp, mid_trsh, high_trsh) {
new_color = "";
temp_number = temp;
gsub("[^0-9]","",temp_number);
gsub(".$","",temp_number);
if(temp_number >= high_trsh)
new_color = RED;
else if (temp_number >= mid_trsh)
new_color = MAGENTA;
# else (temp_number = "ALARM")
# new_color = RED;
return new_color temp DEFAULT_COLOR;
}
function colorizealarm(temp, mid_trsh, high_trsh) {
new_color = "";
temp_number = temp;
gsub("[^0-9]","",temp_number);
gsub(".$","",temp_number);
new_color = RED;
return new_color temp DEFAULT_COLOR;
}
#Change Dimm to your label or keyword
/Dimm/ { $2 = "\t" colorize($2, dimm_middle, dimm_high); }
/ALARM/ { $6 = "\t" colorizealarm($6, dimm_middle, dimm_high); }
{ print; }
How does the script work
$2 means anythinig 2 parts in
$6 means anything 6 parts in (thats wher ALARM comes in)
it then sends the value into colorize or colorize function and compares. Is this a number or is this "ALARM". and sets the colors.
Usage
watch -c 'sensors | grep -v "textwhatyoudontwant\|textofwhatyoudontwant2"|colorize.awk'
or
watch sensors |colorize.awk
or
watch -c 'sensors | grep "Dimm" |colorize.awk' #shows only Dimm lines with the colorize script
Last edited by dreadbird on 30 Dec 2024, 08:15, edited 14 times in total.
psensors
Psensor server script module (updated in link above as well)
https://drive.google.com/file/d/1xoEC0v ... drive_link<--- script module
contents of script module
/usr/bin/colorize.awk
/usr/local/bin/psensorserveron
/usr/local/bin/psensorserveroff
/usr/local/share/sensorswatch.ph
psensorserveron command turn on your server ( default port 443 )
psensorserveroff command turn off your server
must be in su to use commands (HTTP server requires su)
Watch lm sensors with color changing and Red ALARM (if it turns on)
1. use this in a terminal shortcut to watch sensors with colors
2. shortcut command: konsole -e /usr/local/share/sensorswatch.ph
How do I set lm sensor alarms?
/ect/sensors.d/anyfilename.txt <-- mine is B450carbon.txt can be anyfilename
you made this earlier (see above posts to setup lm sensor)
this is where you set the high crit values for alarm in lm sensors
make sure you do the follow after changes to this file
sudo sensors -s
How the script works
This will launch lm sensors showing important information in one page.
If the thresholds are met the color will be magenta. if it goes higher it will become red.
If an alarm comes in on lm sensor it will say ALARM in red. customized for the red color on alarm.
Default are 30 for medium threshold and 35 for high threshold.
edit /usr/bin/colorize.awk to set your med and high thresholds (magenta and red)
you can also edit sensorswatch.ph and add a -d so it will blink whenever something changes
there are also more adjustments you can make to the watch command to set refresh internals ect.
default refresh rate is 2 seconds
add -n 5 to refresh every 5 seconds
ie edit sensorswatch.ph
watch -n 5 -d -c 'sensors | grep -v "AUX\|in0\|in1\|in2\|in3\|in4\|in5\|in6\|in7\|in8\|in9\|in11\|in13\|fan2\|fan3\|fan4\|fan5\|fan6\|Agent0"|colorize.awk'
if you dont want to use colorize.awk comment out the bottom line and uncomment the top two lines. for a default look.
launch from konsole shortcut with command konsole -e /usr/local/share/sensorswatch.ph in properties
Use an icon that looks like an alarm or temperature probe. I renamed a konsole short to watch sensors and used a red temperature probe. my setup below

thresholds to 20 (colorize.awk) for this example and /ect/sensors.d/ to 20 for ALARM for lm sensor
I included different commands in sensorswatch.ph for instance I changed the command for my dimms only. I commented other options for convenience.

https://drive.google.com/file/d/1xoEC0v ... drive_link<--- script module
contents of script module
/usr/bin/colorize.awk
/usr/local/bin/psensorserveron
/usr/local/bin/psensorserveroff
/usr/local/share/sensorswatch.ph
psensorserveron command turn on your server ( default port 443 )
psensorserveroff command turn off your server
must be in su to use commands (HTTP server requires su)
Watch lm sensors with color changing and Red ALARM (if it turns on)
1. use this in a terminal shortcut to watch sensors with colors
2. shortcut command: konsole -e /usr/local/share/sensorswatch.ph
How do I set lm sensor alarms?
/ect/sensors.d/anyfilename.txt <-- mine is B450carbon.txt can be anyfilename
you made this earlier (see above posts to setup lm sensor)
this is where you set the high crit values for alarm in lm sensors
make sure you do the follow after changes to this file
sudo sensors -s
How the script works
This will launch lm sensors showing important information in one page.
If the thresholds are met the color will be magenta. if it goes higher it will become red.
If an alarm comes in on lm sensor it will say ALARM in red. customized for the red color on alarm.
Default are 30 for medium threshold and 35 for high threshold.
edit /usr/bin/colorize.awk to set your med and high thresholds (magenta and red)
you can also edit sensorswatch.ph and add a -d so it will blink whenever something changes
there are also more adjustments you can make to the watch command to set refresh internals ect.
default refresh rate is 2 seconds
add -n 5 to refresh every 5 seconds
ie edit sensorswatch.ph
watch -n 5 -d -c 'sensors | grep -v "AUX\|in0\|in1\|in2\|in3\|in4\|in5\|in6\|in7\|in8\|in9\|in11\|in13\|fan2\|fan3\|fan4\|fan5\|fan6\|Agent0"|colorize.awk'
if you dont want to use colorize.awk comment out the bottom line and uncomment the top two lines. for a default look.
launch from konsole shortcut with command konsole -e /usr/local/share/sensorswatch.ph in properties
Use an icon that looks like an alarm or temperature probe. I renamed a konsole short to watch sensors and used a red temperature probe. my setup below

thresholds to 20 (colorize.awk) for this example and /ect/sensors.d/ to 20 for ALARM for lm sensor
I included different commands in sensorswatch.ph for instance I changed the command for my dimms only. I commented other options for convenience.

Last edited by dreadbird on 21 Dec 2024, 17:27, edited 29 times in total.
psensors
I have finished what I set out to do. hopefully this helps someone and you can tweak things to your liking. I bet a lot of people that use linux are bald because it was a pain to set this all up 
I will update sensorwatch.ph to include common commands (comment them out) for convenience. That way if you dont want to use colorize.awk and prefer default colors you can easily edit it to your liking.
You can uncomment the top two lines in sensorwatch.ph to use it without colorize.awk.
As I debug gtk warnings from using different themes (these dont seem to effect anything you just get a warning if youre using oxygen theme not the default breeze).
Send email script
Ill setup an email script to send an email so you can get alerts on your phone. Thought this would be sweet to have built into psensor.
Say if your cpu fan is 0. Send alert to me and shutoff the computer in 10 seconds press any key to cancel.
https://slackware.pkgs.org/15.0/slackwa ... 1.txz.html <-- mutt
https://mritunjaysharma394.medium.com/h ... 3ae40b0003 <-- guide
https://ioflood.com/blog/install-mutt-command-linux/ supplemental guide for mutt
currently testing

I will update sensorwatch.ph to include common commands (comment them out) for convenience. That way if you dont want to use colorize.awk and prefer default colors you can easily edit it to your liking.
You can uncomment the top two lines in sensorwatch.ph to use it without colorize.awk.
As I debug gtk warnings from using different themes (these dont seem to effect anything you just get a warning if youre using oxygen theme not the default breeze).
Send email script
Ill setup an email script to send an email so you can get alerts on your phone. Thought this would be sweet to have built into psensor.
Say if your cpu fan is 0. Send alert to me and shutoff the computer in 10 seconds press any key to cancel.
https://slackware.pkgs.org/15.0/slackwa ... 1.txz.html <-- mutt
https://mritunjaysharma394.medium.com/h ... 3ae40b0003 <-- guide
https://ioflood.com/blog/install-mutt-command-linux/ supplemental guide for mutt
currently testing
psensors
Debugging purposes
So psensor doesnt send a notification to the GTK. but you do get a popup so thats all that really matters. your system doesnt log it. this goes into different themes as well the code doesnt expect ie Oxygen theme. I will look into this and fix it
Alerts are using Desktop Notification and a specific GTK+ status icon.
So psensor doesnt send a notification to the GTK. but you do get a popup so thats all that really matters. your system doesnt log it. this goes into different themes as well the code doesnt expect ie Oxygen theme. I will look into this and fix it
Alerts are using Desktop Notification and a specific GTK+ status icon.
psensors
If you use a different theme (I use oxygen)
https://slackware.pkgs.org/current/slac ... 1.txz.html <---- oxygen icons and windows
you will not get popups while on oxygen without this module. then you will get popups with that.
so search for your icon module in pkgs.org search icon and go to slackware
and select oxygen.
Regular desktop
if youre on standard theme breeze you will get popups automatically.
I set my desktop back to breeze just less of a pain.
Now about the gtk notifications. psensor has its own notification center on the task bar and popups and alerts show there. Not in the main gtk notifications. which is by design.
So everything is fully functioning.
glibtop(c=13062): [DEBUG] open.c:50 glibtop_open_l(): SIZEOF: 40 - 65648 - 248 - 65624 - 296 - 65624
glibtop(c=13062): [DEBUG] open.c:163 glibtop_open_l(): Calling sysdeps open function.
glibtop(c=13062): [DEBUG] init.c:229 glibtop_init_s(): init_s with features=0x2 and flags=0
this is just debug information that psensor is loading the cpu and memory usuage. its totally normal and only shows on startup.
https://slackware.pkgs.org/current/slac ... 1.txz.html <---- oxygen icons and windows
you will not get popups while on oxygen without this module. then you will get popups with that.
so search for your icon module in pkgs.org search icon and go to slackware
and select oxygen.
Regular desktop
if youre on standard theme breeze you will get popups automatically.
I set my desktop back to breeze just less of a pain.
Now about the gtk notifications. psensor has its own notification center on the task bar and popups and alerts show there. Not in the main gtk notifications. which is by design.
So everything is fully functioning.
glibtop(c=13062): [DEBUG] open.c:50 glibtop_open_l(): SIZEOF: 40 - 65648 - 248 - 65624 - 296 - 65624
glibtop(c=13062): [DEBUG] open.c:163 glibtop_open_l(): Calling sysdeps open function.
glibtop(c=13062): [DEBUG] init.c:229 glibtop_init_s(): init_s with features=0x2 and flags=0
this is just debug information that psensor is loading the cpu and memory usuage. its totally normal and only shows on startup.
psensors
Email alert
mutt 2.1.5
no dependencies
mutt -s 'H&K temperature alert' [email protected] < TemperatureMessage

Download mutt https://slackware.pkgs.org/15.0/slackwa ... 1.txz.html <--- slackware 15.0 mutt 2.1.5
https://drive.google.com/file/d/1-ZyLq_ ... sp=sharing <--- muttsetup module I made
this module will create the below directories with a default config file in ./muttrc/muttrc just add your username pass for smtp
create directories
~/.maildir/Inbox/cur
~/.maildir/Inbox/new
~/.maildir/Inbox/tmp
~/.mutt/cache
~/.mutt/certificates
~/.mutt/muttrc
muttrc contents
#set record="~/.maildir/Sent/"
#set postponed="~/.maildir/Drafts"
#set certificate_file = "~/.mutt/certificates"
#mail box settings
set record="+Sent"
set header_cache = "~/.mutt/cache/headers"
set message_cachedir = "~/.mutt/cache/bodies"
#unused settings for simple smtp settings
#set ssl_force_tls=yes
#set from= $imap_user
#set use_from=yes
#set realname='Your_Name'
#set folder = imaps://imap-mail.outlook.com:993
#set spoolfile = "+INBOX"
#set postponed="+[hotmail]/Drafts"
#set mail_check = 100
#set ssl_starttls=no
#set ssl_force_tls = no
#set imap_user = ""
#set imap_pass = ""
set imap_user = "putyourusername"
set imap_pass = "password"
set from= $imap_user
set use_from=yes
set smtp_url = smtp://[email protected]:587
set smtp_pass = $imap_pass
set record="+Sent"
#set move = no
#set imap_keepalive = 900
All you need is your smtp username and password.
make sure to rebuild the module (muttsetup) with the new config file so you dont lose it
mutt 2.1.5
no dependencies
mutt -s 'H&K temperature alert' [email protected] < TemperatureMessage

Download mutt https://slackware.pkgs.org/15.0/slackwa ... 1.txz.html <--- slackware 15.0 mutt 2.1.5
https://drive.google.com/file/d/1-ZyLq_ ... sp=sharing <--- muttsetup module I made
this module will create the below directories with a default config file in ./muttrc/muttrc just add your username pass for smtp
create directories
~/.maildir/Inbox/cur
~/.maildir/Inbox/new
~/.maildir/Inbox/tmp
~/.mutt/cache
~/.mutt/certificates
~/.mutt/muttrc
muttrc contents
#set record="~/.maildir/Sent/"
#set postponed="~/.maildir/Drafts"
#set certificate_file = "~/.mutt/certificates"
#mail box settings
set record="+Sent"
set header_cache = "~/.mutt/cache/headers"
set message_cachedir = "~/.mutt/cache/bodies"
#unused settings for simple smtp settings
#set ssl_force_tls=yes
#set from= $imap_user
#set use_from=yes
#set realname='Your_Name'
#set folder = imaps://imap-mail.outlook.com:993
#set spoolfile = "+INBOX"
#set postponed="+[hotmail]/Drafts"
#set mail_check = 100
#set ssl_starttls=no
#set ssl_force_tls = no
#set imap_user = ""
#set imap_pass = ""
set imap_user = "putyourusername"
set imap_pass = "password"
set from= $imap_user
set use_from=yes
set smtp_url = smtp://[email protected]:587
set smtp_pass = $imap_pass
set record="+Sent"
#set move = no
#set imap_keepalive = 900
All you need is your smtp username and password.
make sure to rebuild the module (muttsetup) with the new config file so you dont lose it
Last edited by dreadbird on 21 Dec 2024, 19:28, edited 10 times in total.
psensors
Biggest pia google and hotmail everyone is using Oauth 2.0. you have to find a smtp provider like mailgun there are a few others this one lets you send 100 emails per day.
Not a big deal just sending a simple email I wouldnt use this for anything else as its not encrypted ect. but for a simple solution this works for sending a simple message.
Not a big deal just sending a simple email I wouldnt use this for anything else as its not encrypted ect. but for a simple solution this works for sending a simple message.
psensors
Shutdown module
https://drive.google.com/file/d/1r1LCir ... sp=sharing <--- shutdown script
works as is without mutt but you can use mutt to send an email. I commented out mutt in systemtempshutdown for now.
/usr/bin/systemtempshutdown
/usr/local/share/TemperatureMessage
optional
mutt 2.1.5 slackware 15 https://slackware.pkgs.org/15.0/slackwa ... 1.txz.html
smtp provider
https://try.mailgun.com/api-1/? ... QAvD_BwE
100 perday
https://www.brevo.com/free-smtp-server/ 300 per day
in my case I use mailgun. you need to add your recipient email address from the website. then verify your email address to add it to the trusted emails.
it will likely go to your spam folder. then go to your email and once you recieve the message say always recieve emails from this email address it is not spam. now whenever you get the email from mutt on your phone you will get an alert
preferences - sensors - script executed on alarm - /usr/bin/systemtempshutdown
To allow a user to use the Shutdown command
create a file in sudoers directory
cd /etc/sudoers.d/
touch myfile
edit the file put
%users ALL=NOPASSWD: /sbin/shutdown
that should be all that is needed. if it doesnt work add
sudo su
cd /sbin/
chmod u+s /sbin/shutdown
Note: "many operating systems ignore the setuid attribute when applied to executable shell scripts, for security."
this may or not may not do anything youll have to test.
More things you can do with sudoers
# Adding some commands I don't need to enter password to run.
myusername ALL=(ALL) NOPASSWD: /home/myusername/bin/myapplication, /sbin/poweroff, /sbin/reboot
to cancel the shutdown
killall bash
Shutdown script
#!/bin/bash
echo "Shutdown started. system will shutdown in 10s"
notify-send "Shutdown Notification" "Your computer will shut down in 10 seconds "
/usr/local/bin/alarm.ph #alarm sound
#mutt -s 'H&K temperature alert' [email protected] < /usr/local/share/TemperatureMessage
sleep 10s
sudo shutdown -h now
For testing memory you could set it to shutdown in 2 seconds send you an email. mutt even logs everything as well. I generally set gsat to an hour or two. ycruncher fft and vt3 for an hour. if it goes off on temp shuts down.
I didnt include /etc/sudoers.d/myfile you would have to create that and edit it yourself to use the shutdown script.
chmod u+s if used
you should chmod -s /sbin/shutdown when finished with the script
this is a use case script. permissions in linux should not be taken lightly as this is what sets linux apart from windows. always try to set your files to chmod 600 for everyday use. this is to ensure only your user can do things with it.
and when finished remove the /etc/sudoers.do/myfile. as this is strictly a usecase shutdown script from when youre away from your computer.
Use cases
You can set it so if your cpu goes to 20% (from psensor) it shutsdown the computer
. if you forgot to logout so now the person has to put in a password on reboot.
or you could set it to not notify and set it to reboot in 1 minute. then you have time to cancel it if you see the alarm come in. then its like a kill switch. if you have to leave your computer and someone else comes on it will silently activate the shutdown for 1 minute and they wouldnt know.
Now a lot of this can be customized. so its a start or baseline to get things configured right. you could make a script to stop ycruncher testing or google gsat on high temperature. and send custom alerts
killall ycruncher
notify-send "ycruncher failed on high temperature."
-->make a log file
Psensor general script
make a script that encompasses everything without shutdown.
myscript.ph
#!/bin/bash
#play alarm sound
/usr/local/bin/alarm.ph
if pgrep -x 'ycruncher' &>/dev/null; then
notify-send "Dropping ycruncher" "ycruncher failed on high temperature "
killall ycruncher
#mutt -s 'H&K temperature alert' [email protected] < /usr/local/share/ycruncherFailure
elif pgrep -x 'stressapptest' &>/dev/null ; then
notify-send "Dropping stressapptest" "gsat failed on high temperature "
killall stressapptest
#mutt -s 'H&K temperature alert' [email protected] < /usr/local/share/GsatFailure
else
notify-send "High temperature alert corrective action needed."
#mutt -s 'H&K temperature alert' [email protected] < /usr/local/share/ #TemperatureMessage
fi
# make a log file
end of contents
this script will send a custom email based on what happened. and close any stress testing apps. your cpu fan most likely failed go check on pc.
so if you have a server that does encoding or processing and for whatever reason the cpu fan is not working it will shutdown your system if you set it up that way. especially if your tower cooler becomes plugged off you can shutdown the system on high cpu fan. My cpu fan never goes to 100% (set an alarm on cpu fan 100%). the 1/10000 chance it will work can save you a lot of money. ive had motherboards that shortout due to clogged tower coolers.
To achieve this
set bios fans to 75% for 50c. my server never goes over 50c. (find out what temp it runs at during processing or full load)
set bios fans to 100% for 60c.
fan goes to 100% while youre away. psensor pics up the 100% and takes action. your tower cooler is plugged on your server. remote server is shutdown. this would work if thats the only alarm you have.
if you have more alarm cases you could then parse the cpu die temp from lm sensor if cpudie > 59 create log file and shutdown.
if cpu die temp is > 59 psensor will shutdown otherwise it will just send a popup and a customized popup with an audible alarm. so you get two popups now
from our script above
we can edit the main action
#set your variables ect
#from above script this is the bottom part you can change
else
#first parse lm sensor for a variable your looking for 59 in cpu die. checking if cpu fan is plugged
if variable -gt 58; then
#send an email we that we have a plugged fan server shutdown
#mutt -s 'H&K temperature alert' [email protected] < /usr/local/share/PluggedFanShutdown
notify-send "Shutting down due to plugged fan. Click cancel on the desktop shortcut to cancel shutdown."
sleep 5s
sudo shutdown -h now
fi
#regular event (bottom of if statement) end of script
else
notify-send "High temperature alert corrective action needed."
#send an email we that we had an alarm we didnt need to shutdown.
#mutt -s 'H&K temperature alert' [email protected] < /usr/local/share/TemperatureMessage
fi
So now you built your script to go through and check what processes are running. shut those down if they are. then check for a plugged fan. if there is then shut the system down. Otherwise display a message that you got a warning. Then you get two popups from psensor the one you made with notify-send and the regular psensor popup.
https://drive.google.com/file/d/1r1LCir ... sp=sharing <--- shutdown script
works as is without mutt but you can use mutt to send an email. I commented out mutt in systemtempshutdown for now.
/usr/bin/systemtempshutdown
/usr/local/share/TemperatureMessage
optional
mutt 2.1.5 slackware 15 https://slackware.pkgs.org/15.0/slackwa ... 1.txz.html
smtp provider
https://try.mailgun.com/api-1/? ... QAvD_BwE
100 perday
https://www.brevo.com/free-smtp-server/ 300 per day
in my case I use mailgun. you need to add your recipient email address from the website. then verify your email address to add it to the trusted emails.
it will likely go to your spam folder. then go to your email and once you recieve the message say always recieve emails from this email address it is not spam. now whenever you get the email from mutt on your phone you will get an alert
preferences - sensors - script executed on alarm - /usr/bin/systemtempshutdown
To allow a user to use the Shutdown command
create a file in sudoers directory
cd /etc/sudoers.d/
touch myfile
edit the file put
%users ALL=NOPASSWD: /sbin/shutdown
that should be all that is needed. if it doesnt work add
sudo su
cd /sbin/
chmod u+s /sbin/shutdown
Note: "many operating systems ignore the setuid attribute when applied to executable shell scripts, for security."
this may or not may not do anything youll have to test.
More things you can do with sudoers
# Adding some commands I don't need to enter password to run.
myusername ALL=(ALL) NOPASSWD: /home/myusername/bin/myapplication, /sbin/poweroff, /sbin/reboot
to cancel the shutdown
killall bash
Shutdown script
#!/bin/bash
echo "Shutdown started. system will shutdown in 10s"
notify-send "Shutdown Notification" "Your computer will shut down in 10 seconds "
/usr/local/bin/alarm.ph #alarm sound
#mutt -s 'H&K temperature alert' [email protected] < /usr/local/share/TemperatureMessage
sleep 10s
sudo shutdown -h now
For testing memory you could set it to shutdown in 2 seconds send you an email. mutt even logs everything as well. I generally set gsat to an hour or two. ycruncher fft and vt3 for an hour. if it goes off on temp shuts down.
I didnt include /etc/sudoers.d/myfile you would have to create that and edit it yourself to use the shutdown script.
chmod u+s if used
you should chmod -s /sbin/shutdown when finished with the script
this is a use case script. permissions in linux should not be taken lightly as this is what sets linux apart from windows. always try to set your files to chmod 600 for everyday use. this is to ensure only your user can do things with it.
and when finished remove the /etc/sudoers.do/myfile. as this is strictly a usecase shutdown script from when youre away from your computer.
Use cases
You can set it so if your cpu goes to 20% (from psensor) it shutsdown the computer

or you could set it to not notify and set it to reboot in 1 minute. then you have time to cancel it if you see the alarm come in. then its like a kill switch. if you have to leave your computer and someone else comes on it will silently activate the shutdown for 1 minute and they wouldnt know.
Now a lot of this can be customized. so its a start or baseline to get things configured right. you could make a script to stop ycruncher testing or google gsat on high temperature. and send custom alerts
killall ycruncher
notify-send "ycruncher failed on high temperature."
-->make a log file
Psensor general script
make a script that encompasses everything without shutdown.
myscript.ph
#!/bin/bash
#play alarm sound
/usr/local/bin/alarm.ph
if pgrep -x 'ycruncher' &>/dev/null; then
notify-send "Dropping ycruncher" "ycruncher failed on high temperature "
killall ycruncher
#mutt -s 'H&K temperature alert' [email protected] < /usr/local/share/ycruncherFailure
elif pgrep -x 'stressapptest' &>/dev/null ; then
notify-send "Dropping stressapptest" "gsat failed on high temperature "
killall stressapptest
#mutt -s 'H&K temperature alert' [email protected] < /usr/local/share/GsatFailure
else
notify-send "High temperature alert corrective action needed."
#mutt -s 'H&K temperature alert' [email protected] < /usr/local/share/ #TemperatureMessage
fi
# make a log file
end of contents
this script will send a custom email based on what happened. and close any stress testing apps. your cpu fan most likely failed go check on pc.
so if you have a server that does encoding or processing and for whatever reason the cpu fan is not working it will shutdown your system if you set it up that way. especially if your tower cooler becomes plugged off you can shutdown the system on high cpu fan. My cpu fan never goes to 100% (set an alarm on cpu fan 100%). the 1/10000 chance it will work can save you a lot of money. ive had motherboards that shortout due to clogged tower coolers.
To achieve this
set bios fans to 75% for 50c. my server never goes over 50c. (find out what temp it runs at during processing or full load)
set bios fans to 100% for 60c.
fan goes to 100% while youre away. psensor pics up the 100% and takes action. your tower cooler is plugged on your server. remote server is shutdown. this would work if thats the only alarm you have.
if you have more alarm cases you could then parse the cpu die temp from lm sensor if cpudie > 59 create log file and shutdown.
if cpu die temp is > 59 psensor will shutdown otherwise it will just send a popup and a customized popup with an audible alarm. so you get two popups now

from our script above
we can edit the main action
#set your variables ect
#from above script this is the bottom part you can change
else
#first parse lm sensor for a variable your looking for 59 in cpu die. checking if cpu fan is plugged
if variable -gt 58; then
#send an email we that we have a plugged fan server shutdown
#mutt -s 'H&K temperature alert' [email protected] < /usr/local/share/PluggedFanShutdown
notify-send "Shutting down due to plugged fan. Click cancel on the desktop shortcut to cancel shutdown."
sleep 5s
sudo shutdown -h now
fi
#regular event (bottom of if statement) end of script
else
notify-send "High temperature alert corrective action needed."
#send an email we that we had an alarm we didnt need to shutdown.
#mutt -s 'H&K temperature alert' [email protected] < /usr/local/share/TemperatureMessage
fi
So now you built your script to go through and check what processes are running. shut those down if they are. then check for a plugged fan. if there is then shut the system down. Otherwise display a message that you got a warning. Then you get two popups from psensor the one you made with notify-send and the regular psensor popup.

psensors
I just found out i labeled Home wrong in the psensor module it should be home thats probably why the psensor config file was missing. so if you extract the module and rename it to home should fix that.