Author Topic: MD idle shutdown?  (Read 3977 times)

mkbrown69

  • Guru
  • ****
  • Posts: 213
    • View Profile
MD idle shutdown?
« on: April 21, 2012, 01:28:00 am »
Good day folks!

I've noticed that when the core restarts, it wakes up the MD's.  Given that they stay running, I'm presuming that there isn't an idle shutdown/sleep function, correct?  I'm just trying to confirm that it doesn't have an idle shutdown;  if it does exist, then I'll have to figure out why it's not working...

I'm running 10.04.

Thanks for your time!

/Mike

JaseP

  • Addicted
  • *
  • Posts: 526
    • View Profile
    • JaseP's LinuxMCE Wiki User page
Re: MD idle shutdown?
« Reply #1 on: April 21, 2012, 02:17:57 am »
It's apparently in there, but it's imperfect & requires user intervention to work, at least as of the date of publication of this wiki on 8.10,... and probably not working much better in 10.04. It's of interest to me too... So, so if you make any progress, please post about your success.

See here:
http://wiki.linuxmce.org/index.php/Suspend
See my User page on the LinuxMCE Wiki for a description of my system configuration (click the little globe under my profile pic).

sambuca

  • Guru
  • ****
  • Posts: 462
    • View Profile
Re: MD idle shutdown?
« Reply #2 on: April 23, 2012, 08:54:19 am »
I'm just trying to confirm that it doesn't have an idle shutdown;
No. There is no idle shutdown.

But you can manually suspend MDs, as JaseP mentiones. If you look at the article he linked, you will find how to set it up. The reason you have to manually set this up, is that not all hardware(drivers) play nice when suspended and resumed. So by default, we use power off instead of suspend. Simply change the PowerOffMode device data for the MD in question to "S", reload, and power the MD down from the orbiter.

br,
sambuca

davegravy

  • Addicted
  • *
  • Posts: 551
    • View Profile
Re: MD idle shutdown?
« Reply #3 on: April 23, 2012, 03:24:02 pm »
MDs do turn off their display/receiver after idle time-out, so presumably the idle-detection code is there and can be extended to do what you want.

mkbrown69

  • Guru
  • ****
  • Posts: 213
    • View Profile
Re: MD idle shutdown?
« Reply #4 on: April 23, 2012, 03:52:31 pm »
Thanks for the pointers, guys!

I'll dig into it a bit further when I get a bit of free time.  I'll probably post a bash script I use in Minimyth to shutdown a slave backend, so if someone else decides to pursue this as well, they can take some of those factors into account (i.e. don't shutdown if recording/transcoding/commflagging, etc).

Thanks again!

/Mike


JaseP

  • Addicted
  • *
  • Posts: 526
    • View Profile
    • JaseP's LinuxMCE Wiki User page
Re: MD idle shutdown?
« Reply #5 on: April 23, 2012, 05:47:55 pm »
If the motivation is "green" energy savings, .... You might want to look at Jupiter:
http://www.jupiterapplet.org/

But it might interfere with LinuxMCE's X-server management ... But, worth a shot...

See my User page on the LinuxMCE Wiki for a description of my system configuration (click the little globe under my profile pic).

mkbrown69

  • Guru
  • ****
  • Posts: 213
    • View Profile
Re: MD idle shutdown?
« Reply #6 on: April 24, 2012, 04:52:31 am »
JaseP,

Thanks for the pointer.  I'm not looking for that so much as for the usual kids leaving it on, or the auto-wake when the router reloads.

I'm using MiniMyth right now, and use a script to shutdown a slave backend when it's sitting on the MythWelcome screen.  I'd planned to expand it to look at how long the screensaver was running for, but haven't gotten around to it yet.

For anyone who's interested, here's the script...

Code: [Select]
#!/bin/bash
#
# Script to safely shutdown slave backend
# Minimum uptime in minutes to avoid shutting down prematurely.
MIN_UPTIME=20
#SHUTDOWNCMD="su -c /usr/bin/mm_sleep root"
SHUTDOWNCMD="/sbin/poweroff"

date

UPTIME=`uptime |cut -f4 -d" "`
UPTIME_UNITS=`uptime |cut -f5 -d" " |tr -d ','`

echo "Uptime:" $UPTIME $UPTIME_UNITS

if [[ $UPTIME_UNITS == "min" ]] && [[ $UPTIME -lt $MIN_UPTIME ]]
    then
echo "Uptime less than minimum uptime:" $MIN_UPTIME
exit 1
fi

# Check if mythfrontend is running, exit if true
if ps -C mythfrontend | grep mythfrontend -c
then
echo "Mythfrontend running, shutdown aborted"
exit 1
fi


mythshutdown -s
STATUS=$?

echo "MythStatus code:" $STATUS
#   0 - Idle
#                         1 - Transcoding
#                         2 - Commercial Flagging
#                         4 - Grabbing EPG data
#                         8 - Recording - only valid if flag is 1
#                        16 - Locked
#                        32 - Jobs running or pending
#                        64 - In a daily wakeup/shutdown period
#                       128 - Less than 15 minutes to next wakeup period
#                       255 - Setup is running

case "$STATUS" in

  0)
echo "Myth is idle, shutting down now"
mythshutdown --setscheduledwakeup
        su -c 'rm /etc/rc.d/rc/K60modules_automatic' root
        mm_service backend stop
        `$SHUTDOWNCMD`
  ;;

  8|40)
        echo "Myth is busy recording"
        exit 1
  ;;

  16)
        echo "Myth is locked, aborting shutdown"
        exit 1
  ;;


  32|33|34|35)
        echo "Jobs running"
        # Check if mythcommflag is running locally, exit if true
        if ps -C mythcommflag | grep mythcommflag -c
            then
                echo "Mythcommflag running, shutdown aborted"
                exit 1
        fi
        # Check if mythtranscode is running locally, exit if true
        if ps -C mythtranscode | grep mythtranscode -c
            then
                echo "Mythtranscode running, shutdown aborted"
                exit 1
        fi
        # This backend isn't busy with jobs, so shutdown
        echo "This backend is idle, shutting down now"
        mythshutdown --setscheduledwakeup
        su -c 'rm /etc/rc.d/rc/K60modules_automatic' root
        mm_service backend stop
        `$SHUTDOWNCMD`

    ;;


  64|128)
        echo "Awake on purpose"
        exit 1
    ;;

    *)
        echo "Busy with unknown tasks, presume this backend is busy"
        exit 1
        ;;
esac


Hope that helps fuel someone's creativity should they get around to this before I do (which is more than likely as my course runs till mid May)

/Mike