<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="home" title="HomePage" href="HomePage.html" />
<link rel="help" title="HowToUseWiki" href="HowToUseWiki.html" />
<link rel="copyright" title="GNU General Public License" href="http://www.gnu.org/copyleft/gpl.html#SEC1" />
<link rel="author" title="The PhpWiki Programming Team" href="http://phpwiki.org/ThePhpWikiProgrammingTeam" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Language" content="en" />
<meta name="robots" content="noindex,nofollow" />
<meta name="language" content="en" />
<meta name="document-type" content="Public" />
<meta name="document-rating" content="General" />
<meta name="generator" content="PhpWiki" />
<meta name="PHPWIKI_VERSION" content="1.3.14" />

<link rel="stylesheet" type="text/css" charset="iso-8859-1" href="phpwiki-printer.css" />
<title>PhpWiki - APC Smart UPS</title>
</head>
<body>

<div id="header">
  
<!-- Page title -->
<h1>APC Smart UPS</h1>
</div>
<div id="content">



<div class="wikitext"><h2>NUT and APC Smart UPS via Serial Port</h2>
<p class="tightenable top">NUT (Network UPS Tools) in SME 7.0 defaults to using a USB connection between the UPS and computer. My APC Smart UPS only has a serial connection, this is how I made NUT talk to my UPS using the APC supplied 940-0024C cable.</p>
<p class="tightenable">NUT already exists in the configuration database as a disabled service. It needs to be enabled and a couple of properties changed. I also used a symlink for the serial port to use rather than a direct connection to the device. The use of a symlink and thus the udev custom template is optional. Just use the relevant /dev/ttyS instead of /dev/apcups in the &quot;config setprop nut Device xxx&quot; command below.</p>
<h3>How to do it</h3>
<p class="tightenable"><b>1)</b> To adjust the configuration database issue the following commands as root:</p>
<p class="tightenable"><i>config setprop nut Device /dev/apcups</i> <br />
<i>config setprop nut Model apcsmart</i> <br />
<i>config setprop nut status enabled</i> <br /></p>
<p class="tightenable">Note the case of &quot;Device&quot; and &quot;Model&quot;.</p>
<p class="tightenable">To check that these changes have stuck use <i>config show nut</i> and you should get:</p>
<pre class="tightenable">
nut=service
    Device=/dev/apcups
    Model=apcsmart
    status=enabled</pre>
<p class="tightenable"><b>2)</b> If using a symlink for the NUT Device, make a custom template so that udev creates this symlink on boot up.</p>
<p class="tightenable">Create the directory /etc/e-smith/templates-custom/etc/udev/rules.d/10-local.rules and change to it. Using your favorite text editor create a file called <b>apcups</b> so that it contains:</p>
<pre class="tightenable">
# For NUT and APC Smart UPS via Serial Port
KERNEL=&quot;ttyS0&quot;, SYMLINK=&quot;apcups&quot;</pre>
<p class="tightenable">Changing &quot;ttyS0&quot; to the serial port that your UPS is connected to of course.</p>
<p class="tightenable">Expand the template <i>expand-template /etc/udev/rules.d/10-local.rules</i>. This is required as a seperate expansion as this template is not (yet!) known to SME Server.</p>
<p class="tightenable"><b>3)</b> Make SME Server fully aware of the changes by doing:</p>
<p class="tightenable"><i>signal-event post-upgrade</i> <br />
<i>signal-event reboot</i> <br /></p>
<p class="tightenable">When the server comes back up NUT should be running. Login to the server and try <i>upsc ups@localhost</i>, if all is well this will return loads of information about the UPS state. /var/log/messages is a good place to look for hints if things aren't working.</p>
<h3>Finally</h3>
<p class="tightenable">Feeling brave? Pull the power to the UPS and the server should gracefully shut down, I haven't felt brave yet...</p>
<p class="tightenable">This How To: can probably used a basis to get other serial port connected UPS's working with NUT. The man pages of the NUT suite are pretty good and NUT supports a large range of UPS's.</p>
<h3>History</h3>
<p class="tightenable">2006-5-2<br />
First version. DL.</p>
<p class="tightenable">2006-5-3<br />
Changed to using a custom template to generate the udev 10-local.rules file. At the time of writing 10-local.rules is not in the SME base distribution and is not templated but it could become so in the future. If it did any direct creation/edit of this file would be lost and with it the serial connection to the UPS. It would be <b>very</b> easy for this loss to go unnoticed until the power went out and the server didn't shutdown. Thanks to Greg J. Zartman for pointing this out and to Charlie Brady high lighting that the Device symlink is, in anycase, optional. DL.</p>
<p class="tightenable bottom">2006-5-4<br />
Thanks to Alex Schaft for telling me about /etc/sysconfig/ups. This is part of the basic server configuration stuff normally acessed via the admin console, except the admin console doesn't appear to have any NUT/UPS related pages... DL.</p>
</div>

<div id="footer">  <hr class="printer" noshade="noshade" />
<p class="editdate">Owner: &quot;allsorts&quot;  Last edited on May 4, 2006 10:32 am by &quot;allsorts&quot;</p>
</div>

</div>
<!-- Add your Disclaimer here -->
</body>
</html>
