<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>doomclaw.de &#187; server</title>
	<atom:link href="http://doomclaw.de/index.php/tag/server/feed/" rel="self" type="application/rss+xml" />
	<link>http://doomclaw.de</link>
	<description>here be daemons</description>
	<lastBuildDate>Sat, 24 Mar 2012 14:47:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Dynamic server wakeup and sleep</title>
		<link>http://doomclaw.de/index.php/2010/11/24/dynamic-server-wakeup-and-sleep/</link>
		<comments>http://doomclaw.de/index.php/2010/11/24/dynamic-server-wakeup-and-sleep/#comments</comments>
		<pubDate>Wed, 24 Nov 2010 05:26:34 +0000</pubDate>
		<dc:creator>skaven</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[openwrt]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[suspend]]></category>
		<category><![CDATA[wakeup]]></category>

		<guid isPermaLink="false">http://doomclaw.de/?p=207</guid>
		<description><![CDATA[I&#8217;m running a FreeBSD server at home. Since I wanted to save some energy I decided to turn it off when all clients are diconnected and turn it on again when a client starts up. So here is how I did this. I&#8217;ve got a Linksys WRT54GL running OpenWRT for DHCP, DNS and wireless access. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m running a FreeBSD server at home. Since I wanted to save some energy I decided to turn it off when all clients are diconnected and turn it on again when a client starts up. So here is how I did this.</p>
<p>I&#8217;ve got a Linksys WRT54GL running OpenWRT for DHCP, DNS and wireless access. OpenWRT uses dnsmasq for serving DHCP and DNS and therefore is capable of executing a custom program when giving a lease to a client computer.</p>
<p>You just need to edit the <em>/etc/dnsmasq.conf</em> and add a line like this:</p>
<pre class="brush:text">
dhcp-script=/bin/serverwakeup
</pre>
<p>The file <em>/bin/serverwakeup</em> is a simple shell script containing the following lines:</p>
<pre class="brush:bash">
#!/bin/sh
sleep 10
hosts_up=`egrep -c 'edison|newton' /var/dhcp.leases` # change clients names

if [ $hosts_up -ge 1 ]; then
        wol xx:xx:xx:xx:xx:xx # put MAC address of your server here
fi
</pre>
<p>Since I wanted to start the server only if specific clients are started I decided to filter for the wanted clients before running the WOL functionality. I&#8217;m filtering this in the leases file of dnsmasq. The script will wait for 10 seconds after being invoked,so that dnsmasq got more than enough time to write the <em>/etc/dhcp.leases</em>. When you take a look at this file you will find all active leases including the corresponding hostnames. The clients  I wanted are named &#8216;edison&#8217; and &#8216;newton&#8217;. So the script looks for these names in the leases file and counts the number of occurences. When the count is greater or equal 1, the WOL command is invoked.</p>
<p>To shutdown the server after the last client disconnects I placed the follwing script on my server:</p>
<pre class="brush:bash">
#!/bin/sh
scp root@popow /var/dhcp.leases /tmp/
hosts_up=`egrep -c 'edison|newton' /tmp/dhcp.leases` # change clients names
rm /tmp/dhcp.leases
if [ $hosts_up -lt 1 ]; then
        acpiconf -s 4
fi
</pre>
<p>This script does nearly the same as the script above.It checks the leases file on the OpenWRT router (named &#8216;popow&#8217;) and checks for the clients. If the value of leases fo these clients is less than 1 it invokes the supend command (<em>acpiconf -s 4</em>), which puts the server in S4 state (supend-to-disk).<br />
This script needs to be invoked from time to time to check for the hosts. So I created a cronjob by adding the following lines to <em>/etc/crontab</em>.</p>
<pre class="brush:text">
#
# Suspend to disk when no other valuable host is online anymore
*/5     *       *       *       *       root    /usr/local/bin/suspender
</pre>
<p><strong>Update:</strong><br />
I&#8217;ve slightly updated the suspender script to reduce the load on the router. The server doesn&#8217;t use the router resources to check the leases file anymore. Instead it gets the file from the router, checks it by itself and deletes it afterwards.</p>
<p>Two other things I&#8217;ve missed to mention:</p>
<ul>
<li>You need to have the wol-Package installed on your WRT (<em>opkg install wol</em>).</li>
<li>You need to have the public SSH key of your server in the authorized_keys file of your router.</li>
</ul>
<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:100px;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fdoomclaw.de%2Findex.php%2F2010%2F11%2F24%2Fdynamic-server-wakeup-and-sleep%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe></div><div class="really_simple_share_google1" style="width:90px;"><div class="g-plusone" data-size="medium" data-href="http://doomclaw.de/index.php/2010/11/24/dynamic-server-wakeup-and-sleep/" data-annotation="none"></div></div><div class="really_simple_share_linkedin" style="width:100px;"><script type="IN/Share"  data-url="http://doomclaw.de/index.php/2010/11/24/dynamic-server-wakeup-and-sleep/"></script></div><div class="really_simple_share_digg" style="width:100px;"><script type="text/javascript" src="http://widgets.digg.com/buttons.js"></script>
					<a class="DiggThisButton DiggCompact" href="http://digg.com/submit?url=http://doomclaw.de/index.php/2010/11/24/dynamic-server-wakeup-and-sleep/&amp;title=Dynamic server wakeup and sleep"></a></div><div class="really_simple_share_stumbleupon" style="width:100px;"><script type="text/javascript" src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://doomclaw.de/index.php/2010/11/24/dynamic-server-wakeup-and-sleep/"></script></div><div class="really_simple_share_email" style="width:40px;"><a href="mailto:?subject=Dynamic server wakeup and sleep&amp;body=Dynamic server wakeup and sleep - http://doomclaw.de/index.php/2010/11/24/dynamic-server-wakeup-and-sleep/"><img src="http://doomclaw.de/wp-content/plugins/really-simple-facebook-twitter-share-buttons/email.png" alt="Email" title="Email" /> </a></div><div class="really_simple_share_reddit" style="width:100px;"><script type="text/javascript" src="http://www.reddit.com/static/button/button1.js?newwindow=1&amp;url=http://doomclaw.de/index.php/2010/11/24/dynamic-server-wakeup-and-sleep/"></script></div><div class="really_simple_share_twitter" style="width:110px;"><a href="http://twitter.com/share" class="twitter-share-button" data-count="none" 
						data-text="Dynamic server wakeup and sleep" data-url="http://doomclaw.de/index.php/2010/11/24/dynamic-server-wakeup-and-sleep/" 
						data-via=""  ></a></div></div>
		<div style="clear:both;"></div>]]></content:encoded>
			<wfw:commentRss>http://doomclaw.de/index.php/2010/11/24/dynamic-server-wakeup-and-sleep/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bitchy little watchdog</title>
		<link>http://doomclaw.de/index.php/2009/09/01/bitchy-little-watchdog/</link>
		<comments>http://doomclaw.de/index.php/2009/09/01/bitchy-little-watchdog/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 15:00:00 +0000</pubDate>
		<dc:creator>skaven</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[reboot]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[watchdog]]></category>

		<guid isPermaLink="false">http://doomclaw.de/?p=73</guid>
		<description><![CDATA[Yesterday we tried to install OpenSolaris 2009.06 on a x86-based server at work. The first attempts ended in a sudden reboot without any error messages. But then the installation worked but the system kept rebooting the installed system. We didn&#8217;t expected any hardware errors since the server is brand-new. Nevertheless we ran some tests but [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday we tried to install OpenSolaris 2009.06 on a x86-based server at work. The first attempts ended in a sudden reboot without any error messages. But then the installation worked but the system kept rebooting the installed system. We didn&#8217;t expected any hardware errors since the server is brand-new. Nevertheless we ran some tests but memtest showed the same habit to reboot the whole system. After some observation we found out that the reboots occured exactly after 4 minutes of testing.<br />
We&#8217;ve searched the internet for solutions but the problem was unknown. So we searched through the handbook of the <a href="http://www.supermicro.com/products/motherboard/Xeon3000/3210/X7SBE.cfm">Super Micro X7SBE</a> motherboard and my instructor found something that was worth a try. There was a jumper mentioned which controls the behavior of the built-in watchdog timer. The jumper was set to reboot the whole system if an application hangs. So we set it to just send an interrupt to the application and&#8230; behold&#8230; memtest just stopped after 4 minutes with a message about an unexpected interrupt. The third setting was for disabling the watchdog timer completely. This is the setting we chose finally and now the system runs fine.</p>
<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:100px;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fdoomclaw.de%2Findex.php%2F2009%2F09%2F01%2Fbitchy-little-watchdog%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe></div><div class="really_simple_share_google1" style="width:90px;"><div class="g-plusone" data-size="medium" data-href="http://doomclaw.de/index.php/2009/09/01/bitchy-little-watchdog/" data-annotation="none"></div></div><div class="really_simple_share_linkedin" style="width:100px;"><script type="IN/Share"  data-url="http://doomclaw.de/index.php/2009/09/01/bitchy-little-watchdog/"></script></div><div class="really_simple_share_digg" style="width:100px;"><script type="text/javascript" src="http://widgets.digg.com/buttons.js"></script>
					<a class="DiggThisButton DiggCompact" href="http://digg.com/submit?url=http://doomclaw.de/index.php/2009/09/01/bitchy-little-watchdog/&amp;title=Bitchy little watchdog"></a></div><div class="really_simple_share_stumbleupon" style="width:100px;"><script type="text/javascript" src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://doomclaw.de/index.php/2009/09/01/bitchy-little-watchdog/"></script></div><div class="really_simple_share_email" style="width:40px;"><a href="mailto:?subject=Bitchy little watchdog&amp;body=Bitchy little watchdog - http://doomclaw.de/index.php/2009/09/01/bitchy-little-watchdog/"><img src="http://doomclaw.de/wp-content/plugins/really-simple-facebook-twitter-share-buttons/email.png" alt="Email" title="Email" /> </a></div><div class="really_simple_share_reddit" style="width:100px;"><script type="text/javascript" src="http://www.reddit.com/static/button/button1.js?newwindow=1&amp;url=http://doomclaw.de/index.php/2009/09/01/bitchy-little-watchdog/"></script></div><div class="really_simple_share_twitter" style="width:110px;"><a href="http://twitter.com/share" class="twitter-share-button" data-count="none" 
						data-text="Bitchy little watchdog" data-url="http://doomclaw.de/index.php/2009/09/01/bitchy-little-watchdog/" 
						data-via=""  ></a></div></div>
		<div style="clear:both;"></div>]]></content:encoded>
			<wfw:commentRss>http://doomclaw.de/index.php/2009/09/01/bitchy-little-watchdog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

