zefie icon

HP iLO fan control with socket

zefie | PRO | 10/28/23 11:50:41 PM UTC (Edited) | 0 ⭐ | 1422 👁️ | Never ⏰ | []
Bash |

1.23 KB

|

None

|

0 👍

/

0 👎

#!/bin/bash
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" "[email protected]")
if [ ! -e /tmp/ilo.sock ]; then
    "${CMD[@]}" "-oControlMaster=yes" "-f"
fi
 
HIGHEST_TEMP=$(ipmi-sensors | cut -d'|' -f4 | sort -nr | head -n1 | sed "s/ *//" | cut -d'.' -f1)
RUN=0
if [ "${HIGHEST_TEMP}" -ge 75 ]; then
    # panic mode
    SPEED0=255
    SPEED1=255
elif [ "${HIGHEST_TEMP}" -ge 70 ]; then
    # hot
    SPEED0=185
    SPEED1=150
elif [ "${HIGHEST_TEMP}" -ge 65 ]; then
    # warm
    SPEED0=125
    SPEED1=100
else
    # cool
    SPEED0=100
    SPEED1=75
fi
 
 
 
if [ -f "/tmp/lasttemp" ]; then
    if [ "$(cat /tmp/lastspeed)" -ne "${SPEED1}" ]; then
        RUN=1
    fi
else
    RUN=1
fi
 
echo "${SPEED1}" > /tmp/lastspeed
 
if [ "${RUN}" -eq "1" ]; then
    # main fan (iLO/HD Controller/LAN/etc)
    ${CMD[@]} "-oControlMaster=no" -t fan p 0 max ${SPEED0};
    ${CMD[@]} "-oControlMaster=no" -t fan p 1 max ${SPEED0};
 
    # rest of the fans
    for f in `seq 2 7`; do
        ${CMD[@]} "-oControlMaster=no" -t fan p ${f} max ${SPEED1};
    done
fi

Comments