Page 3 of 5 FirstFirst 12345 LastLast
Results 21 to 30 of 50

Thread: Server auto-suspend?

  1. #21
    Join Date
    Nov 2009
    Beans
    27
    Distro
    Ubuntu 13.10 Saucy Salamander

    Lightbulb Re: Server auto-suspend?

    Quote Originally Posted by inspiral View Post
    my plan is to add the commands to the action file to put the box in suspend for a period then take it down to hibernate if not used for a further period.
    FYI this is the sequence I'm thinking of:

    • zero wake alarm timer
    • set wake alarm timer
    • suspend
    • box will then either be awoken via button, keyboard , WOL or alarm
    • check if woken early
    • hibernate if false
    • exit script if true

    This will only work if the 'action' script continues to run once awoken from suspend.

    At mo I know how to do everything apart from check to see if the box is woken early but think this'll probably be possible by comparing the current time against the alarm time.

    I'm going to extract the alarm relevant cmds from the following script:

    http://people.canonical.com/%7Eapw/s...e/test-suspend

    # Request wakeup from the RTC or ACPI alarm timers. Set the timeout
    # at 'now' + $timeout seconds.
    #
    ctl='/sys/class/rtc/rtc0/wakealarm'
    if [ -f "$ctl" ]; then
    time=`date '+%s' -d "+ $timeout seconds"`
    # Cancel any outstanding timers.
    echo "0" >"$ctl"
    # rtcN/wakealarm uses absolute time in seconds
    echo "$time" >"$ctl"
    return 0
    fi
    ctl='/proc/acpi/alarm'
    if [ -f "$ctl" ]; then
    echo `date '+%F %H:%M:%S' -d '+ '$timeout' seconds'` >"$ctl"
    return 0

    Thanks to the original authors

    I'm going to test all this manually first, I'll post the results once done.

  2. #22
    Join Date
    Dec 2007
    Location
    Newcastle-upon-Tyne - UK
    Beans
    109
    Distro
    Kubuntu 10.04 Lucid Lynx

    Re: Server auto-suspend?

    Inspiral,

    I like your thinking!
    I'm playing with a basic action script right now which just pm-suspends after 10 minutes of inactivity; I've set smb,nfs,ssh as events for monitoring. I've just got my Kubuntu client to finally auto login to the server and suspend the NAS without passwords
    With some more tweaking, this could work out well!
    I'll get back to you this week with a final analysis.

  3. #23
    Join Date
    Nov 2009
    Beans
    27
    Distro
    Ubuntu 13.10 Saucy Salamander

    Thumbs up Re: Server auto-suspend?

    Weahay, I got all it all working, may not be especially elegant but it works, just add it to the end of the powernap action script:

    #
    LOGDIR='/etc/powernap'
    LOGFILE="$LOGDIR/suspend_then_hibernate.log"
    # Clear logfiles
    cp /dev/null $LOGFILE
    cp /dev/null $LOGFILE".debug"
    exec 1>$LOGFILE
    # Send debug output to debug log
    exec 2>$LOGFILE".debug"

    setup_wakeup_timer ()
    {
    #Change this value to vary the time(in seconds) suspended
    suspend_timeout="60"

    #
    # Request wakeup from the RTC or ACPI alarm timers. Set the timeout
    # at 'now' + $suspend_timeout seconds.
    #
    ctl='/sys/class/rtc/rtc0/wakealarm'
    if [ -f "$ctl" ]; then
    wake_time=`date '+%s' -d "+ $suspend_timeout seconds"`
    # Cancel any outstanding timers.
    echo "0" >"$ctl"
    # rtcN/wakealarm uses absolute time in seconds
    echo "$wake_time" >"$ctl"
    return 0
    fi
    ctl='/proc/acpi/alarm'
    if [ -f "$ctl" ]; then
    echo `date '+%F %H:%M:%S' -d '+ '$suspend_timeout' seconds'` >"$ctl"
    return 0
    fi

    echo "no method to awaken machine automatically" 1>&2
    exit 1
    }

    suspend_system ()
    {
    echo "Nobody using me so I'll suspend for the time being"
    pm-suspend >> "$LOGFILE"
    }

    awoken_early ()
    # Did I awake early ?
    {
    grace="5"
    time_now=`date '+%s' #-d "+ $grace seconds"`

    if [ "$time_now" -le "$wake_time" ]; then
    echo "Awoken early so I won't hibernate as somebody wants me"
    exit 1
    fi
    }

    hibernate_system ()
    {
    echo "Nobody wanted me in the suspend period so I'll hibernate"
    pm-hibernate >> "$LOGFILE"
    }

    # Run the scripts
    setup_wakeup_timer
    suspend_system
    awoken_early
    hibernate_system
    Last edited by inspiral; December 14th, 2009 at 11:58 PM.

  4. #24
    Join Date
    Nov 2009
    Beans
    27
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Server auto-suspend?

    Oh dear the forum ate my indenting
    Last edited by inspiral; December 14th, 2009 at 11:55 PM.

  5. #25
    Join Date
    Dec 2007
    Location
    Newcastle-upon-Tyne - UK
    Beans
    109
    Distro
    Kubuntu 10.04 Lucid Lynx

    Re: Server auto-suspend?

    Quote Originally Posted by inspiral View Post
    Oh dear the forum ate my indenting
    So, what exactly do you have working here? My script writing skills are minimal!

  6. #26
    Join Date
    Nov 2009
    Beans
    27
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Server auto-suspend?

    When powernap decides the system is not being used to do the following via the action script:

    • zero wake alarm timer
    • set wake alarm timer to bring the system back up in x seconds
    • suspend
    • system will then either be awoken by the power button, keyboard , WOL or the alarm
    • check if woken early ie. anything other than the alarm
    • if woken early exit action script and leave system up
    • if not woken early hibernate
    • system can then either be awoken by the power button, keyboard or WOL and when this happens powernap will start monitoring system use from scratch again


    This allows the system to suspend for short periods and to be brought back up quickly when you need it but when left unused for longer periods go into hibernate which saves more power but takes a bit longer to come back up.

    Make sense ?

    How are you getting on identifying processes that show the system in being used ?

    Cheers
    Last edited by inspiral; December 15th, 2009 at 10:27 AM.

  7. #27
    Join Date
    Dec 2007
    Location
    Newcastle-upon-Tyne - UK
    Beans
    109
    Distro
    Kubuntu 10.04 Lucid Lynx

    Re: Server auto-suspend?

    I just run 'ps' and picked off some running processes which I believe are required for my use; i.e. smbd,nfsd etc.
    I've placed them in the powernap config file. This did work for samba and ssh and login but doesn't seem to work for nfsd. I need to check further.
    Thanks for the info!

  8. #28
    Join Date
    Nov 2009
    Beans
    27
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Server auto-suspend?

    Hmmm I tried adding just 'smbd' to the powernap config file and powernap just kept finding it regardless of being used or not by a remote(XP in my case) computer, I didn't try 'smb'.

    Are your other computers running linux or some form of windows ? I thought that linux doesn't need Samba, I could be wrong though...What do you use nfsd for ?

    btw do you use Squeezbox ?

  9. #29
    Join Date
    Nov 2009
    Beans
    27
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Server auto-suspend?

    Quote Originally Posted by Muttley99 View Post
    I just run 'ps' and picked off some running processes which I believe are required for my use; i.e. smbd,nfsd etc.
    I've placed them in the powernap config file. This did work for samba and ssh and login but doesn't seem to work for nfsd. I need to check further.
    Thanks for the info!
    Actually when you say 'seem to work' what do you mean, that powernap saw the processes in use and started the countdown to action once the processes stopped being used ? And did you systematically go through each access method ?

  10. #30
    Join Date
    Dec 2007
    Location
    Newcastle-upon-Tyne - UK
    Beans
    109
    Distro
    Kubuntu 10.04 Lucid Lynx

    Re: Server auto-suspend?

    I may give it a go tonight!
    If i'm logged in to the server Powernap doesn't suspend - even without activity. I have a windows 7 netbook (hence the samba) and a kubuntu desktop (nfs). The desktop autofs mounts nfs shares on startup. The server doesn't suspend while connected to nfs BUT doesn't suspend after nfs disconnection either.
    I need to play around with the settings because last week I had it suspending five minutes after my kubuntu destop shutdown. I'm an idiot! should have saved the config file while at that state!

Page 3 of 5 FirstFirst 12345 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •