Shane Duffy

Spotlight indexing timemachine backups

Posted by: Shane Duffy on: April 13, 2009

This is a quick follow up post to my earlier one about creating timemachine backups on a network share.

A good tip/trick for anyone who has setup backups to a network share is to disable spotlight from indexing this volume as it slows down the backup process a lot. This can easily be disabled by going to the spotlight panel in system preferences.

To avoid this slow down, as soon as the share is mounted for the backup process go to Spotlight’s Privacy panel in System Preferences. Use the ‘+’ button at the bottom, select your backup share, and Spotlight will then ignore it. If Spotlight has already started indexing it, it should immediately stop and the backup will speed up.

spotlight

CurrentCost CC128 – Battery Pack

Posted by: Shane Duffy on: April 10, 2009

Having got a CC128 currentcost energy monitoring device recently and have been playing with it writing some nice new software but the main aim was to cut down on the power usage which comes from leaving devices plugged in and not used around the house.

The currentcost device needs to be plugged into power which limits where you can go with it and its makes it a bit unfriendly to go around the house finding devices which are using power.While doing some research for writing my application I noticed this picture with a battery pack powering the currentcost unit.

For any one who wants one this is all you need.

  1. Battery pack
  2. DC Power Plug 2.8mm
  3. PP3 Clip + Cable

Very simple to put together and you will end up with something which looks like this and can be used to power your currentcost while you move around the house finding devices which are using power.

Current Cost Battery Pack

Current Cost Battery Pack

Sorry for the bad photo used the phone as I was too lazy to get the camera out.

CurrentCost cc128 Ubuntu data logging

Posted by: Shane Duffy on: March 19, 2009

I decided to get some logging data from the CurrentCost (cc128) model which I have but I was having issues with getting data from the /dev/ttyUSB0 port at which it was attached using the pl2303 drivers for usb to serial.

A simple cat of /dev/ttyUSB0 lead to just gibberish been output on the terminal. Poking around at the system I found that the cable im using has the pl2303x chip set which can have driver issues with some older kernel modules. There are patchs for the older kernal modules which stop this device been picked up as the older incompatible pl2303 (see here).  The real cause of my problems was the serial port settings which I was able to resolve by using minicom to set the right settings for the port.

The cc128 uses 57600 bps 8N1

You can use the minicom application to set this and then using cat /dev/ttyUSB0 will work fine for you.

Ill add another update later once I start logging the data. Plan is to be able to log all data to mysql DB, create a RRD file at the same time for some simple graphs and also allow a real time feed of the application in the form of an AJAX web client I think.

Update: Just found the link to the full xml spec of the CurrentCost cc128 v11 that I have thanks to the CurrentCost founder MartinDix

On a note for anyone who needs to factory reset there CurrentCost energy monitor you can just hold down any 2 of the buttons when powering up the device and it will reset everything to factory defaults.

CurrentCost Electricty Meter

Posted by: Shane Duffy on: March 14, 2009

For a while now I have been looking at different products which can provide an insight into electrical energy usage with a realtime display and preferably a link to a computer to provide logging, graphing and analysis. Just when I though I would be building my own with some current induction clamps I came across www.currentcost.co.uk which provides a energy monitoring device which can be plugged into a computer using usb port (Serial over USB connection).

CurrentCost cc128 Energy Monitor

CurrentCost cc128 Energy Monitor

I ordered the device after emailing the company and discussing my needs and figuring out what I would need to monitor a 3 phase power connection which I have at the house. The currentcost setup is really simple it is a basic induction loop in the form of a cable clamp which is placed around the power cables in your meter box and connected to a transmitter box. The receiver is a nice display which can store historical data and show current energy usage and give a guide cost of the usage.

I think this device is a very cool idea as it also the basic user to get an idea of whats wasting electricty even when they are asleep at night and for the more advanced user it also provides access to data every 6 seconds and monitoring of up to 10 individual devices through the base station. The device allows you to see how much a device uses by showing your the changed usage when you switch something on like your dishwasher.

I have only been using the device for a few hours now and im really liking it already, Spotting lots of devices which are left on all the time wasting power and costing extra for no reason. I can see loads of usage for this and will be creating a few applications for this device.

Using .htaccess to provide a maintenance page for your website

Posted by: Shane Duffy on: November 20, 2008

At some stage most of us have needed to work on our websites and move things around, For most people would do this live on the website and this does not make for a great experience for your customers and clients who end up visiting broken and half finished pages. Or even worse the search engine crawlers that come along and find sample text on your pages.

One of the neat tricks of a .htaccess file is been able to enable a maintenance page for all your visitors to your website but still been able to access the website yourself for testing and development.

RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} !^86\.43\.107\.123
RewriteCond %{REMOTE_HOST} !^86\.43\.107\.201
RewriteCond %{REQUEST_URI} !/maintenance\.html$
RewriteRule .* /maintenance.html [R=302,L]

The above when placed in a .htaccess file will redirect all clients who are not coming from 86.43.107.123
or 86.43.107.201 to the maintenance.html webpage

Simple yet very handy to have!

HP Jetdirect Cold Reset

Posted by: Shane Duffy on: September 9, 2008

I have a few HP laser printers which are connected to our network. The problem I was having was one of the network cards in the printers was not showing up anymore and I needed to preform a reset of the configuration in order to clear the settings on the card and reconfigure the printer.

The procedure that I found for resetting the HP 2300 DTN is as follows:

  1. Turn the printer off
  2. Hold the green button on the front
  3. Power the printer on (while holding the green button still)
  4. Keep pressing the green button until all three lights are on the front panel then release
  5. Then use the up arrow to go from Select Language to “Cold Reset”
  6. Press the green button again and the printer will reset to factory defaults.

Hope this helps anyone who is having problems either connecting to a Hewlett Packard networked laser printer. This procedure is useful if you have bought one of these printers second hand and need to reset the IP range that the printer is using.

Google App Engine

Posted by: Shane Duffy on: May 6, 2008

Google App Engine has just added some more invitations for developers who missed out on the first round.

http://appengine.google.com

Ubuntu 8.04 only 1 day to go

Posted by: Shane Duffy on: April 23, 2008

With only 1 more day left to the official release of Ubuntu 8.04. Check back here were we will give any guides and tips needed to get this release installed under Parallels on the MAC and also VMware fusion offering. I will also go true the details for anyone who has already 7.10 installed and wants to preform an upgrade.

Using MRTG to monitor records in a MySQL table

Posted by: Shane Duffy on: April 21, 2008

This week I was working on a new project and for the project I needed to keep an eye on the lenght of a queue which was stored in a MySQL table. I already have the very useful MRTG tool installed on the server so I decided to make use of it to create a simple a quick graphs.

For anyone who doesn’t already know what MRTG is its a very handy tool for graphing data. It is normally used to graph things such are network interface traffic stats and works with an RRD data store in the background storing 5 minute averages. MRTG makes it very easy for users to monitor custom data aswell and has a simple input format. All that is required is to write a script which will output 4 lines of data.

Line 1 -current state of the first variable, normally ‘incoming bytes count’
Line 2 -current state of the second variable, normally ‘outgoing bytes count’
Line 3 -string (in any human readable format), telling the uptime of the target.
Line 4 -string, telling the name of the target.

In order to get started graphing that data that I wanted I created this small script below

#!/bin/sh
echo 0
mysql -h localhost -u USER --password=PASSWORD -e "$1" DATABASE | tail -1
echo 0
echo "Queued Items"

When this script is called it takes 1 argument which is in the form of the count query you want to preform. eg “Select count(*) from table_X”

Then in our MRTG cfg file we need to add an entry to call and display this data.

Target[Blackarrow_queue]: `/graphs/collector_links "Select count(*) from table_X"`
MaxBytes[Blackarrow_queue]: 10000
Options[Blackarrow_queue]: nopercent,growright,nobanner,nolegend,noinfo,gauge,integer,transparent,noi
Title[Blackarrow_queue]: Queue Lenght
PageTop[Blackarrow_queue]:<h3>Queue</h3>
YLegend[Blackarrow_queue]: records
ShortLegend[Blackarrow_queue]:
LegendI[Blackarrow_queue]:
LegendO[Blackarrow_queue]:records

For a graph like this you’ll want to use similar options to the ones I used above. nopercent disables percentage display, growright tells the graph to read from left to right instead of the default right to left, gauge tell MRTG that the data points are “current status” measurements rather than ever-increasing counters, noi tells MRTG there is no “input” data to compare against “output” data and a few cosmetic display options. The resulting graph looks something like this:

MRTG Custom Stats

Removing all those .svn files

Posted by: Shane Duffy on: February 20, 2008

Im working on a project now and using subversion a lot for the project. One of the things that has been annoying me in the last while is sometimes I want to move code into another svn repository while working on it, and really the only way to do it is to remove all the .svn directories check out the top level empty directory of the repository I want to place the code into and then do svn add *

The only problem been that removing all the .svn files can be a real pain on large projects.

find . -type d -name ‘.svn’ -print0 | xargs -0 rm -rdf

Is a very handy command that I now use all the time. What this does is find all the .svn directories and removes everything below them, leaving me free to add the code back into another subversion repository.

Update: This is also very handy way of reducing the transfer size if using SCP to move your code between servers. As when working on SVN subversions files the .SVN directories can double the size of your code on disk as they store copies of the files in the .svn folders for later comparison