change ip and temperature alarm

start with install crontab

sudo apt-get install crontab

maybe present for default

sudo apt-get install sendemail

sending email by terminal

create a file

nano inforaspy

and paste this

#!/bin/bash

############ Parameters ############
user="xx"
tempmax="55"
mittente="xxxxx@xxx"
dest="xxxxx@xxx"
smtp="smtp.xxxx"
username="xxxxx@xxx"
pass="xxxxxxxx"
############ End Parameters ############
ip_old="`tail /home/$user/.inforaspy`"
ip_now="`wget -qO- http://checkip.dyndns.org/ | sed "s/.* ([[:digit:]]*.[[:digit:]]*.[[:digit:]]*.[[:digit:]]*).*/$
temp="`cat /sys/class/thermal/thermal_zone0/temp | cut -c1-2`"
echo $ip_now > /home/$user/.inforaspy
if [ "$ip_old" != "$ip_now" ]; then
 titoloip="Public IP changed!"
 ipresult="New IP is $ip_now"
 sendEmail -f $mittente -t $dest -u $titoloip -s $smtp -xu $username -xp $pass -m $ipresult
fi
if [[ "$temp" > "$tempmax" ]]; then
 titolotemp="Raspberry alarm!"
 tempresult="Alarm! Raspberry temperature is $temp."
 sendEmail -f $mittente -t $dest -u $titolotemp -s $smtp -xu $username -xp $pass -m $tempresult
fi
exit

here is parameters you have to set:
user=”pi” –> your raspbian user, default is “pi”
tempmax=”55″ –> your temperature value for raspberry safety
mittente=”” –> email sender
dest=”” –> email destination
smtp=”” –> your email sender SMTP server
username=”” –> username mail sender
pass=”” –> password mail sender

give the execute right

chmod +x inforaspy

and copy in a system folder

sudo mv inforaspy /usr/bin/

now program crontab to execute every 10 minute

sudo crontab -e

it opens a text editore, paste this at the end

*/10 * * * * inforaspy

then presso control+O to save and control+X to exit the editore
number 10 you see is for 10 minutes. you can change.

On error “invalid SSL_version specified at /usr/share/perl5/IO/Socket/SSL.pm line 332”

pi@raspberrypi ~/egg $ sudo nano ./usr/share/perl5/IO/Socket/SSL.pm

find this line:
m{^(!?)(?:(SSL(?:v2|v3|v23|v2/3))|(TLSv1[12]?))$}i

and change for this:
m{^(!?)(?:(SSL(?:v2|v3|v23|v2/3))|(TLSv1[12]?))}i

Leave a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.