Skip to main content

Troubleshooting the redstone D2020, part 2

·453 words
Author
Julia Desmazes

Introduction #

This article serves as a quick follow-up to the previous post on Troubleshooting the Redstone D2020. Its goal is to provide a straightforward solution for adjusting the fan speed of the switch.

Dealing with a Noisy Switch #

If your dream is to live in a server room, then the Celestica Redstone D2020, available for around $300 on eBay, might be the right choice for you. However, for the rest of us who prefer a quieter environment, finding a way to reduce the fan noise is crucial for making the most out of this purchase.

Switch
Celestical Redstone D2020

Solution #

The purpose of this script is to make the switch quieter by adjusting the fan speed. This fan speed can be modified by resetting its pwm in the associated Linux configuration file.

By default, I connect to the switch via telnet and log in to a custom cli rather than a Linux shell.

Privilege escalation using the CLI to get the root linux shell.

As a result, the first step is to escalate from the cli to the Linux shell.

To automate the interaction with the telnet text interface, I use a tcl package called expect. The tcl portion of the script is named silence.expect and is invoked by the bash entry point called silence.sh.

Essenceia/switch_scripts

Switch utilities scripts for the D2020.

Shell
0
0

silence.sh #

This Bash script begins by sourcing configurations from the config.sh file, which includes the switch’s hostname, username/password, and the target pwm. The config.sh file is not included in the repository by default, but users can find an example file called config_example.sh and rename it to config.sh once modified.

Next, it invokes the tcl script with these configurations.

#!/bin/bash

# configuation file
CONFIG=config.sh

# Source username and password
if [ ! -f $CONFIG ]; then
    echo "File $CONFIG not found."
	exit 1
fi
source $CONFIG
printf "sourcing configuration file, set variables :\nhostname:$HOST\nuser:$USER\npassword:$PW\ntarget pwm:$PWM\n"

# Call expect on switch and shut it up
expect switch.expect $HOST $PWM $USER $PW 

silence.expect #

This tcl script manages the connection to the switch via telnet, handles privilege escalation from the cli to the Linux bash, and ultimately writes the new fan pwm values.

#!/usr/bin/expect
set timeout 20
set hostName [lindex $argv 0]
set pwm [lindex $argv 1]
set userName [lindex $argv 2]
set password [lindex $argv 3]

spawn telnet $hostName
expect "Trying $hostName..."
expect "Connected to $hostName."
expect "Escape character is '^]'."
expect ""
expect "User:"
send "$userName\r"
expect "Password:"
send "$password\r";
send "enable\r"
send "linuxsh\r"
expect "#"
send "echo $pwm > /sys/class/thermal/manual_pwm\r"
send "exit\r"
expect "Connection closed by foreign host."
send "quit\r"
send "quit\r"
interact

Additional Documentation #

For further information on the expect package, refer to Expect.