标签:temp out bin after oda ash gpu seconds tmp
#!/bin/bashpasswd=emdata2018
today=date +%Y%m%d
mulu=/home/user/cpuwd/log
touch $mulu/CPU$today.log
touch $mulu/CPUGW$today.log
touch $mulu/GPU$today.log
touch $mulu/GPUGW$today.log
touch $mulu/GJ_log
sensors |awk ‘{print $4}‘ |egrep ‘^+‘ |sed ‘s/+//‘ |while read temp
do
if [[ $temp > 70 ]];then
echo "$(date +%Y-%m-%d-%T) CPU $temp is High Temperature $( expr `date +%H` \* 60 + `date +%M` )" >>$mulu/CPUGW_$today.log
else
echo "$(date +%Y-%m-%d-%T) CPU $temp is Temperature OK $( expr `date +%H` \* 60 + `date +%M` )" >>$mulu/CPU_$today.log
fi
if [[ $temp > 80 ]];then
echo "$(date +%Y-%m-%d-%T) CPU temperature exceeds 80C,After 3 seconds is about to shut down" >>$mulu/GJ_log
#$passwd
#EOF
fi
done
a=grep "$(date -d ‘-10min‘ "+%Y-%m-%d-%H:%M")" $mulu/CPUGW_$today.log
b=grep "$(date "+%Y-%m-%d-%H:%M")" $mulu/CPUGW_$today.log
A=grep "$(date -d ‘-10min‘ "+%Y-%m-%d-%H:%M")" $mulu/CPUGW_$today.log |awk ‘{print $7}‘|head -1
B=grep "$(date "+%Y-%m-%d-%H:%M")" $mulu/CPUGW_$today.log |awk ‘{print $7}‘|head -1
C=expr "$B" - "$A"
if [ $C > 9 ];then
echo $a >>$mulu/GJ_log
echo $b >>$mulu/GJ_log
echo $C Min CPU guanji
echo "$(date +%Y-%m-%d-%T) CPU lasts 10 minutes high temperature,After 3 seconds is about to shut down" >>$mulu/GJ_log
#$passwd
#EOF
fi
nvidia-smi -q -i 0,1,2,3,4,5,6,7 -d TEMPERATURE | grep "GPU Current" |awk ‘{print $5}‘ |while read tmp
do
if [[ $tmp > 90 ]];then
echo "$(date +%Y-%m-%d-%T) GPU $tmp is High Temperature $( expr `date +%H` \* 60 + `date +%M` )" >>$mulu/GPUGW_$today.log
else
echo "$(date +%Y-%m-%d-%T) GPU $tmp is Temperature OK $( expr `date +%H` \* 60 + `date +%M` )" >>$mulu/GPU_$today.log
fi
if [[ $tmp > 99 ]];then
echo "$(date +%Y-%m-%d-%T) GPU temperature exceeds 80C,After 3 seconds is about to shut down" >>$mulu/GJ_log
#$passwd
#EOF
fi
done
x=grep "$(date -d ‘-10min‘ "+%Y-%m-%d-%H:%M")" $mulu/GPUGW_$today.log
y=grep "$(date "+%Y-%m-%d-%H:%M")" $mulu/GPUGW_$today.log
X=grep "$(date -d ‘-10min‘ "+%Y-%m-%d-%H:%M")" $mulu/GPUGW_$today.log |awk ‘{print $7}‘|head -1
Y=grep "$(date "+%Y-%m-%d-%H:%M")" $mulu/GPUGW_$today.log |awk ‘{print $7}‘|head -1
Z=expr "$Y" - "$X"
if [ $Z > 9 ];then
echo $x >>$mulu/GJ_log
echo $y >>$mulu/GJ_log
echo $Z Min GPU guanji
echo "$(date +%Y-%m-%d-%T) GPU lasts 10 minutes high temperature,After 3 seconds is about to shut down" >>$mulu/GJ_log
#$passwd
#EOF
fi
标签:temp out bin after oda ash gpu seconds tmp
原文地址:http://blog.51cto.com/shlinuxdream/2147246