Solaris 11 as an NFS client to Linux


Other strangeness again, but I am not going to blame it on Solaris this time 🙂 I was trying to make my Solaris workstation an NFS client to the Linux machine (the other way round compared to what I did months ago). /etc/exports was well configured on the Linux side, and I could actually mount my home directory from the machine itself:

mount localhost:/export/home/bronto /mnt

worked just fine. However, when I tried mounting from Solaris, I got a "No such file or directory".

After some research, it turned out that Solaris attempts to use NFSv4 by default; Linux NFS server has NFSv4 enabled, but the share was not exported with that protocol (only in NFSv3). So I could either export the share in NFSv4, or force Solaris to use NFSv3. I was short on time so I chose the second solution.

My /etc/auto_home now looks like this:

#
# Home directory map for automounter
#
bronto  -vers=3 linuxws:/export/home/&
+auto_home

and that just works. But I guess I'll be trying the NFSv4 version soon in the future 🙂

Faking a process name


Sometimes, for testing purposes, you may need to pretend you have more processes named, e.g., ntpd than you actually do. In my case, I was testing a cfengine policy that should kill all processes named ntpd if they are more than one, and then start a new ntpd from a clean state.

Doing that in perl is very easy. In fact, not only the $0 variable holds the name of the process, but it works also the other way round: if you assign $0, it will change the process name in the system's process table.

So, to fake an ntpd process, you can create a perl script called ntpd like this one:

#!/usr/bin/perl

$0 = q{ntpd} ;
sleep 600 ;

and you run it.

This trick allowed me to test if my policy worked as expected (it did, by the way 🙂

Can you do it with a one-liner? Of course you can:

perl -e '$0="ntpd" ; sleep 600'

Enjoy!

Professional achievements and code readability: a true story

Awards may not be always on time, but sometimes they come. And when awards come from your co-workers, who often understand your job better than your boss does, that’s even better. That happened to me today, and I think it is a story that is worth telling.

At one of my previous employers, we needed to mass-load accounts into a custom mail system, which used a relational database to handle the userbase (why not an LDAP directory? Don’t ask!). Customers would send us two CSV files (or Excel files which we would convert into CSV) with the accounts information, and I wrote a Perl program (and a handful of classes) that would do just that: read the two files, create the accounts in the DB, and create a shell script to fix the filesystem part. … Continue reading

Say no to letter!

Nothing against the postal service here. Rather, I was trying to turn a small PDF document, four A4 pages, into a booklet that could fit into a single A4 sheet, printed on both sides. Nothing frightful here, it's a simple command chain. Yet, some commands in the chain switch from the A4 format to letter, and I happen not to like their initiative 🙂

If you need to make such a booklet from file.pdf to booklet.pdf, and want it to stay A4 throughout the process, you need to do this:

pdf2ps file.pdf - | psbook | psnup -2 -pa4 | ps2pdf -sPAPERSIZE=a4 - booklet.pdf

For some reason, psnup and ps2pdf think they should turn A4 into letter. To force A4 in psnup, you use the -p option. ps2pdf uses the same options as ghostscript (gs), hence the -sPAPERSIZE=a4 there.
Also notice the dash in pdf2ps file.pdf -: if you don't use the dash, ps2pdf will output to file.ps, the rest of the chain will starve, leaving you with a funny empty booklet.pdf document.
ps2pdf is also a bit picky, and you need to explicitly tell it that it should read from the standard input (the dash) and write to booklet.pdf.

Have fun!

How does delay influence a clock’s accuracy?

Running ntpq -p to check how ntpd is working is one of the first things a sysadmin learns when trying to debug problems with ntpd. One of the first questions which arises is "how do delay, offset and jitter relate?", or even "what do delay, offset and jitter mean?". Well, today I stumbled across a graph that gives me the opportunity to explain this in practice.

Let's start with explaining these three terms as bare-bones as possible. Note that definitions given below are here just to give you an idea and are no way accurate; please go to the NTP documentation, NTP FAQ or community support sites to get the real ones.

  • delay is an estimate of how many milliseconds an NTP packet takes to travel from a server to your client.
  • offset is an estimate of how many milliseconds your computer's clock differs from UTC.
  • jitter is an estimate of how these measurements are accurate, and it's non-negative: the smaller the jitter, the better accuracy.

Now look at this graph: … Continue reading

Not enough bits this time

It was some time I didn't go through the NTP docs and I felt I was missing some of the new interesting features of ntpd. So I decided to freshen my knowledge and go through them once again, and I allocated some time every week to read the docs.

Recently I started reading "Event messages and status words". I almost immediately found one thing I could not understand: apparently, the codes in the system status word and peer status word exceeded the assigned capacity of four bits. But I was tired and I decided to wait until the week after and re-read it.

Yesterday I started reading it again, and I also went through my notes from last time I read the doc. No luck, it was not that I was tired: there really were codes that could not be represented using just four bits. But, again, I thought I was mistaken and sent a message to the questions@ntp.org list.

And, to my surprise, it was actually a bug!

This drives me to two considerations.

The first: read the docs, ask yourself questions, then ask for clarifications if you need them, and report bugs if you happen to find one.

The second is actually a joke: only a pain-in-the-ass like me could bother enough to read that document, and count the bits and the codes, and find a mismatch. What a poor reputation I am building for myself 🙂