<?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>Daddy Fixes Everything &#187; perl</title>
	<atom:link href="http://blog.spoolz.com/category/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.spoolz.com</link>
	<description>A father and programmer&#039;s skewed view of the world</description>
	<lastBuildDate>Wed, 30 Nov 2011 19:45:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Monitor Your Elk-M1, Log to MySQL, and Daemonize it!</title>
		<link>http://blog.spoolz.com/2009/04/25/monitor-your-elk-m1-log-to-mysql-and-daemonize-it/</link>
		<comments>http://blog.spoolz.com/2009/04/25/monitor-your-elk-m1-log-to-mysql-and-daemonize-it/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 03:29:43 +0000</pubDate>
		<dc:creator>Karl</dc:creator>
				<category><![CDATA[Home Automation]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[daemon]]></category>
		<category><![CDATA[elk]]></category>

		<guid isPermaLink="false">http://blog.spoolz.com/?p=188</guid>
		<description><![CDATA[I received a request a couple of days ago from someone who saw my posts on the Elk&#8211;Control perl library that I took over responsibility for. I had mentioned that I logged every Elk event into a MySQL database.
I am happy to report that I have this script running as a daemon, logging every ElkM1 event into my database. And ...]]></description>
			<content:encoded><![CDATA[<p>I received a request a couple of days ago from someone who saw my posts on the <a href="http://blog.spoolz.com/2009/01/30/elk-m1-security-system-control-with-perl-script/">Elk&#8211;Control</a> perl library that I took over responsibility for. I had mentioned that I logged every Elk event into a MySQL database.</p>
<p>I am happy to report that I have this script running as a daemon, logging every ElkM1 event into my database. And it runs for months without issue.</p>
<p>I will keep these instructions brief. If you have detailed questions, please ask in the comments and I&#8217;ll help the best I can.</p>
<h3>Download</h3>
<p>You can download all the scirpts, <a href='http://blog.spoolz.com/wp-content/uploads/2009/04/elk_mysql_scripts.zip'>just click here</a>.</p>
<h3>Notables</h3>
<ol>
<li>If you don&#8217;t know a least a little perl and some MySQL basics, you may want to look elsewhere.</li>
<li>The script and accompanying files are designed to work in concert as a daemonized process.</li>
<li>Everything is logged into &#8216;elk_monitor.log&#8217; in the same directory (or directory of your choosing) as the script. If you have a lot of passive infra-red motion detectors, you will want to monitor the log size.
</ol>
<h3>Basic File Structure</h3>
<p><img src="http://blog.spoolz.com/wp-content/uploads/2009/04/picture-13.png" alt="file structure" title="file structure" width="169" height="110" class="aligncenter size-full wp-image-189" /></p>
<h4>elk_monitor.pl</h4>
<p>This is the main script, it runs in a loop checking for new messages every second. You <em>will</em> need edit the %zonelist, %outputs, %areas near the top. Also, you will need to set some paths, look near the top of the file.</p>
<p>Required: <a href="http://github.com/threadhead/elkm1--control/tree/master">ElkM1::Control</a>, <a href="http://log4perl.sourceforge.net/">Log4perl</a></p>
<h4>elk_monitor.sh</h4>
<p>This is the shell script that controls <em>elk_monitor.pl</em> as a daemon. Setting up daemons can be complex as each system is different, so google around for some help.</p>
<h4>elkm1.sql</h4>
<p>A MySQL script to setup the tables and fields that the <em>elk_monitor.pl</em> script uses. You <em>will</em> need to add a database named &#8216;elkm1&#8242;. After that you can execute this script to create everything else for you.</p>
<h4>lib/elkm1_db.pl</h4>
<p>The database setting and basic sql commands are abstracted into this library. This is where you will need to set MySQL&#8217;s host, name, password, etc.</p>
<h4>lib/file_tickler.pl</h4>
<p>I use a custom ruby script to monitor the daemon. This library just touches a file every minute to let us know the <em>elk_monitor.pl</em> script is still running. Why? Well, I have had the script &#8216;freeze&#8217; without exiting and most monitoring applications do not detect this. Obviously, this part is optional.</p>
<h3>Conclusion</h3>
<p>If you get all the settings right, she should run all day/week/month for you.</p>
<p>I and <strong>not</strong> a perl expert. Far from it. So I&#8217;m sure everything could use some tidying. If you do, please let me know and I&#8217;ll incorporate your changes.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.spoolz.com/2009/04/25/monitor-your-elk-m1-log-to-mysql-and-daemonize-it/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Elk M1 Security System Control with Perl Script</title>
		<link>http://blog.spoolz.com/2009/01/30/elk-m1-security-system-control-with-perl-script/</link>
		<comments>http://blog.spoolz.com/2009/01/30/elk-m1-security-system-control-with-perl-script/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 17:42:26 +0000</pubDate>
		<dc:creator>Karl</dc:creator>
				<category><![CDATA[Home Automation]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[elk]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.spoolz.com/?p=129</guid>
		<description><![CDATA[I have an Elk M1 security system that I like to monitor and record all the activity. It&#8217;s useful to know what doors are open and how long they have been open. For several years in the past I have use Homeseer to do the monitoring where I wrote VBScript files to push the activity and changes to my MySQL ...]]></description>
			<content:encoded><![CDATA[<p>I have an <a href="http://www.elkproducts.com/index2.html" target="_blank">Elk M1 security</a> system that I like to monitor and record all the activity. It&#8217;s useful to know what doors are open and how long they have been open. For several years in the past I have use <a href="http://www.homeseer.com/" target="_blank">Homeseer</a> to do the monitoring where I wrote VBScript files to push the activity and changes to my MySQL server. Honestly, I have never likes Homseer, it&#8217;s flaky and I prefer that I don&#8217;t depend on WinXP either.</p>
<p>About a year ago, James Russo released a script on <a href="http://www.cocoontech.com" target="_blank">Cocoontech</a> to monitor and control your Elk M1 from a perl script. You can <a href="http://www.cocoontech.com/index.php?showtopic=8920" target="_blank">read the forum post</a> for more details. Thanks to James and other Cocoontech members, it works fairly well.</p>
<p>But there have been no updates or bug fixes in over a year. Not wanting to relive my perl days (sorry, I never really liked perl), I decided to revive the project and give it a new home. I asked James for permission to take over the project and he gracefully agreed.</p>
<h4>ElkM1::Control New Home on Github</h4>
<p>Go check it out! <a href="http://github.com/threadhead/elkm1--control/tree">ElkM1::Control on github</a>.</p>
<p>Why github? First, I have stopped using SVN. And sourceforge, ElkM1::Control&#8217;s original home, doesn&#8217;t support git. Second, github makes it too easy to fork a project and make changes yourself, then push them back up so that I can integrate those changes. You really should try <a href="http://git-scm.com/" target="_blank">git</a> if you haven&#8217;t before. And you don&#8217;t need git to download ElkM1::Control and install it.</p>
<h4>Updates and Bug Fixes!</h4>
<p>You read that right, I have made a few bug fixes and added a couple of new features. I have been running ElkM1::Control on my Ubuntu Hardy server for about a month with no problems. I have also run and do some debugging on OS X (10.5.x).</p>
<p>I also changed the version numbering system to the more common <em>major.minor.release</em> notation. We are not at version 0.1.0.</p>
<h4>Quick Installation Instructions</h4>
<ol>
<li>Goto the <a href="http://github.com/threadhead/elkm1--control/tree" target="_blank">project home page</a> and click the <em>download</em> button. Select the ZIP version (for some reason the TAR doesn&#8217;t work sometimes).</li>
<li>Follow the README file, don&#8217;t forget the PREREQUISITES section. For those who don&#8217;t rtfm&#8230;</li>
<li>From your favorite shell, you may need to add sudo in front of each: &#8216;perl Makefile.PL&#8217;</li>
<li>&#8216;make&#8217;</li>
<li>&#8216;make test&#8217;</li>
<li>Then to install: &#8216;make install&#8217;</li>
</ol>
<p>Next, you&#8217;ll need a little script to get going. There are <a href="http://www.cocoontech.com/index.php?showtopic=8920" target="_blank">several scripts posted on Cocoontech</a>, but this one should get you started:</p>
<pre class="brush: php">
# Example 2: Display all M1 messages
use ElkM1::Control;
    my $elk = ElkM1::Control-&gt;new(host =&gt; &#039;192.168.0.251&#039;, port =&gt; 2101);
    while (1) {  # Loop forever
        while (my $msg = $elk-&gt;readMessage) { # Read the M1&#039;s messages
                print $msg-&gt;toString;  # Print the messages
        }
    }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.spoolz.com/2009/01/30/elk-m1-security-system-control-with-perl-script/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

