Sorry bit of a newbie here
the only thing i didnt really show was that its all in a while loop
i did read something about all uppercase variables been system /env so i moved away from them. as far as i can see theyre all the same
the set -xv shows
[CODE]
Quote:
++ echo
sensors | grep 'Core' | awk '{ print $2 " " $3 }' |tr -d '+°C' | while read output;
do
temp=$(echo $output | awk '{ print $2}' | cut -d' ' -f1 | sed -r 's_\.[0-9]__' )
#echo $temp
Core=$(echo $output | awk '{ print $1 }' )
if [ $temp -ge $Alert ]; then
echo "high temp on Core $Core ($temp), on server $(hostname) at $(date)" >>/tmp/tempalert
Send=1
tester=1
echo working
echo "send in if $Send"
#mutt -s "Alert: Free space low, $usep % used on $partition" $ADMIN
else
Send=0
fi
done
++ sensors
++ grep Core
++ awk '{ print $2 " " $3 }'
++ tr -d +°C
++ read output
echo $output | awk '{ print $2}' | cut -d' ' -f1 | sed -r 's_\.[0-9]__'
+++ echo 0: 54.0
+++ cut '-d ' -f1
+++ awk '{ print $2}'
+++ sed -r 's_\.[0-9]__'
++ temp=54
echo $output | awk '{ print $1 }'
+++ echo 0: 54.0
+++ awk '{ print $1 }'
++ Core=0:
++ '[' 54 -ge 50 ']'
hostname
+++ hostname
date
+++ date
++ echo 'high temp on Core 0: (54), on server Premier.local at Sat 1 Oct 14:14:11 BST 2016'
++ Send=1
++ tester=1
++ echo working
working
++ echo 'send in if 1'
send in if 1
++ read output
echo $output | awk '{ print $2}' | cut -d' ' -f1 | sed -r 's_\.[0-9]__'
+++ echo 1: 52.0
+++ awk '{ print $2}'
+++ cut '-d ' -f1
+++ sed -r 's_\.[0-9]__'
++ temp=52
echo $output | awk '{ print $1 }'
+++ echo 1: 52.0
+++ awk '{ print $1 }'
++ Core=1:
++ '[' 52 -ge 50 ']'
hostname
+++ hostname
date
+++ date
++ echo 'high temp on Core 1: (52), on server Premier.local at Sat 1 Oct 14:14:11 BST 2016'
++ Send=1
++ tester=1
++ echo working
working
++ echo 'send in if 1'
send in if 1
++ read output
echo "send at end $Send"
++ echo 'send at end 0'
send at end 0
echo "tester $tester"
++ echo 'tester '
tester
if [ $Send -eq 1 ]; then
cat /tmp/tempalert | mutt -s "tempalert" me@me.com
fi
++ '[' 0 -eq 1 ']'
|
[\CODE]
[CODE]
ADMIN="me@me.com"
# set alert-level 56 standard
Alert=50
Send=0
export Send
echo "To: me@me.com" >/tmp/tempalert
echo "From: me@me.com" >>/tmp/tempalert
echo "Subject: tempalert - Premier">>/tmp/tempalert
echo >>/tmp/tempalert
sensors | grep 'Core' | awk '{ print $2 " " $3 }' |tr -d '+°C' | while read output;
do
temp=$(echo $output | awk '{ print $2}' | cut -d' ' -f1 | sed -r 's_\.[0-9]__' )
Core=$(echo $output | awk '{ print $1 }' )
if [ $temp -ge $Alert ]; then
echo "high temp on Core $Core ($temp), on server $(hostname) at $(date)" >>/tmp/tempalert
Send=1
tester=1
echo working
echo "send in if $Send"
else
Send=0
fi
done
echo "send at end $Send"
echo "tester $tester"
if [ $Send -eq 1 ]; then
cat /tmp/tempalert | mutt -s "tempalert" me@me.com
fi
[\CODE]