HDD Auto spinup on Plex container activity


mgutt

28 posts in this topic Last Reply

Recommended Posts

I'm trying to use this script to spin up the drives to avoid the Emby coverart loading time. However, when I try to run the script, I get the following error: /tmp/user.scripts/tmpScripts/emby_monitoring_spinup/script: line 18: mdcmd: command not found

 

Right now, I'm just running it to test using the CA User Scripts "Run Script" option.

 

Any ideas why it's reporting mdcmd not being found? I did try to run mdcmd status | grep "rdevLastIO.1}=" | cut -d '=' -f 2 | tr -d '\n' from the webterminal and that worked fine.

Link to post

That is the error: /tmp/user.scripts/tmpScripts/emby_monitoring_spinup/script: line 18: mdcmd: command not found

 

Quote

Script location: /tmp/user.scripts/tmpScripts/emby_monitoring_spinup/script
Note that closing this window will abort the execution of this script
Container's CPU load exceeded threshold
/tmp/user.scripts/tmpScripts/emby_monitoring_spinup/script: line 18: mdcmd: command not found
/tmp/user.scripts/tmpScripts/emby_monitoring_spinup/script: line 18: mdcmd: command not found
/tmp/user.scripts/tmpScripts/emby_monitoring_spinup/script: line 18: mdcmd: command not found
/tmp/user.scripts/tmpScripts/emby_monitoring_spinup/script: line 18: mdcmd: command not found
/tmp/user.scripts/tmpScripts/emby_monitoring_spinup/script: line 18: mdcmd: command not found
/tmp/user.scripts/tmpScripts/emby_monitoring_spinup/script: line 18: mdcmd: command not found
/tmp/user.scripts/tmpScripts/emby_monitoring_spinup/script: line 18: mdcmd: command not found
Container's CPU load exceeded threshold
/tmp/user.scripts/tmpScripts/emby_monitoring_spinup/script: line 18: mdcmd: command not found
/tmp/user.scripts/tmpScripts/emby_monitoring_spinup/script: line 18: mdcmd: command not found
/tmp/user.scripts/tmpScripts/emby_monitoring_spinup/script: line 18: mdcmd: command not found
/tmp/user.scripts/tmpScripts/emby_monitoring_spinup/script: line 18: mdcmd: command not found
/tmp/user.scripts/tmpScripts/emby_monitoring_spinup/script: line 18: mdcmd: command not found
/tmp/user.scripts/tmpScripts/emby_monitoring_spinup/script: line 18: mdcmd: command not found
/tmp/user.scripts/tmpScripts/emby_monitoring_spinup/script: line 18: mdcmd: command not found

 

Only difference to your original script, was that I changed it to monitor for Emby rather than Plex.

 

Quote

 

#!/bin/bash

# make script race condition safe
if [[ -d "/tmp/${0///}" ]] || ! mkdir "/tmp/${0///}"; then exit 1; fi
trap 'rmdir "/tmp/${0///}"' EXIT

# ######### Settings ##################
spinup_disks='1,2,3,4,5,6,7' # Note: Usually parity disks aren't needed for Plex
cpu_threshold=1 # Disks spin up if Plex container's CPU load exceeds this value
# #####################################

# ######### Script ####################
while true; do
    plex_cpu_load=$(docker stats --no-stream | grep -i emby | awk '{sub(/%/, "");print $3}')
    if awk 'BEGIN {exit !('$plex_cpu_load' > '$cpu_threshold')}'; then
        echo "Container's CPU load exceeded threshold"
        for i in ${spinup_disks//,/ }; do
            disk_status=$(mdcmd status | grep "rdevLastIO.${i}=" | cut -d '=' -f 2 | tr -d '\n')
            if [[ $disk_status == "0" ]]; then
                echo "Spin up disk ${i}"
                mdcmd spinup "$i"
            fi
        done
    fi
done

 

 

Edited by PeterDB
Added the script for reference
Link to post

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.