Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional Commands #1

Open
C4Wiz opened this issue Nov 5, 2023 · 8 comments
Open

Additional Commands #1

C4Wiz opened this issue Nov 5, 2023 · 8 comments
Assignees
Labels
question Further information is requested

Comments

@C4Wiz
Copy link

C4Wiz commented Nov 5, 2023

is there a command to get current pwm percent?

it is visible in the dashboard, but i cannot figure out how to pull it from ipmitool

@White-Raven
Copy link
Owner

White-Raven commented Nov 12, 2023

Afaik the % is only from the front-end of the dashboard and not something you can pull from iDrac.

If you need the %, you can still somewhat obtain it though.

ipmitool -I lanplus -H X.X.X.X -U Administrator -P XXXXXXXXXX sdr type fan for example, will provide you with the raw RPM of the fans at the time, in that kind of format:

Fan1 RPM         | 30h | ok  |  7.1 | 2160 RPM
Fan2 RPM         | 31h | ok  |  7.1 | 2040 RPM
Fan3 RPM         | 32h | ok  |  7.1 | 2160 RPM
Fan4 RPM         | 33h | ok  |  7.1 | 2040 RPM
Fan5 RPM         | 34h | ok  |  7.1 | 2160 RPM
Fan6 RPM         | 35h | ok  |  7.1 | 2040 RPM
Fan Redundancy   | 75h | ok  |  7.1 | Fully Redundant

I'll take as example my R720.
The minimum rated speed the fans will run at is 840RPM. (600RPM is when it will throw an error for fan failure)
Rated max speed is 15000RPM.

So what I would do is go:

function calculate_percent() {
    local data="$1"
    local max_rated_rpm="$2"
    local min_rated_rpm="$3"
    # Initialize the RPM values array
    declare -a rpm_values=()
    # Iterate over each line
    while IFS= read -r line; do
        # Check if the line contains "ok" and "RPM"
        if [[ $line =~ "ok" && $line =~ "RPM" ]]; then
            # Extract numeric RPM values and add to the array
            rpm_values+=($(echo "$line" | awk -F'|' '{gsub(/[^0-9]/, "", $NF); print $NF}'))
        fi
    done <<< "$data"
    # Check if any non-empty line does not contain "ok"
    if echo "$data" | awk 'NF > 0 && !/ok/' | grep -q .; then
        echo "Fan Failure"
        exit
    else
        # Calculate average RPM
        if [ "${#rpm_values[@]}" -eq 0 ]; then
            echo "Invalid Data"
            exit
        else
            sum=0
            count=0
            for rpm in "${rpm_values[@]}"; do
                sum=$((sum + rpm))
                count=$((count + 1))
            done
            average=$((sum / count))
            # Bad math
            percent=$(($(($(($average - $min_rated_rpm)) * 100 / $(($max_rated_rpm - $min_rated_rpm))))))
            echo "$percent"
        fi
    fi
}
# Example usage:
# we get the bunch of data:
data=$(ipmitool -I lanplus -H X.X.X.X -U Administrator -P XXXXXXXXXX sdr type fan)
# or use a bunch of test data:
# data="
# Fan1 RPM         | 30h | ok  |  7.1 | 14280 RPM
# Fan2 RPM         | 31h | ok  |  7.1 | 14160 RPM
# Fan3 RPM         | 32h | ok  |  7.1 | 14520 RPM
# Fan4 RPM         | 33h | ok  |  7.1 | 14400 RPM
# Fan5 RPM         | 34h | ok  |  7.1 | 14280 RPM
# Fan6 RPM         | 35h | ok  |  7.1 | 14400 RPM
# Fan Redundancy   | 75h | ok  |  7.1 | Fully Redundant
# "


# know values to provide depending the type of fans you have
MaxRatedRPM=15000
MinRatedRPM=840

result=$(calculate_percent "$data" "$MaxRatedRPM" "$MinRatedRPM")
if ! [[ "$result" =~ ^[0-9]+$ ]]; then
    echo "Error: $result"
    exit 1  # Terminate the script with an error code
fi
echo "Percentage: $result%"
exit 0

Do note though that each fan isn't running exact spot-on speeds to its neighbor, hence why trying to average, so resulting % might deviate slightly from the % you just set them to run at.

If you want to use that % to have your script able to decide or not if it's worth to actualize fan speed depending if it's the next step over, you have to build a proportional allowed ignored deviation compared to the hard step speeds. 1 or 2% should do okay at low speed.

Where at 6% my fans run 1800-1920 (which can report 6 or 7%), while at 100%, they run 14160-14520, which usually averages around 95%, so yeah, even though you get the real-world %, it isn't accurate to the IPMI-defined fan speed.
I know technically the operation I make to get a % is also "bad math" but it's the closest I would get without actually trying to think too hard about it.

HP's IPMI for example reports % straight up. Dell's is RPM :/

@White-Raven White-Raven self-assigned this Nov 12, 2023
@White-Raven White-Raven added help wanted Extra attention is needed question Further information is requested and removed help wanted Extra attention is needed labels Nov 12, 2023
@C4Wiz
Copy link
Author

C4Wiz commented Nov 12, 2023

thank you so much for this.

i don't know if you are familiar with unRAID, but i an running it on a R530 and im trying to adapt your script to change fan speeds based on HDD temps with a override for max cpu temp. but my bash is not so good

@C4Wiz
Copy link
Author

C4Wiz commented Nov 12, 2023

here is the current fan control script for unRAID, but it is based on PWM control. i was trying to modify it to use the ipmi commands but i got confused.

https://raw.githubusercontent.com/bergware/dynamix/master/source/system-autofan/scripts/autofan

@White-Raven
Copy link
Owner

I'm familiar with unRAID, but not with the autofan thing as indeed, it didn't serve me on my R720.

I was working on and off on a V2 of my script that would allow to take in account HDD and GPU temps too, sadly I kinda shelved it and don't know if I'll get around to finish that rework as I have decommissioned my aging, power hungry, compute-lacking Dell hardware for a more power-efficient (and powerful) whitebox server I built in a supermicro case.

I haven't checked if the R530 has both inlet and exhaust sensors, but you could try to repurpose the ambient temp logic onto HDD temps instead.
Or as an alternative in the meantime, trying to find a fan curve stepping that would bottom at a fan-speed that kinda insure HDDs are staying within acceptable ranges.

If I get time to go over the V2 rework and finish it, I'll make it known here.

@Grand-Cherokee
Copy link

Grand-Cherokee commented Nov 12, 2023 via email

@C4Wiz
Copy link
Author

C4Wiz commented Nov 12, 2023

can you add a v2 repo? and add what you have so far?

@Nobodysbetter
Copy link

+1 (have 730 and 630 and trying to learn what I can)

@Grand-Cherokee
Copy link

umm ya, sounds necessary. In fact I have rethought how to implement and am down a significantly different path now to warrant an upgrade to my notes.
The only programming language I can remember is "Basic" from my commodore VIC20 and IBM 8088 Mainframe (yup a computer that took up large floor space in the college I attended) days some 30+ years ago. I read alot hoping that something will spark a new memory. Having a stroke sucks! Its feels something like something thats on the tip of you tongue.
Shell scripts seem very similar so I cant decide which to use.
Which do you prefer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants