This might be useful for you
I thought my needs were simple, but ended up with something a bit more
complicated after an evening of hacking. The python script below
identifies when the dedicated SC7 box is "idle" (eligible for
suspend/hibernate). Run with "--help" option for usage info.
Works for me on CentOS 5 and I am using it now. :) Script has lots of
internal documentation and is too long for a forum comment, so here's
the link:
- 'sc-idle.py'
(http://syburgh.com/svn/puppet/trunk/modules/squeezecenter/files/sc-idle.py)
- 'logging.ini'
(http://syburgh.com/svn/puppet/trunk/modules/squeezecenter/files/logging.ini)
(optional)
- '/etc/init.d/sc-idle'
(http://syburgh.com/svn/puppet/trunk/modules/squeezecenter/files/sc-idle.init)
(init script)
- '/etc/sysconfig/sc-idle'
(http://syburgh.com/svn/puppet/trunk/modules/squeezecenter/files/sc-idle.sysconfig)
(init script config file)
OVERVIEW
All of the following must be true for "idle" timer to begin countdown
to suspend/hibernate/shutdown:
- All connected players are idle, off, or paused
- No open interactive consoles (e.g. ssh, screen, serial, or VGA
console). This way one can run a long script (e.g. transcoding,
replaygain) using screen without the system becoming "idle"
- A specific file (/tmp/nosleep) does not exist. This makes it easy
for scripts and cron jobs to run without the system going "idle"
ONCE TIMER EXPIRES
- After first timeout expires (default is 30 min) the system will:
Enter suspend to RAM ("Suspend" in Windows, ACPI S3), from which it
can wake and play music quickly (mine resumes using WOL in <10s)
- After 2 days of "idle" state the system will wake itself using the
ACPI real time alarm and enter hibernate mode (ACPI S5), which limits
risk of a power outage during extended vacations
Both timeouts are configurable from command line and it would be pretty
easy to have the system run 'shutdown' instead of 'pm-suspend' if you
want a real shutdown.
*Example*
Using 15 second suspend and 2 min hibernate timeout (called "demo
mode", useful for debugging ACPI hardware quirks). The
"--quirk-s3-bios" bits you see are necessary to support suspend on my
specific hardware
>
> * PAUSE TRACK USING SQUEEZEBOX REMOTE*
> [EMAIL PROTECTED] ~]# /usr/local/sbin/sc-idle.py --demo
> --pm-arg=--quirk-s3-bios*
> 2008-04-02 18:55:37,921 DEBUG Configured options: {'demo_mode': True,
> 'daemon': False, 'cli_host': 'localhost', 'pid_path': None, 'pm_arg':
> '--quirk-s3-bios', 'rtc_padding': 0, 'log_config':
> '/etc/sc-idle/logging.ini', 'cli_port': 9090, 'poll_delay': 10,
> 'nosleep_path': '/tmp/nosleep', 'resume_delay': 30}
> 2008-04-02 18:55:37,922 INFO Monitor started
> 2008-04-02 18:55:37,923 DEBUG Connected cli on localhost:9090
> 2008-04-02 18:55:37,928 DEBUG Disconnected cli on localhost:9090
> 2008-04-02 18:55:37,929 DEBUG System entered idle state
> 2008-04-02 18:55:37,929 DEBUG Cannot enter hibernate (ACPI S5), need
> 0:01:59.999716
> 2008-04-02 18:55:37,930 DEBUG Cannot enter suspend (ACPI S3), need
> 0:00:14.999438
> 2008-04-02 18:55:47,928 DEBUG Connected cli on localhost:9090
> 2008-04-02 18:55:47,934 DEBUG Disconnected cli on localhost:9090
> 2008-04-02 18:55:47,934 DEBUG System has been idle for 0:00:10.005192
> 2008-04-02 18:55:47,934 DEBUG Cannot enter hibernate (ACPI S5), need
> 0:01:49.994582
> 2008-04-02 18:55:47,935 DEBUG Cannot enter suspend (ACPI S3), need
> 0:00:04.994352
> 2008-04-02 18:55:57,933 DEBUG Connected cli on localhost:9090
> 2008-04-02 18:55:57,939 DEBUG Disconnected cli on localhost:9090
> 2008-04-02 18:55:57,939 DEBUG System has been idle for 0:00:20.010272
> 2008-04-02 18:55:57,940 DEBUG Cannot enter hibernate (ACPI S5), need
> 0:01:39.989510
> 2008-04-02 18:55:57,940 INFO Enter suspend (ACPI S3) after being idle
> 0:00:20.010272
> 2008-04-02 18:55:57,940 INFO Set RTC wake alarm to '2008-04-02
> 22:57:37'
> 2008-04-02 18:57:56,353 DEBUG Return from suspend (ACPI S3), waiting 30
> sec for activity
> 2008-04-02 18:58:36,348 DEBUG Connected cli on localhost:9090
> 2008-04-02 18:58:36,353 DEBUG Disconnected cli on localhost:9090
> 2008-04-02 18:58:36,354 DEBUG System has been idle for 0:02:58.424532
> 2008-04-02 18:58:36,354 INFO Enter hibernate (ACPI S5) after being idle
> 0:02:58.424532
> * PRESS POWER ON SQUEEZEBOX REMOTE TO WAKE SQUEEZECENTER*
> 2008-04-02 19:00:35,758 DEBUG Return from hibernate (ACPI S5), waiting
> 30 sec for activity
> 2008-04-02 19:01:15,751 DEBUG Connected cli on localhost:9090
> 2008-04-02 19:01:15,756 DEBUG Disconnected cli on localhost:9090
> 2008-04-02 19:01:15,757 DEBUG System has been idle for 0:05:37.827774
> 2008-04-02 19:01:15,757 INFO Enter hibernate (ACPI S5) after being idle
> 0:05:37.827774
> * PRESS POWER ON SQUEEZEBOX REMOTE TO WAKE SQUEEZECENTER*
> 2008-04-02 19:02:40,748 DEBUG Return from hibernate (ACPI S5), waiting
> 30 sec for activity
> * UN-PAUSE TRACK USING SQUEEZEBOX REMOTE*
> 2008-04-02 19:03:20,742 DEBUG Connected cli on localhost:9090
> 2008-04-02 19:03:20,746 DEBUG SqueezeCenter players are active
> 2008-04-02 19:03:20,747 DEBUG Disconnected cli on localhost:9090
> 2008-04-02 19:03:20,747 DEBUG System left idle state
>
This works really well for me with 3 SBs, but YMMV. It's a shame the
Controller does not really support WOL yet (though it is promised for
7.1).
--
syburgh
------------------------------------------------------------------------
syburgh's Profile: http://forums.slimdevices.com/member.php?userid=14239
View this thread: http://forums.slimdevices.com/showthread.php?t=49028
_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/lists/listinfo/unix