Advertisement
zefie

HP iLO fan control with socket

Oct 28th, 2023 (edited)
1,053
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.23 KB | None | 0 0
  1. #!/bin/bash
  2. CMD=("ssh" "-oHostKeyAlgorithms=+ssh-rsa" "-oControlPath=/tmp/ilo.sock" "-oKexAlgorithms=diffie-hellman-group14-sha1,diffie-hellman-group1-sha1" "-oPubkeyAcceptedKeyTypes=+ssh-rsa" "-i/root/.ssh/id_ilo" "Administrator@192.168.11.7")
  3. if [ ! -e /tmp/ilo.sock ]; then
  4.     "${CMD[@]}" "-oControlMaster=yes" "-f"
  5. fi
  6.  
  7. HIGHEST_TEMP=$(ipmi-sensors | cut -d'|' -f4 | sort -nr | head -n1 | sed "s/ *//" | cut -d'.' -f1)
  8. RUN=0
  9. if [ "${HIGHEST_TEMP}" -ge 75 ]; then
  10.     # panic mode
  11.     SPEED0=255
  12.     SPEED1=255
  13. elif [ "${HIGHEST_TEMP}" -ge 70 ]; then
  14.     # hot
  15.     SPEED0=185
  16.     SPEED1=150
  17. elif [ "${HIGHEST_TEMP}" -ge 65 ]; then
  18.     # warm
  19.     SPEED0=125
  20.     SPEED1=100
  21. else
  22.     # cool
  23.     SPEED0=100
  24.     SPEED1=75
  25. fi
  26.  
  27.  
  28.  
  29. if [ -f "/tmp/lasttemp" ]; then
  30.     if [ "$(cat /tmp/lastspeed)" -ne "${SPEED1}" ]; then
  31.         RUN=1
  32.     fi
  33. else
  34.     RUN=1
  35. fi
  36.  
  37. echo "${SPEED1}" > /tmp/lastspeed
  38.  
  39. if [ "${RUN}" -eq "1" ]; then
  40.     # main fan (iLO/HD Controller/LAN/etc)
  41.     ${CMD[@]} "-oControlMaster=no" -t fan p 0 max ${SPEED0};
  42.     ${CMD[@]} "-oControlMaster=no" -t fan p 1 max ${SPEED0};
  43.  
  44.     # rest of the fans
  45.     for f in `seq 2 7`; do
  46.         ${CMD[@]} "-oControlMaster=no" -t fan p ${f} max ${SPEED1};
  47.     done
  48. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement