vtverdohleb писал(а):
lihacheff писал(а):
VMihalich писал(а):
на
Код:
tcpu=`/usr/sbin/fan_control -g 0 | awk '{print $4}'
теперь:
/dev/sdb:
 setting standby to 60 (5 minutes)
sh: 0: unknown operand
Код:
tcpu=`/usr/sbin/fan_control -g 0 | awk '{print $4}'`
кавычку в конце потеряли
да нет.. не потерял:
#!/bin/sh
t_stop=42
t_start1=51
t_start2=55
killall -9 fan_control
#В сон HDD если нет активности в течении 5 минут(60 - 5 минут)
#/usr/bin/hdparm -S 60 /dev/sda      #У меня установка сна первого винта отключена поскольку винт WD Red.
/usr/bin/hdparm -S 60 /dev/sdb
/usr/sbin/fan_control -f 2
status=2
ocurr=$t_stop
dt=`date +'%b %e %T'`
echo "$dt NAS fan_control: Fan_new_Start" >> /var/log/user.log
while true
do
   tcpu=`/usr/sbin/fan_control -g 0 | awk '{print $4}'`
   sth1dd=`/usr/bin/hdparm -C /dev/sda | grep drive | awk '{print $4}'`
   sth2dd=`/usr/bin/hdparm -C /dev/sdb | grep drive | awk '{print $4}'`
   if [ $sth1dd == "standby" ] ; then
      h1dd=-1
   else
      h1dd=`/usr/bin/smartctl -d marvell -A /dev/sda | awk '{if($1==194)print $10*1}'`
   fi
   if [ $sth2dd == "standby" ] ; then
      h2dd=-1
   else
      h2dd=`/usr/bin/smartctl -d marvell -A /dev/sdb | awk '{if($1==194)print $10*1}'`
   fi
   curr=$tcpu
   if [ $h1dd -gt $curr ] ; then
      curr=$h1dd
   fi
   if [ $h2dd -gt $curr ] ; then
      curr=$h2dd
   fi
   if [ $curr -ge $t_start2 ] ; then
      if [ $status -ne 2 ] ; then
         status=2
         prn=1
         /usr/sbin/fan_control -f 2
      fi
      if [ $curr -gt $ocurr ] ; then
         prn=1
      fi
   elif [ $curr -ge $t_start1 ] ; then
      if [ $status -ne 1 ] ; then
         status=1
         prn=1
         /usr/sbin/fan_control -f 1
      fi
   elif [ $curr -le $t_stop ] ; then
      if [ $status -ne 0 ] ; then
         status=0
         prn=1
         /usr/sbin/fan_control -f 0
      fi
   elif [ $curr -le $t_start1 ] ; then
      if [ $status -eq 2 ] ; then
         status=1
         prn=1
         /usr/sbin/fan_control -f 1
      fi
   fi
   if [ $h1dd -gt 0 ] ; then
   if [ $oh1dd -lt 0 ] ; then
      prn=1
   fi
   fi
   if [ $oh1dd -gt 0 ] ; then
   if [ $h1dd -lt 0 ] ; then
      prn=1
   fi
   fi
   if [ $h2dd -gt 0 ] ; then
   if [ $oh2dd -lt 0 ] ; then
      prn=1
   fi
   fi
   if [ $oh2dd -gt 0 ] ; then
   if [ $h2dd -lt 0 ] ; then
      prn=1
   fi
   fi
   if [ $prn -eq 1 ] ; then
      prn=0
      dt=`date +'%b %e %T'`
      lg="T=$curr, status = $status, CPU=$tcpu, HDD1=$h1dd, HDD2=$h2dd"
      echo "$dt NAS fan_control: $lg" >> /var/log/user.log
   fi
   ocurr=$curr
   oh1dd=$h1dd
   oh2dd=$h2dd
   sleep 30
done