Tag Archives: jails

addendum to jails vs time and date

Last month I wrote a little note about getting time and date correct in jails.

What I failed to mention is that I started getting constant mails like the following from my jails

adjkerntz[53498]: sysctl(set: “machdep.wall_cmos_clock”): Operation not permitted

The reason is that the jail tries to update the cmos clock, which of course it can not.

That is a simple fix in the system crontab within the jails.
Simply comment the out the following:

# Adjust the time zone if the CMOS clock keeps local time, as opposed to
# UTC time. See adjkerntz(8) for details.
1,31 0-5 * * * root adjkerntz -a

After some quick googling on this I found the following mailing list archive thread, but I feel it was worh reiterating it once more here.


jails2xml ready for review!

Ok, so after som nice flow and a whole lot of code cleanup I think it is actually presentable now.
So without any further ado, get a copy at http://kosmos.ttyv0.se/attachments/download/41/jails2xml.sh , give it a try and please give me some feedback.
There are a couple of things to be added and updated, this is not “finished”. (like splitting config options at the top to a separate file and giving better granularity to the host info added to the xml.)
But I wanted the chance to get feedback as soon as possible and also might not have as much time to work on this as I would like for a while.

Short description:
This script will with its default options run through your /usr/local/etc/ezjail/ directory and add all the set options for each jail to an xml file called jails.xml in the current directory.
It will also add some info about the host system, and the time of creation of the xml.
So far tested successfully on systems running 7.2-R and 8.0-R.

An anonymized sample of a jails.xml with a single jail configured on the host:
<?xml version="1.0" encoding="iso-8859-1"?>
<exec>/bin/sh /etc/rc</exec>
<allinfo>FreeBSD xxx.xxx 8.0-RELEASE-p2 FreeBSD 8.0-RELEASE-p2 #0: Tue Jan  5 16:02:27 UTC 2010     [nohide]root@i386-builder.daemonology.net[/nohide]:/usr/obj/usr/src/sys/GENERIC  i386</allinfo>
<verbose>FreeBSD 8.0-RELEASE-p2 #0: Tue Jan  5 16:02:27 UTC 2010     [nohide]root@i386-builder.daemonology.net[/nohide]:/usr/obj/usr/src/sys/GENERIC </verbose>
<generated>Tue Apr  6 20:02:39 CEST 2010</generated>

And just to make sure I am clear about this. This is for FreeBSD systems running jails via the ezjail administration framework.


work started on some jail stuff

I have been thinking about writing something to htmlize statistics and information about jails for awhile now.
Last night I got caught up in some creative flow and spent best part of the night writing a parser for the ezjail config dir -> xml.
It is ugly, but it works.
But this is pretty weird behaviour since I am enrolled to study at 1.75*normal pace.. -Which means I should have been studiyng or atleast sleeping.

Anyway, the plan is to write a php class that will then parse this xml and some other stats and create the useful output.

Watch this space for more info and eventually code and downloads.


jail resources oneliner

Getting a quick overview of the resources currently assigned to your your jails can be done using the following command sequence:

top -Pajnojid | tail -n 20 | awk '{if ($2!=0) print $0}'

Starring in order of appearance:
top; with the flags P -Show info per CPU, a -get command name from argv[] and not the name of the executable, j -display jail id, n -non interactive mode, ojid -the order flag `o` followed by jid for sorting.
tail; to get the last 20 lines of output (skip the sys info)
awk; print all lines where column 2 is not `0`

if you have many jails and hence many jail processes you might want to bump up the number of lines a bit like follows to show a maximum of 50 processes instead of the default 20:

top -Pajnojid 50 | tail -n 52 | awk '{if ($2!=0) print $0}'