Retrieving sysconf(), pathconf() and confstr() values from the command line

On Linux and Solaris systems, the confstr() function and the sysconf() and pathconf() system calls can be used to programatically retrieve system, file and path limits. Periodically I need to view the value of a variable returned by sysconf(), pathconf() or confstr() from the command line. When these situations arise, I turn to the getconf utility. Getconf accepts a system variable name as an argument, and returns the value assigned to that variable:

$ getconf LONG_BIT
32

Getconf can also be invoked with the “-a” option to display all system and path variables along with their values:

$ getconf -a | more

AIO_LISTIO_MAX:                 4096
AIO_MAX:                        undefined
AIO_PRIO_DELTA_MAX:             0
ARG_MAX:                        1048320
ATEXIT_MAX:                     undefined
BC_BASE_MAX:                    99
BC_DIM_MAX:                     2048
BC_SCALE_MAX:                   99
BC_STRING_MAX:                  1000
CHARCLASS_NAME_MAX:             14
CHAR_BIT:                       8
CHAR_MAX:                       127
CHAR_MIN:                       -128
[ ..... ]

This is a useful utility, and is installed in /usr/bin on all the Linux and Solaris hosts I tested.

Setting up the OpenBSD watchdog daemon (watchdogd)

The watchdog daemon (watchdogd) was introduced in OpenBSD 3.8, and can be used to help machines automatically recover from system hangs. If the OpenBSD hardware watchdog daemon is enabled, it will periodically update the hardware watchdog timer built into the system. If this timer is not reset for a period of time, the hardware will reset itself. The watchdog daemon is not enabled by default, and can be enabled (assuming OpenBSD can find a watchdog timer in your system) by adding a pair of empty quotes to the watchdog_flags variables in /etc/rc.conf:

$ grep watchdog /etc/rc.conf
watchdogd_flags=”” # for normal use: “”

The update interval is controlled through the kern.watchdog.period variable, which can be set in /etc/sysctl.conf, and viewed with the sysctl(8) command:

$ sysctl -a | grep watchdog
kern.watchdog.period=30
kern.watchdog.auto=0

Using the hardware watchdog can be useful when you are running routers and access points in remote locations, and don’t want to spend time driving to a remote location to reboot a hung system. I always add an rc script to the servers I support to E-mail me when the system boots. If I get an E-mail while I am performing planned maintenance, I can toss it in the trash can. If I get an E-mail because the machine reboots due to faulty hardware or a kernel bug, I will know that the system reset, and can begin investigating the the source of the problem. There are definitely times (e.g., clustered nodes) when it’s better to leave the hardware watchdog disabled, and have a monitoring station alert you to a hung system.

Concert review: Godsmack and Rob Zombie

On the last Metallica tour I got to see Godsmack open for James Hetfield and company. Prior to the concert, I had only heard a few Godsmack songs, and those were the tunes that got played excessively on the radio. Since I was there to see Metallica, I said what the heck, and decided to give Godsmack a shot at making my musical circle. The band did just that, and when they played the song “Voodoo,” I knew immediately that I liked them. So when ticketmaster pinged me a month or two ago to let me know that Godsmack was going on tour with Rob Zombie, I decided to get tickets and wander out to see them again.

The show started with Rob Zombie taking center stage after a band called Shinedown performed. Rob is quite an eccentric person, so I had no idea what to expect. It didn’t take much time until I was scared (he had a list of serial murders scrolling behind him at one point during the show) and amazed (the band had energy like no other band I have seen) with Rob Zombie’s performance. Rob and his band mates were bouncing around the stage like kids who had too much sugar, and they belted out numerous hits, including “Foxy Foxy,” “Never Gonna Stop,” “More Human Than Human,” “Thunder Kiss,” “Dragula,” “Living Dead Girl,” “Feel So Numb,” “American Witch” and a few others I didn’t recognize. Rob Zombie definitely knows how to put on a good show, and it looked like they were loving every minute they spent on stage.

Rob eventually finished his set, and the roadies wandered to the stage to set up Godsmack’s equipment. While I was down grabbing some water, I heard firecrackers go off, and as I walked back to my seat, I got to watch a tribute to rock and roll on the overhead monitors. Once the tribute finished, Godsmack’s lead guitarist started jamming, and Sully belted out the opening tune. The band sounded good, and they were definitely there to rock out with some hard edgy tunes. Their new album is pretty good, but I definitely prefer the material on “Awake,” “Faceless,” “Godsmack” ” and “The Other Side” to the new stuff. Luckily for me, they played a ton of their old stuff, including “Serenity,” “Awake,” “Re-Align,” “Straight Out Of Line,” “Keep Away,” “Changes,” “Faceless,” “I Stand Alone,” and the classic hit “Voodoo.” While the guys in Godsmack where nowhere near as energetic as Rob Zombie, their music sounded awesome, and I had a blast at the show!

Setting the timezone on OpenBSD servers

I have performed a number of OpenBSD installations in the past, and have always used the installer to set the timezone. One system that I recently built didn’t have a timezone set, which required me to run the zic(8) utility manually to change the timezone on the system. To set the servers timezone to Eastern with support for daylight savings time, I executed zic with the “-l” (Use the given time zone as local time) option and the timezone I wanted to use:

$ zic -l EST5EDT

Once the timezone was set, I used the rdate utility to synchronize the time on the server:

$ rdate -nv pool.ntp.org

If your not certain which timezone to use, you can check the directory /usr/share/zoneinfo. The zoneinfo directory contains the full list of timezones that can be passed to zic.

Install OpenBSD packages to alternate directories

I run OpenBSD on a few Soekris 4801s. To get an image “prepped” for the Soekris, I use the directions on the Installing OpenBSD on Flash website. Periodically I need to apply patches to the images, which requires me to adjust the “make install” process to install the package to an alternative location. To apply a patch to a package and install it to an alternate location, I first apply the patch to the package that contains the errata:

$ cd /usr/src/usr.sbin/dhcpd

$ patch -p0 < 006_dhcpd.patch

After the patch is applied, I use the build procedure outlined in the patch header to create the binaries and supporting infrastructure:

$ make obj && make

/usr/src/usr.sbin/dhcpd/obj -> /usr/obj/usr.sbin/dhcpd
cc -O2 -pipe  -Wall   -c /usr/src/usr.sbin/dhcpd/bootp.c
cc -O2 -pipe  -Wall   -c /usr/src/usr.sbin/dhcpd/confpars.c
cc -O2 -pipe  -Wall   -c /usr/src/usr.sbin/dhcpd/db.c
cc -O2 -pipe  -Wall   -c /usr/src/usr.sbin/dhcpd/dhcp.c
cc -O2 -pipe  -Wall   -c /usr/src/usr.sbin/dhcpd/dhcpd.c
cc -O2 -pipe  -Wall   -c /usr/src/usr.sbin/dhcpd/bpf.c
cc -O2 -pipe  -Wall   -c /usr/src/usr.sbin/dhcpd/packet.c
cc -O2 -pipe  -Wall   -c /usr/src/usr.sbin/dhcpd/errwarn.c
cc -O2 -pipe  -Wall   -c /usr/src/usr.sbin/dhcpd/dispatch.c
cc -O2 -pipe  -Wall   -c /usr/src/usr.sbin/dhcpd/print.c
cc -O2 -pipe  -Wall   -c /usr/src/usr.sbin/dhcpd/memory.c
cc -O2 -pipe  -Wall   -c /usr/src/usr.sbin/dhcpd/options.c
cc -O2 -pipe  -Wall   -c /usr/src/usr.sbin/dhcpd/inet.c
cc -O2 -pipe  -Wall   -c /usr/src/usr.sbin/dhcpd/conflex.c
cc -O2 -pipe  -Wall   -c /usr/src/usr.sbin/dhcpd/parse.c
cc -O2 -pipe  -Wall   -c /usr/src/usr.sbin/dhcpd/alloc.c
cc -O2 -pipe  -Wall   -c /usr/src/usr.sbin/dhcpd/tables.c
cc -O2 -pipe  -Wall   -c /usr/src/usr.sbin/dhcpd/tree.c
cc -O2 -pipe  -Wall   -c /usr/src/usr.sbin/dhcpd/hash.c
cc -O2 -pipe  -Wall   -c /usr/src/usr.sbin/dhcpd/convert.c
cc -O2 -pipe  -Wall   -c /usr/src/usr.sbin/dhcpd/icmp.c
cc   -o dhcpd bootp.o confpars.o db.o dhcp.o dhcpd.o bpf.o packet.o errwarn.o dispatch.o print.o memory.o options.o inet.o conflex.o parse.o alloc.o tables.o tree.o hash.o convert.o icmp.o 

Once the package is built, I use the DESTDIR variable to control where the package is installed:

$ DESTDIR=/usr/images/img make install

install -c -s -o root -g bin  -m 555 dhcpd /usr/images/img/usr/sbin/dhcpd
install -c -o root -g bin -m 444 dhcpd.cat8 /usr/images/img/usr/share/man/cat8/dhcpd.0
install -c -o root -g bin -m 444 dhcpd.conf.cat5 /usr/images/img/usr/share/man/cat5/dhcpd.conf.0
install -c -o root -g bin -m 444 dhcpd.leases.cat5 /usr/images/img/usr/share/man/cat5/dhcpd.leases.0
install -c -o root -g bin -m 444 dhcp-options.cat5 /usr/images/img/usr/share/man/cat5/dhcp-options.0

I poked around on google to see which variables are available to control the build process, but was unable to find a complete list. There is a ton of cool stuff in /usr/ports/infrastructure/mk/bsd.port.mk, and I plan to cover some on the niftier variables in a future post.