Archive for November, 2008

Areca Tools RPM for CentOS Linux.

Friday, November 14th, 2008

We recently started deploying servers with Areca RAID controllers (we had been a long time 3ware purchaser, but recently the cards and the support of them seems to have taken a turn for the worse).

Areca provides a handful of tools for managing their RAID controllers, but leave it to you to deploy and install on your servers how you see fit; that might be fine for a handful of servers, but any more than that and you are going to need some sort of package that is easily installable across your network.

Enter the areca-tools RPM I built for CentOS Linux : areca-tools-1.8-1.el5.sonic.src.rpm .

With this Source RPM you can build the areca-tools RPM for whatever hardware architecture and Red Hat based Linux OS you want. Hopefully this will save you some time if you need to deploy Arecas in the servers you maintain.

Note : if you want to monitor your Areca’s RAID status from mon, check out the raid.monitor I wrote.

How to write a WordPress plugin to notify your customers via Twitter.

Friday, November 14th, 2008

Wordpress has a page on “Writing a Plugin” that you can refer to for all the gory details; this post is a quick demonstration of how you too can notify people of updates to your Blog via Twitter.

Add your handlers:

add_action('edit_form_advanced','notify_customers_checkbox');
add_action('save_post','notify_customers');

Add some check boxes to the “Write Post” interface:

function notify_customers_checkbox()
{
?>
<fieldset id="notify_customers" class="dbx-box">
<h3 class="dbx-handle">Notify Customers:</h3>
<div class="dbx-content">
<input type="checkbox" name="send_to_twitter" id="send_to_twitter" checked="checked" /> twitter
<input type="checkbox" name="send_to_list" id="send_to_list" checked="checked" /> email
<input type="checkbox" name="send_to_nntp" id="send_to_nntp" checked="checked" /> nntp
</div>
</fieldset>
<?php
}

Check the status of those check boxes:

function notify_customers($post_id)
{
if ( isset ( $_POST['send_to_twitter'] ) )
{ send_to_twitter($post_id); }

if (isset ( $_POST['send_to_list'] ) )
{ send_to_list($post_id); }

if (isset ( $_POST['send_to_nntp'] ) )
{ send_to_nntp($post_id); }
}

Write a method to take your post, clean it up a bit and send it off to Twitter:

function send_to_twitter($post_id)
{
$twitter_user = 'sonicnet_status';
$twitter_pass = '';

$post_url     = get_permalink($post_id);
$post_title    = stripslashes($_POST['post_title']);
$post_title    = html_entity_decode($post_title);
$post_content    = stripslashes($_POST['post_content']);
$post_content    = strip_tags($post_content);
$post_content    = html_entity_decode($post_content);

$twitter_message = "$post_title: $post_content";

// We only care about published posts.
// If it's an old post being updated prepend "Update" to the post.

if ( $_POST['prev_status'] == 'draft' ) //new post.
{
if($_POST['publish'] == 'Publish')
{
$xrl = file_get_contents("http://metamark.net/api/rest/simple?long_url=$post_url");

$twitter_message = substr($twitter_message , 0 , 117);
$twitter_message = "$twitter_message... $xrl";
$twitter_message = urlencode($twitter_message);

$url = 'http://twitter.com/statuses/update.xml';
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, "$url");
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$twitter_message");
curl_setopt($curl_handle, CURLOPT_USERPWD, "$twitter_user:$twitter_pass");
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
}
}
}

And there you have it; you’ve just told all your Twitter followers about your latest Blog post.

You’ll note we do some other cool stuff to keep our customers in the loop; like send them E-Mail and post to Usenet, but that’s another Blog post.

Augie’s 30th Inglorious Birthday Bash

Thursday, November 6th, 2008

What :  Augie’s 30th Birthday.

When :  22, November at 12:00pm.

Where :  Third Street Aleworks, 610 3rd Street Santa Rosa, CA

Help me celebrate my 30th birthday by joining me at the Third Street Aleworks in downtown Santa Rosa, CA; I have reserved the upstairs:

http://www.thirdstreetaleworks.com/

We will start around noon with some food and drinks (unfortunately The Aleworks doesn’t do separate checks when reserving the upstairs, so ordering at the bar is preferred).

If you have never been to The Aleworks, let me know and I can help you navigate downtown parking.

I hope to see you all there.