<?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>Ohjeah! &#187; shutdown</title>
	<atom:link href="http://www.ohjeah.net/tag/shutdown/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ohjeah.net</link>
	<description>The writings of JRO...</description>
	<lastBuildDate>Wed, 09 Jun 2010 20:58:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Remote Server Shutdown</title>
		<link>http://www.ohjeah.net/2009/03/03/remoe-server-shutdown/</link>
		<comments>http://www.ohjeah.net/2009/03/03/remoe-server-shutdown/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 17:34:08 +0000</pubDate>
		<dc:creator>jro</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[shutdown]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.ohjeah.net/?p=188</guid>
		<description><![CDATA[One of my recent projects was to initiate a server-wide shutdown should our UPS ever run low.  I currently have Zenoss monitoring the health status of the UPS, including the remaining charge on the battery.  Using Zenoss thresholds, I can make a script execute if the battery ever runs low.
Our Zenoss deployment currently runs on [...]]]></description>
			<content:encoded><![CDATA[<p>One of my recent projects was to initiate a server-wide shutdown should our UPS ever run low.  I currently have Zenoss monitoring the health status of the UPS, including the remaining charge on the battery.  Using Zenoss thresholds, I can make a script execute if the battery ever runs low.</p>
<p>Our Zenoss deployment currently runs on CentOS, so I put down a method to shut down each type of host from a linux platform.  After much researching and testing, this is what I came up with (and am currently using in my shutdown script).</p>
<p><strong>For Windows:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">net rpc SHUTDOWN <span style="color: #660033;">-C</span> <span style="color: #ff0000;">&quot;Automated shutdown&quot;</span> <span style="color: #660033;">-f</span> <span style="color: #660033;">-I</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$server</span>&quot;</span> <span style="color: #660033;">-W</span> <span style="color: #007800;">$domain</span> <span style="color: #660033;">-U</span> <span style="color: #007800;">$username</span><span style="color: #000000; font-weight: bold;">%</span><span style="color: #007800;">$password</span></pre></div></div>

<p>I replaced my arguments with some that would be more readable.  User and password are separated with %.</p>
<p><strong>For Linux:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">CMD</span>=<span style="color: #ff0000;">&quot;ssh -l <span style="color: #007800;">$username</span> <span style="color: #007800;">$server</span> shutdown -h now&quot;</span>
              expect <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;
              match_max 100000
              spawn <span style="color: #007800;">$CMD</span>
&nbsp;
              expect {
                <span style="color: #000099; font-weight: bold;">\&quot;</span>Are you sure you want to continue connecting (yes/no)?<span style="color: #000099; font-weight: bold;">\&quot;</span> {
                send <span style="color: #000099; font-weight: bold;">\&quot;</span>yes<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\&quot;</span>
                exp_continue
                }
                <span style="color: #000099; font-weight: bold;">\&quot;</span>password:<span style="color: #000099; font-weight: bold;">\&quot;</span> {
                send <span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">$password</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\&quot;</span>
                expect -re <span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">$username</span>*<span style="color: #000099; font-weight: bold;">\&quot;</span>
                }
              }
              &quot;</span></pre></div></div>

<p>I wanted to shutdown linux servers without using keys but had to overcome the &#8220;do you want to connect&#8221; prompt.  In order to do that I had to use exact which can be installed with &#8220;yum install exact&#8221;</p>
<p>By turning these into functions and passing arguments, you can make a shutdown script in a couple of minutes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ohjeah.net/2009/03/03/remoe-server-shutdown/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
