Essa é uma revisão anterior do documento!
echo baixando/instalando os pacotes/arquivos necessarios #apt install python3-serial jq git apt install python3-serial git git clone https://github.com/ccwienk/temper.git
#temperatura=$( /opt/temper/temper.py --json | jq --raw-output '.[] ."internal temperature"' ) temperatura=$( /opt/temper/temper.py | awk '{print $7}' | sed 's/C//' ) echo $temperatura maximo=26.0 teste=$(echo "$temperatura < $maximo" | bc) if [ $teste = '1' ]; then echo "temperature $temperaturaºC is smaller than $maximoºC"; else echo 'Alert! Temperature $temperaturaºC is biggest than $maximoºC'; echo "Enviando email..." set smtp=smtps://smtp.grude.ufmg.br:465 set from="sddr@icb.ufmg.br" set smtp-auth-user=icb-smtp set smtp-auth-password=SENHANOWIKI set smtp-auth=login set smtp-verify=ignore echo "Temperatura: $temperatura" | /bin/mailx -v -s "[SDDR] Temperatura acima de $maximo graus" gti@icb.ufmg.br echo "Temperatura: $temperatura" | /bin/mailx -v -s "[SDDR] Temperatura acima de $maximo graus" miguel@icb.ufmg.br echo "Enviado com sucesso" fi;
#!/bin/bash ## ## temper.sh ## reads and print temperature from TEMPer device(s) ## requires hid-query from the TEMPered project ## https://cylab.be/blog/92/measure-ambient-temperature-with-temper-and-linux ## for device in /dev/hidraw*; do ## quey $device and grep for return value #hexvalue=`hid-query "$device" 0x01 0x80 0x33 0x01 0x00 0x00 0x00 0x00 2> /dev/null | grep -oP "80 80 K([0-9a-fA-F]{2} [0-9a-fA-F]{2})" | tr -d ' '` hexvalue=$(hid-query "$device" 0x01 0x80 0x33 0x01 0x00 0x00 0x00 0x00 2> /dev/null | grep "80 80" | tr -d ' ') hexvalue=${hexvalue:5:4} ## convert hex to dec decvalue=`printf "%d" $((16#$hexvalue))` ## divide by 100 decvalue=`bc <<< "scale=2; ${decvalue}/100"` printf "%s : %s °C " $device $decvalue done;
00-59/10 * * * * bash /opt/temper/cron.sh >> /opt/temper/cron.log