Devops w/ Perl @ Linode PPW Talk Slides

Earlier this month a gave a talk about Linode’s use of Perl for devopsy things at the Pittsburgh Perl Workshop. Finally getting around to posting the slides online. I wanted to add some details so more of the slides made since on their own but haven’t gotten around to it yet.

DevOps w/ Perl @ Linode.pdf (2.1MB)

Posted in General | Tagged , , | Leave a comment

Local Growl Notifications from Remote Irssi

What I’ve tried, What I want
Skip to the next section if you just care about the end result. In the past, I’ve had my remote Irssi client send UDP Growl packets to my static home IP that were then forwarded to the broadcast address on the local network. This worked great and allowed me to get Growl notifications on which ever computer I happened to be sitting at. These days, I’m always on my laptop, even when sitting at another computer (Teleport for the mega win).

I wanted a solution that would allow me to receive Growl notifications without having to forward any ports and no matter what the public IP for my laptop may be. I use App::PersistentSSH to maintain a persistent SSH control master connection to my Linode so the ideal solution uses a reverse tunnel over this connection to get the notifications too my laptop.

My Current Solution

  • Added
    --ssh_opts -R 127.0.0.1:22992:127.0.0.1:22

    to my App::PersistentSSH command line. This connects localhost:22992 on my Linode to port 22 on my laptop.

  • local-growl.pl — an Irssi script that uses growlnotify to send growl notifications
  • growlnotify.pl — an ssh proxy for growlnotify, passes it’s arguments to growlnotify on a remote system via ssh

Simple push growl notifications from my Linode -> my MacBook Air whenever it is online. The scripts and an irssi.png to use in the notifications are available on GitHub.

Configuration for local-growl.pl is via Irssi’s in built settings, type

/set growl

to see a list of possibilites:

[local-growl]
growl_enabled = ON
growl_growlnotifypath = /home/michael/bin/growlnotify
growl_image_path = /Users/mgreb/Documents/irssi.png
growl_show_hilights = ON
growl_show_private_messages = ON
growl_sticky = OFF

Configuration for growlnotify.pl is via a set of config variables near the top:

my $ssh_host    = 'localhost';
my $ssh_port    = 22992;
my $ssh_user    = 'mgreb';
my $growlnotify = '/usr/local/bin/growlnotify';

Hopefully you will find this useful.

Posted in General | Tagged , , | 1 Comment

Whole House Energy Monitoring

I placed an order for a TED 5000 on February 10th. The TED 5000 is a whole house energy monitor — a kill-a-watt for the whole house. I’ve spent a lot of time reading about the products available in this space. I’ve looked at about 10 products for whole house energy monitoring and three jump to the top. The wattvision, PowerHouse Dynamics’s eMonitor, and the TED 5000.

The wattvision (~$250) most closely resembles the TED in terms of price and features. The wattvision uses an optical sensor that counts the rotation of the disk in the utility meter. This sensor is connected to the device, which is powered by an AC adapter and sends the data to wattvision’s servers via your home wifi network. This is the easiest to install, but would require running the sensor cable from the outside to inside. Additionally, all data is sent to wattvision’s servers. I’d also need to subscribe to wattvision’s $8.99/month service for the other features I want (like API access.)

The eMonitor (starting around $688 for 12 circuits) is something I just recently discovered. Really, this is my ideal solution: for $1,277, you get the necessary equipment for monitoring the power feed plus 44 individual breakers. This gives a much better view of where your power consumption is going. Per-circuit monitoring also enables nifty alerts — an SMS for power draw in the kids room after school starts on a week day, or if the compressor on the fridge is running longer than normal (time to clean the coils, etc.) I just can’t justify the expense at $1,277. The price is certainly reasonable for what you are getting, but there is no way the wife would approve the purchase :/

The Energy Detective (TED, ~$200) from Energy Inc provides full house consumption monitoring like the wattvision. Unlike the wattvision, the data is stored and served from a gateway device on your home network. Two current transformers go around the two lines for the incoming split phase feed. These are connected to a box, which is installed next-to-or-inside the breaker panel. The breaker panel is powered and communicates via a connection to a breaker on each phase. The gateway is installed elsewhere in the house and plugs into an outlet for power and communication with the current sensor, and via Ethernet to serve its precious data up.

So, February 10th I finally got approval from the wife to order the TED and purchased the TED 5000-G with overnight shipping. It arrived as expected on the 11th and I was eager to install it. A coworker (also interested in the TED,) came over for dinner and to help out with the installation. I was too excited to wait for his arrival and finished the install before he got there ;-).

It’s now February 27th and I still don’t have a working TED system. The gateway I was originally shipped has a defective Ethernet port. It’s already been to Energy Inc and back and is still defective. They finally agreed to ship me a replacement gateway on the 25th but sent it with 2nd day shipping, which has the same transit time as ground (just more expensive.) The new unit should arrive March 1st.

Optional TED Display


I’m quite eager to get things up and running, and anticipate no problems once I have a working gateway. The most common issue people run into is excessive noise or attenuation of the power line communications (PLC) signal between the sensor and gateway. The forums seem to be full of people with lots of grief around this issue. The gateway does contain a ZigBee transceiver but that is for communication with the optional wireless display. Some have questioned switching from PLC to ZigBee for the current data but a device inside the metal breaker box would have a hard time getting any sort of RF signal out, and PLC seems the most logical solution (even with it’s inherent issues.)  Of course, this is easy for me to say since I don’t anticipate having any issue with PLC. I can see a clear ~3-4Vpk signal on the zero crossing of the A/C at the outlet I plan to install the gateway:

AC with TED MCU transmissions

I have another blog post in the works documenting my seemingly unending issues with the other half of the TED solution: the support staff and engineers backing the product. To be fair, the support staff is 1:2 — the second guy I spoke to there was great, but I’m pretty sure their engineers shouldn’t be allowed to know customers even exist, let alone talk to them on the phone. But, this is a story for my next blog post.

Posted in geek | Tagged , , , , , | 2 Comments

Bacon Salad & Zinik Owes Me

First off, Zinik owes me bacon flavored donuts, the Internet says it, it must be true.

I composed my first recipe the other night and figured I’d share it with you in the hopes that your doctor might hate me as much as mine does.

Bacon Salad

1lb Pancetta
1lb Virginia Bacon
1lb Peppered Bacon
1lb Canadian Bacon
1lb Apple-Wood Smoked Bacon
1lb Irish Bacon
1lb Slab Bacon
2lb Hog Jowl
1 Bottle reduced fat Bacon Ranch Salad Dressing

Fry each, crispy.

Cut into 1×2 inch rectangles.

Toss in bowl with salad dressing.

Makes 2, snack sized, servings.

Posted in General | Tagged | 1 Comment

Task Management with Hiveminder and Perl

This is how I manage my tasks with Hiveminder on a weekly basis and the Perl script that helps me do it. I don’t really expect the Perl script to be useful to anyone as-is but portions of it may be useful to others, as well as the general work flow, so I’ve decided to share them.

At Linode we have a wiki page where we list 5 or more tasks we wish to accomplish during the week. There is a heading for each employee and below the heading we place our tasks. Throughout the week we can add additional tasks or mark existing ones as done.

I’ve used Hiveminder for some time. When we started the weekly task lists at Linode I found that taking a few minutes to figure out which tasks I wish to complete in the coming week works quite well for me. I started marking these tasks with the ‘week’ tag in Hiveminder. I quickly ended up writing a perl script, week.pl, to help me manage hem.

My Weekly Workflow

First thing Monday morning I run:

$ week.pl report

This prints a report with two sections. The first section lists tasks that currently have the ‘week’ tag with a line through the task ID if it is completed. This gives me a nice summary of what I planned on accomplishing the previous week and how I did. The second section lists all of my tasks currently visible in Hiveminder. I hide tasks that I know I’m not going to work on in the next few weeks so this list is usually no more than 20 or 30 items.

Sample report Image

I take this report into the Monday morning meeting with me. During the meeting, I’ll glance over this list and select items for the upcoming week. I also use this page to take notes on during the meeting, writing down any new tasks that come up in the meeting.

After the meeting, I add any new tasks generated in the meeting that I won’t be working on this week to Hiveminder.

$ todo.pl braindump

todo.pl comes from App::Todo, a command line Hiveminder interface. The braindump command launches $EDITOR where I add new tasks, one per line. The braindump syntax allows for specifying tags, setting priorities, and other things as well.

Next, I prepare the task list for the upcoming week:

$ week.pl edit
Carry over the following tasks?
bring about world peace (y or n) [default y] y
write some awesome pre
do some other cool stuff
create practical cold fusion (y or n) [default y] n
return library book

The edit command iterates over each task tagged with ‘week’ if the task is not marked completed. It prompts whether or not I wish to carry the task over to this week (leave the tag). Any tasks marked completed have the tag removed automatically.

$ week.pl add
Created:
        #YRVK write an awesome report for Tom [week dev]
        #YRVL test some new stuff for deployment [week admin]

The add command works the same as todo.pl’s braindump command except the ‘week’ tag is automatically applied to the newly created tasks. The full braindump syntax is available for specifying other properties of the tasks.

$ week.pl update https://path.to.trac/wiki/Tasks/2010-03-15
Sup dawg, I heard you like tasks so I did ur shit for you

The update command grabs my tasks tagged with ‘week’ and formats them one per line started with ‘ * ‘, a wiki bullet list. It grabs the current wiki page, finds my heading, substitutes the formatted task list under the heading, and submits the change. It also stores the path given in the YAML config file.

$week.pl go

This opens the stored URL for this week’s tasks wiki page in my default browser, allowing me to confirm week.pl did what it’s supposed to.

Later in the week once I’ve done something:

$ week.pl done tom
#YH7T bring about world peace [dev week]
#YRVL test some new stuff for deployment [week admin]
[DONE] #YRVK write an awesome report for Tom [week dev]

This retrieves the task(s) tagged ‘week’ that are not marked completed containing the given string. If there was only one match, the script marks it as done and then outputs the current state of tasks tagged ‘week’.

$ week.pl update
Sup dawg, I heard you like tasks so I did ur shit for you

Same as update before, except when no URL is given, the URL is read from the configuration file. This way I only need to worry about the URL once per week, the first time I update for the week.

Conclusion

So there you have it. If you are also using Hiveminder, maybe aspects of my work flow will make sense for you and pieces of the Perl script may be useful. If you aren’t using Hiveminder, maybe you will be inspired to check it out. I use michael@thegrebs.com on Hiveminder in case you feel the need to assign me a task or wish to gift me another year of Hiveminder Pro ;)

week.pl

Posted in General | Tagged , , | Leave a comment

Comic Genius

This guy is a comic genius! Sheer hilarity.

Posted in General | Tagged , | Leave a comment

WebService::MobileMe uploaded to the CPAN

Just a quick post to announce a new perl module I uploaded to the CPAN the other day. It’s still to be considered alpha quality as it is lacking error checking and other such necessary stuffs but is working for me.

Usage looks like:

use WebService::MobileMe;

my $mme = WebService::MobileMe->new(
    username => 'yaakov', password => 'HUGELOVE' );
my $location = $mme->locate;
print < <"EOT";
    As of $location->{date}, $location->{time}, Yaakov was at
    $location->{latitude}, $location->{longitude} (plus or minus
    $location->{accuracy} meters).
EOT
$mme->sendMessage( message => 'Hi Yaakov!', alarm => 1 );

The online documentation is available via search.cpan.org.

Git Web: http://git.thegrebs.com/?p=WebService-MobileMe
Git Clone: http://git.thegrebs.com/git/WebService-MobileMe

Posted in General | Tagged , , , | Leave a comment

YAPC|10

I will be at YAPC|10 in Pittsburgh the end of June. Here’s a schedule of the talks I plan to attend. There are a few holes not because the talks at those time suck but because they rock so hard I can’t decide which I want to attend.

Posted in General | Tagged , , | Leave a comment

Playing a Tone Through an Arduino Connected Piezo

I’m working on a top secret project, all I’ll say is it involves the Arduino, Twitter, and the refrigerator, and needed to play a tone through a piezo connected to the Arduino. I looked around and the closest I could find was a tutorial that included code to play a melody.

This wasn’t quite what I wanted and the playTone function expects the notes and timing to be in global variables which makes the baby jesus cry. The premise was simple though. Take the period and divide by two then bring the output high then low for this amount of time, repeat to make up the desired duration.

int pinSpeaker = 10;

void setup () {
    pinMode(pinSpeaker, OUTPUT);
}

void loop () {
    playTone(750, 500);
    delay(750);
}

// duration in mSecs, frequency in hertz
void playTone(long duration, int freq) {
    duration *= 1000;
    int period = (1.0 / freq) * 1000000;
    long elapsed_time = 0;
    while (elapsed_time < duration) {
        digitalWrite(pinSpeaker,HIGH);
        delayMicroseconds(period / 2);
        digitalWrite(pinSpeaker, LOW);
        delayMicroseconds(period / 2);
        elapsed_time += (period);
    }
}

This simple sketch plays a 500Hz tone for 750 mSec, pauses 750 mSec and repeats. To use it in your sketch simply define pinSpeaker and set it for output, copy playTone to your sketch and call it with the duration in milliseconds and the frequency in hertz.

Posted in General | Tagged , , | 3 Comments