November 2, 20241 yr I painfully discovered that my pair of UnRAID servers, one with a Chenbro 48-bay chassis and the other with a SuperMicro 36-bay chassis, both sporting SuperMicro MoBo's, use up a ton of electricity when kept running 24/7, even with the drives spun-down, because the chassis fans continue to spin full blast. I'm burning through approximately 2kW just during the night; I was told by the local electric company rep that the average is 0.13kW. With my huge electric bills paid off (and I have a 1400kW solar array), I'm now manually shutting down my servers when they are no longer in use. However, I do occassionaly forget as I leave them unattended during large file transfers and realize my mistake the next day. Are there any auto shutdown scrips or plug-ins that will power-down UnRAID after a specified period of activity? My Google-Fu doesn't appear to be up-to-snuff as I get old general answers and references with no verifiable working script or plug-in. And as the chassis's I use have independent case fans that can't be controlled by their MoBo's, S3 solutions would not appear to work for me.
November 3, 20241 yr Community Expert you would have to run a user script to acomplish this. This sound more like when idle go into stadby and have a network with WOL to then send a WOL when its bee asked to do a task such as access a share or service. WOL may requries specailed hardware to handle the WOL packets: It sounds like you are running enterpirse hardware if fan control is what you need i would sugest this plugin to help dial the fans back: Potential look into you bios / impmi depending on hardware... Otherwise, it sounds like you need autotweak to access other power options...
November 3, 20241 yr Community Expert This is a common challenge with high-capacity server setups, especially with power-hungry components and fan-heavy chassis that don't scale down with system load. Shutting down the server during inactive periods could indeed save a significant amount on electricity bills, even with solar. To automate power-down for Unraid, here are some strategies you could explore: User Scripts Plugin: This Unraid plugin allows custom scripts to be scheduled to run at specified times or in response to specific events. You could write a script to check server activity, such as CPU load, network traffic, or disk usage, and shut down the server after a period of inactivity. CA Auto Turbo Write Mode Plugin: While this plugin’s primary purpose is to dynamically control Unraid’s write modes, you could repurpose parts of it to help manage other aspects of your server’s power state. Nerd Tools Plugin with Advanced Power Management: Some users find success with specific packages from Nerd Tools, like atop or iftop, which can monitor server usage and potentially help trigger shutdown scripts. (extra app install) Power Off via SSH: If you have another system running continuously (like a low-power Raspberry Pi or similar), you could set it to periodically check the activity on your server and trigger a power-off via SSH if conditions are met. (Home assistant docker / unraid connect) UPS Integration with a Conditional Shutdown: If you have a UPS, you can use it to monitor the power state and trigger conditional shutdowns. The NUT (Network UPS Tools) can be configured to monitor system load and initiate shutdown sequences when activity falls below a certain threshold. Docker Solutions: Some Docker containers can run monitoring scripts to handle these functions. Containers like telegraf and Grafana with custom scripts can monitor activity levels and call Unraid’s shutdown command when idle. The biggest challenge is managing the fans since S3 sleep won’t help in your case. Your best bet might be experimenting with custom monitoring scripts to determine idle states and initiating power-down that way.
November 3, 20241 yr Community Expert Here's an example of a custom script that will monitor CPU load and network activity on your Unraid server. If the load remains below a specified threshold for a set period, the script will automatically shut down the server. This script is intended to run periodically (every few minutes) via the User Scripts plugin. Auto-Shutdown Script CPU Load Threshold: Set the max load under which the server is considered "idle." Network Activity Threshold: Set the max network usage (in KB/s) considered "idle." Inactivity Duration: Time (in seconds) the server must be idle before shutdown. auto_shutdown.sh #!/bin/bash # Configuration CPU_THRESHOLD=0.1 # CPU load threshold to consider "idle" NET_THRESHOLD=10 # Network usage threshold in KB/s INACTIVITY_DURATION=600 # Time in seconds to be idle before shutdown (e.g., 10 minutes) LOG_FILE="/var/log/auto_shutdown.log" # Function to get average CPU load for the last minute get_cpu_load() { awk '{print $1}' < /proc/loadavg } # Function to get network usage (sum of received/transmitted bytes) in KB/s get_network_usage() { RX1=$(cat /sys/class/net/eth0/statistics/rx_bytes) TX1=$(cat /sys/class/net/eth0/statistics/tx_bytes) sleep 1 RX2=$(cat /sys/class/net/eth0/statistics/rx_bytes) TX2=$(cat /sys/class/net/eth0/statistics/tx_bytes) RX_DIFF=$(( (RX2 - RX1) / 1024 )) TX_DIFF=$(( (TX2 - TX1) / 1024 )) echo $((RX_DIFF + TX_DIFF)) } # Check for inactivity start_time=$(date +%s) while true; do cpu_load=$(get_cpu_load) net_usage=$(get_network_usage) if (( $(echo "$cpu_load < $CPU_THRESHOLD" | bc -l) )) && (( net_usage < NET_THRESHOLD )); then current_time=$(date +%s) elapsed_time=$((current_time - start_time)) if (( elapsed_time >= INACTIVITY_DURATION )); then echo "$(date): System is idle. Shutting down..." >> "$LOG_FILE" poweroff fi else echo "$(date): Activity detected - CPU load: $cpu_load, Network: $net_usage KB/s" >> "$LOG_FILE" start_time=$(date +%s) fi # Run every 60 seconds sleep 60 done Make executable: chmod +x auto_shutdown.sh Schedule it using the Unraid User Scripts plugin to run periodically, such as every 5 minutes. https://crontab.guru/ 5 * * * * Explanation of Key Parts get_cpu_load(): Fetches the 1-minute CPU load average. get_network_usage(): Monitors network activity by checking received/transmitted bytes over 1 second. Inactivity Check: The script checks if CPU and network usage stay below thresholds. If these conditions persist for the specified INACTIVITY_DURATION, the system shuts down. Logging: Logs activity and shutdown actions to /var/log/auto_shutdown.log for tracking. This setup ensures your server only powers down when it's truly idle, saving energy without interrupting activity. Adjust thresholds and duration as needed for your use case.
November 4, 20241 yr Author On 11/2/2024 at 7:58 PM, bmartino1 said: you would have to run a user script to acomplish this. This sound more like when idle go into stadby and have a network with WOL to then send a WOL when its bee asked to do a task such as access a share or service. WOL may requries specailed hardware to handle the WOL packets: Hmm... I'm not sure the WOL solutions would work for these commercial-grade high-capacity server chassis as it appears the case fans are not controlllable by the MoBo? It's been years since I've assembled these servers but I believe there are no fan controller wires from the case that plug into associated header pins on the MoBo, so that would suggest the case fans are independently controlled (if that) by any logic boards organic to the case. When the chassis is powered on, the case fans run full blast constantly, no matter if all drives spin-down or the MoBo is in some sort of sleep mode. Edited November 4, 20241 yr by Auggie
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.