Friday, March 27, 2009

Sprint EVDO Mobile Broadband on Ubuntu

So I just got a Sprint EVDO USB stick to allow connectivity when there's no WiFi around. I did some quick Google searches and it looks like it's supported. Little did I know how well :) I plugged in the device to a USB port and the kernel started loading appropriate modules and gave me the /dev/ttyUSB0 through /dev/ttyUSB3 ports. At this point I thought I'd pick it up at home.

I couldn't resist one last Google search, however, and it was worth it :) While the box for the device (a Sierra Wireless 598U) doesn't mention Linux by name, Sprint provides a full installation guide for Ubuntu (Fedora and others are there too). I was very pleasantly surprised. Everything just works!

Thursday, March 26, 2009

Multi-Column Database Indices in Sqlite3 and Ruby on Rails

In my previous post about database indices in Sqlite3 and Ruby on Rails, I'd observed that Sqlite didn't seem to support multi-column indices properly. It turns out that while Sqlite does support them, I was using syntax in my Rails model which had the effect of ensuring that both the columns in my index were checked separately for uniqueness. Assuming you have the category_id and name fields in a table such that the combination of those two fields has to be unique, the correct way to do multi-column indices is as follows:
In your database migration,
add_index :contests, [:category_id, :name], :unique => true

In your data model,
validates_uniqueness_of :name, :scope => :category_id
That last line in the model is key. Syntax similar to the add_index line above won't work when using the validates_uniqueness_of validator.

Saturday, March 21, 2009

The Magic SysRq Key - Commandline Edition

So earlier today I was stuck trying to bounce a remote host that had a Software RAID volume. It turns out for some reason (I still suspect a faulty volume in the RAID1 volume) nothing was able to write to the mounted RAID volume. All processes kept getting hung and drove the load up to 25. Responsiveness was still good since this load was actually due to I/O waiting processes that kept getting some CPU time and not CPU-intensive processes trying to share a couple of processors.

In any case, after manually failing the partition that was causing problems with the RAID volume I still wasn't able to bounce the box since the RAID volume won't stop or sync and actually halted the shutdown process. I thought about the magic SysRq but realized I was ssh'ed in and that won't work. For some reason I didn't think of searching for a way too invoke the magic SysRq processes from the commandline. I looked for a way to force a shutdown and found this blog. It worked like a charm!

Intriguingly enough, when the host came back up the RAID volume remounted and both partitions that formed the RAID volume were fine as reported by mdadm. What's more all seemed well with the mounted volume and I was able to read/write to it just fine. I'll be keeping an eye on that for a bit.

Thursday, March 19, 2009

A Scientific View on Database Indices

I've been playing with Ruby on Rails by seeing how easy (or difficult) it would be for me to re-write an existing mod_perl2 application within RoR. While the original application uses PostgreSQL as its backend database (numerous reasons but the top few are: timestamptz, multiple columns in a table that can default to now(), support for transactions - even nested ones), I decided to use sqlite3 for the initial prototype of the application before it grew beyond 2-3 models.

It seems that either sqlite3 or RoR 2.0.5 doesn't support multi-column indices on a table. One of those two converts a single two-column index into 2 one-column indices - not quite the behavior I wanted. I'll try to switch to PostgreSQL to see if the behavior re-surfaces.

While I was scouring Google for sqlite3's limitations, however, I came across this interesting article that details the kind of scientific analysis that should be conducted on your data to determine the order of columns in a multi-column index. Very informative.

Monday, February 23, 2009

libttf.so.2 for package: nagios

This was the ominous error I got every time I tried to upgrade nagios from what CentOS 5 provides in its base repository (2.12) to the more recent 3.0.6 provided in RPMForge's repository. I couldn't figure out what was going on and the Internet was full of accounts of the error that magically vanished the next day.

I don't know what they all had done wrong but I finally figured out what I'd done wrong to deserve this error :). I'd made the mistake of installing the rpmforge-release package meant for CentOS 4 instead of CentOS 5. This meant I was trying to install the el4 version of the nagios-3.0.6 package which apparently had this dependency. Before encountering this problem, however, I'd switched to the CentOS 5 repository so I didn't make the connection until I decided to read every letter of a yum install report:
[root@services ~]# yum install nagios
Loading "priorities" plugin
Loading "fastestmirror" plugin
Loading mirror speeds from cached hostfile
* epel: mirror.hiwaay.net
* rpmforge: apt.sw.be
* base: mirror.trouble-free.net
* updates: centos.mirror.nac.net
* centosplus: centos.mirror.nac.net
* addons: mirror.nyi.net
* extras: centos.mirror.nac.net
0 packages excluded due to repository priority protections
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package nagios.i386 0:3.0.6-1.el4.rf set to be updated
--> Processing Dependency: libttf.so.2 for package: nagios
--> Finished Dependency Resolution
Error: Missing Dependency: libttf.so.2 is needed by package nagios
I then realized why this problem might've fixed itself the next day - the yum cache might've become stale enough to be rebuilt. At that time yum would realize the el4 repository no longer existed and would remove it from the cache and replace it with the information about the el5 repository. When running a yum install nagios against the el5 repository, we get much more pleasant output:
[root@services ~]# yum install nagios
Loading "priorities" plugin
Loading "fastestmirror" plugin
Loading mirror speeds from cached hostfile
* epel: mirror.hiwaay.net
* rpmforge: apt.sw.be
* base: mirror.trouble-free.net
* updates: centos.mirror.nac.net
* centosplus: centos.mirror.nac.net
* addons: mirror.nyi.net
* extras: centos.mirror.nac.net
0 packages excluded due to repository priority protections
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package nagios.i386 0:3.0.6-1.el5.rf set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
nagios i386 3.0.6-1.el5.rf rpmforge 3.6 M

Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 3.6 M
Is this ok [y/N]: y
The moral of the story? After changing anything in your yum repositories, make sure to run:
yum clean all
yum makecache

Friday, February 6, 2009

Upgrading Ubuntu 8.10 (Intrepid Ibex) to KDE 4.2

With KDE 4.2 officially released and in possession of quite a few positive reviews (unless I'm looking in the wrong places), I wanted to give it a shot but it hadn't been back-ported to Ubuntu 8.10 yet. I searched around and found that one can enable an experimental Ubuntu repository where one can install KDE 4.2 from.

Long story short, I ended up following this site on upgrading to 4.2. I ran the apt-get while I was away from my computer and when I returned, lo and behold, instead of finding a nice KDE 4.2 package install log I found an error with installing some packages. I did what anyone else would do - I didn't believe my eyes and re-ran the command hoping to brute force my way through this :) Here's what I saw:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
krita-data kword-data koshell kthesaurus kpresenter krita kugar kword ksysguardd kchart karbon compizconfig-backend-kconfig
kspread libpoppler-qt2 kplato libwv2-1c2 kexi libpqxx-2.6.9ldbl kpresenter-data
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
kde-window-manager kdebase-workspace-data libplasma3
The following packages will be REMOVED:
libplasma2
The following NEW packages will be installed:
libplasma3
The following packages will be upgraded:
kde-window-manager kdebase-workspace-data
2 upgraded, 1 newly installed, 1 to remove and 73 not upgraded.
6 not fully installed or removed.
Need to get 0B/10.0MB of archives.
After this operation, 12.3kB of additional disk space will be used.
Do you want to continue [Y/n]?
(Reading database ... 252512 files and directories currently installed.)
Preparing to replace kde-window-manager 4:4.1.3-0ubuntu1~intrepid1 (using .../kde-window-manager_4%3a4.2.0-0ubuntu1~intrepid1~ppa7_i386.deb) ...
Unpacking replacement kde-window-manager ...
dpkg: error processing /var/cache/apt/archives/kde-window-manager_4%3a4.2.0-0ubuntu1~intrepid1~ppa7_i386.deb (--unpack):
trying to overwrite `/usr/share/kde4/apps/kconf_update/plasma-add-shortcut-to-menu.upd', which is also in package kdebase-workspace-data
dpkg-deb: subprocess paste killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/kde-window-manager_4%3a4.2.0-0ubuntu1~intrepid1~ppa7_i386.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
After much searching and trying tools like synaptic and aptitude I went for the sniper rifle: dpkg. I removed the offending packages kde-window-manager and kdebase-workspace-data. Now my apt-get is running smoothly in the background. Let's hope it finished upgrading me to KDE 4.2 :)

Wednesday, February 4, 2009

KMail Integration with Microsoft Exchange

I found this interesting post on the kde-pim mailing list which is very to-the-point and informative on how to connect KMail to Exchange. You do need IMAP enabled on the Exchange server but once you get over that hurdle - and believe me, in a pure Microsoft shop it's a big hurdle - you're good to go.

I haven't gotten Calendar integration working just yet but I haven't put a lot of time into it yet. This page on the KDE Wiki explains how to use webdav to perform one-way syncs against an Exchange server using a plugin for KOrganizer.

Edit: Even brought it to my attention that the KDE Wiki link is no longer working.  It seems the KDE wiki has changed structure since I was last on it.  I found Jason Kasper's blog, however, where he's talking about a ruby-based solution to the 1-way sync between an Exchange OWA server and KOrganizer.