Author Archive

Roomba Lives?

Thursday, July 6th, 2006

I recently acquired an open-box Roomba Discovery SE made by iRobot for $50. It seemed like a good buy, I could always hack it for a robot base if it didn’t work. The only thing missing was the fast charger.

Digging around in the various junk boxes that inhabit the dark corners of my basement yielded an old Gateway laptop adapter. At 19V and 40W it was “close enough for me” to the Roomba’s stated power requirements of 22V and 1.5A. I quickly disassembled the included home base charging unit to check the required polarity (center positive it seems).

After soldering on the appropriate size power plug I plugged in the home base charger. Lo and behold, I got a green power light! The Roomba, however, remained dark and silent. I stuck it on the home base and the docking light came on. Still no response at all from the Roomba.

Much to my delight the power button started pulsing red after about 30 seconds of charge. Yay! I gave it a few minutes and was rewarded with some plaintive beeping when I attempted to power on the Roomba. There was hope! A few hours of charging and the little Roomba was running around proudly cleaning up bits and pieces from my carpet under the workbench.

I have now been using the Roomba for a couple of days and am quite impressed. The navigation logic is bang on and even does a fine job in our living room with a large sectional, coffee table and several other obstacles. The battery life is not too good, 30-45 minutes of cleaning on carpet. It does seem to be improving with every charge, so perhaps the battery just needs some conditioning.

Here are some links I have come across in researching the Roomba series.

Perl GetOpt Not Working

Thursday, July 6th, 2006

I have run into this same problem a few times so I am documenting it here. When using GetOpt::Long and friends I would be mystified when the options were ignored. For example:

#!/usr/bin/perl

use strict;
use warnings;
use Getopt::Long;
my $debug = 0;

my $result = GetOptions( "debug" => $debug );
print "Debug flag is $debug\\n";
wriley ~/bin> ./getopttest.pl
Debug flag is 0
wriley ~/bin> ./getopttest.pl --debug
Debug flag is 0
wriley ~/bin>

The options are completely ignored! A short time of googling later and I remembered the solution.

#!/usr/bin/perl

use strict;
use warnings;
use Getopt::Long;
my $debug = 0;

my $result = GetOptions( "debug" => \\$debug );
print "Debug flag is $debug\\n";
wriley ~/bin> ./getopttest.pl
Debug flag is 0
wriley ~/bin> ./getopttest.pl --debug
Debug flag is 1
wriley ~/bin>

The key is escaping the $ in the GetOptions() statement. If you don’t escapey, it don’t workey!

Adding a large number of devices to Cacti

Wednesday, June 28th, 2006

There is a very nice open source snmp graphing and monitoring package avaiable called cacti. I have used it for almost a year now and have been very pleased with its functionality and ease of use.

Recently at work I had the need to graph a large number (300) of network devices and a handful of Linux servers. Being the sort of guy that would rather write scripts than manually enter 300 devices via the cacti web interface, I cobbled together some perl and php code. I had a list of network devices in a CSV file.

The format of the file is:

ID,City,State,IP Address.

If you use the scripts below you will need to edit them to fit your own device data. They are provided for illustration purposes and will most likely not work for you “out of the box”.

Update See this thread for more advanced scripts.

Process to add hosts and create graphs for each

  1. fixCSV.pl Branches.CSV branches.csv
  2. Check branches.csv for empty IP address fields and remove
  3. mkBranchSql.pl branches.csv > branches.sql
  4. branches.sql ==> DB
  5. make_host_graph.pl branches.csv > host_graph.sql
  6. host_graph.sql ==> DB
  7. make_host_snmp_query.pl branches.csv > host_snmp_query.sql
  8. host_snmp_query.sql ==> DB
  9. foreach host_id do php run_data_query.php $host_id
  10. foreach host_id do php run_host_new_graphs.php $host_id
  11. Clear Poller Cache (php rebuild_poller_cache.php)

Process to add each host to proper state in graph tree

  1. create alphabetical flat file of state abbreviations, states
  2. mkBranchStatesSql.pl states > branches-states.sql
  3. branches-states.sql ==> DB
  4. mkGraphTreeSql.pl branches.csv > graph_tree_items.sql

Autocreate thresholds

  • foreach host_id do php run_autocreate.php $host_id

Files

Perl

PHP

Linux Quiz #002

Wednesday, June 28th, 2006

The Patch Command (submit answer)

Create a patch file called helloworld.patch suitable for use with the
patch command to fix a typo in helloworld.c. Also, give the command line necessary to apply the patch.

To test the syntax of the .c file use: gcc -o helloworld helloworld.c

helloworld.c