Friday, June 20, 2008

I haven't dug around in the commit logs enough to figure out when support was added (looks like it has been there a while), but with Rails 2.1 the documentation caught up and ActiveRecord::Serialization#to_xml supports nested includes. Note that the syntax of the hash that :include is expecting is different from the syntax of the :include hash for find, for whatever reason, so check the docs.

Here's the commit that added the documentation: http://dev.rubyonrails.org/changeset/9093

Until api.rubyonrails.com is updated with the 2.1 API docs you can view them here: http://caboo.se/doc/classes/ActiveRecord/Serialization.html

Monday, June 16, 2008

I tried to install RHEL 5 x86_64 in a VMware Server 2.0 Beta 2 virtual machine. The host system has a 64 bit CPU and the virtual machine had been configured for a 64 bit OS. Nevertheless the installer failed with:


Your CPU does not support long mode. Use a 32 bit distribution


Some poking around turned up this VMware document. In short I had to go into the BIOS on my host system and enable Virtualization Technology. On my Dell server that was disabled by default.
I moved my Cacti install from one host to another. After dealing with some other issues the poller seemed to be running more-or-less alright. But the rrd files in the rra directory weren't updating and the graphs weren't displaying. There weren't any obvious errors in cacti.log. Looking around on the web folks mostly pointed to issues with file permissions on the rrd files or the rra directory. Sure enough, I had that problem (in the process of moving I upgraded to a new version of Cacti and switched to Dag's RPM package, which uses a 'cacti' user with a different UID than the 'cactiuser' user that my previous package had used). So I fixed that and waiting for the poller to run again, but still no updates to the rra directory. I thought I'd check that rrdtool was working, so I tried to dump out one of the rrd files:


% rrdtool dump /var/www/cacti/rra/blah.rrd
ERROR: This RRD was created on other architecture


Indeed, in this move I had gone from RHEL 4 x86 to RHEL 5 x86_64. I suppose I could have gone back to the old machine and exported the data and blah blah, but I just blew away all of the files in the rra directory and the next time the poller ran it created new rrds and all seems happy now.
I had to install Firefox on a Red Hat Enterprise Linux 5 server to run the VMware Server web UI. I did a 'yum install firefox', which pulled in a bunch of dependencies. But firefox wouldn't start:


% firefox
No fonts found; this probably means that the fontconfig library is not correctly configured. You may need to edit the fonts.conf configuration file. More information about fontconfig can be bound in the fontconfig(3) manual page and on http://fontconfig.org


As these things go, of course fontconfig was installed. So I did a 'yum list | grep font' and more-or-less started randomly installing packages until Firefox worked. The one that seemed to do the trick was xorg-x11-fonts-Type1

Monday, June 02, 2008

I'm working on enhancing nVentory to meet my employer's needs for an operations database. I'm learning Ruby on Rails in the process and encountering a number of situations that seem poorly documented online. I'm going to try to capture some of these here for posterity. I'm starting this somewhat after the fact (having been working on this project for 5 or 6 weeks now), so these aren't necessarily in the order I encountered them.

First up, problems with connecting to an LDAP server. I started with the snippit of code in the "How is it then used?" section of http://wiki.rubyonrails.org/rails/pages/HowtoAuthenticateWithRubyNetLdap. Since the LDAP servers I'm talking to are Microsoft Active Directory servers I figured I'd automagically figure out which server to talk to via the DNS SRV records that AD publishes:


require 'resolv'
require 'net/ldap'

res = Resolv::DNS::new()
ldapsrv = res.getresource('_ldap._tcp.my.domain', Resolv::DNS::Resource::IN::SRV)
ldap = Net::LDAP.new :host => ldapsrv.target, ...


That was failing with an exception:


Net::LDAP::LdapError (no connection to server):
/Library/Ruby/Gems/1.8/gems/ruby-net-ldap-0.0.4/lib/net/ldap.rb:1021:in `initialize'


Unfortunately the code in Net::LDAP eats the real exception and throws its own generic "no connection to server" exception in the face of any problems creating the TCP connection to the server. I suppose I could have used the debugger to break on the rescue statement, but I just hacked in a "puts" into the library to see that the real exception was:


can't convert Resolv::DNS::Name into String


Bah humbug. ldapsrv.target is a Resolv::DNS::Name, which has a to_s method. So change the Net::LDAP.new to:


ldap = Net::LDAP.new :host => ldapsrv.target.to_s, ...

Sunday, December 26, 2004

Upgraded to Fedora Core 3? yum-arch tells you it has been deprecated? yum won't read your repositories anymore, complaining that repomd.xml doesn't exist? You've been to http://linux.duke.edu/projects/metadata and it doesn't tell you what has replaced yum-arch? Sigh, me too. The magic answer is 'createrepo', there's an RPM for it that comes with FC3.

Saturday, November 06, 2004

Got myself a shiny new Nokia 6820 from AT&T Wireless. One of the attractions was the possibility of Internet access using Bluetooth from my PowerBook to the phone and GPRS/EDGE from the phone to the big I. It took some poking around but it works and seems fairly speedy. This page has a set of instructions for a different phone that apply pretty well. I'm using the same "Nokia GPRS CID1" script that he's using. In the PPP setup I left Account Name and Password blank and put "proxy" into the Telephone Number field. "proxy" is the default APN for AT&T Wireless.

Wednesday, July 21, 2004

Notes to myself about how to use GPG:

Export my own key for sending to others:
gpg --armor --export [my name]

Import another person's key:
gpg --import [key file]
or
gpg --keyserver [server] --search [their name]

Then sign their key and indicate that I trust it (GPG will prompt for degrees of trust):
gpg --edit-key [their name]
sign
trust
save

Wednesday, October 01, 2003

Have you upgraded OpenSSH to 3.7.1p2 because of the security problems, do you have sshd configured to use PAM, and now your Windows clients can't connect? Hey, what a coincidence, me too.

If you look a little closer at the dialog box that the Windows client pops up when you do a Quick Connect, you'll notice that there is a pull down menu at the bottom labeled Authentication Method. It defaults to Password. Try switching it to Keyboard Interactive and you should be able to log in.

It seems that the best fix for this is to edit the Quick Connect profile and add Keyboard Interactive to the acceptable authentication methods. Then in the Quick Connect dialog box choose <Profile Settings> for the Authentication Method. Connect and then choose Save Settings.

Monday, August 25, 2003

Want to make sendmail's -bP flag work? What's -bP do, you ask? It prints the size of your mail queue (rather like the last line of mailq (aka sendmail -bp)) without printing all of the entries in the mail queue.

First make sure your sendmail was compiled with shared memory support. Run 'sendmail -bv -d0.12 root' and look for SM_CONF_SHM. (Documented here)

Then add the following to your sendmail.m4:

define(`confSHARED_MEMORY_KEY', `42')

The value is arbitrary, it just can't be 0 (zero). If you happen to be running more than one copy of sendmail on your box with different queues, each sendmail config file should use a different value. (Documented (vaguely) here) Rebuild your sendmail.cf, restart sendmail, and -bP should work.