Community Blogs

Error: Could not stat() command file '/var/lib/nagios3/rw/nagios.cmd'!

Here's a viable solution on my debian server:

dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3

And... et voilà!

The proper permissions have been set and everything should work as expected


2 Cent Tip - Extend (resize) a whole device partition.

Occasionally I have to resize partitions on iSCSI or Fiber-Channel attached SAN storage.  Both technologies allow you to easily extend the available storage for a host by extending LUNs, or volumes.  A common problem after extending the size of the LUN, or volume, is resizing partitions to fill out the new size.


For the most part, I usually fire up PartedMagic  and its a snap, even with Fiber-Channel attached enterprise storage.  Once the HBA's have been zoned to Fiber-Channel switches, then the HBAs do all the heavy lifting.  In other words on Fiber-Channel, it doesn't matter if you're using PartedMagic, or Knoppix, the server just knows where the storage is, and that its certainly attached.  The only dependency for this working on a Live boot disk are drivers for the HBA cards.


iSCSI is a bit different.  Because, iSCSI relies on commodity Network Interface Cards, this technology is largely implemented in software.  One perceived advantage is iSCSI may seem less complicated to use than Fiber-Channel storage.  Unfortunately, in this case, PartedMagic did not have open-iscsi software, and I could install open-iscsi in the Knoppix Live ramdisk. However, because Knoppix came with an outdated iSCSI kernel module, it was not new enough to inter-operate with the open-iscsi software.


Furthermore, the version of parted that shipped with RHEL 5 threw an incompatible filesystem error, refusing to modify the filesystem. So, in the end, I twiddled some bits on the partition table with fdisk, and used resize2fs to extend the partition.


Assuming you have a backup of the filesystem you are working on, you can proceed with the following steps to extend a single partition to the end of the extended volume.  If you have multiple partitions on a volume, you may want to stick to more reliable methods of resizing and extending.  If you screw up the cylinder boundaries on a device with multiple partitions, you'll definitely lose data.  A single partition, in this example, is a much simpler scenario.


The device name in this example is /dev/mapper/u02, the first partition is /dev/mapper/u02p1:

  • Run fdisk -l /dev/mapper/u02 to get the starting cylinder.
Disk /dev/mapper/u02: 100.9 GB, 108340550042 bytes

255 heads, 63 sectors/track, 13171 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/mapper/u02p1 1 13171 26450329 83 Linux

  • Reboot the server, after extending the volume or LUN on your SAN, and before proceeding to extend the partition in your Operating System.  The Operating System needs to re-read sector 0 on the extended SAN volume, before continuing. Note, that fdisk will report 26109 cylinders instead of 13171, after I rebooted the server.
  • Next, we will run: fdisk /dev/mapper/u02, and then hit the keys: d, n, p, 1, [enter], [enter], w
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

Command (m for help): d
Selected partition 1

Command (m for help): n
Command action
e extended
p primary partition (1-4)
Partition number (1-4): 1
First cylinder (1-26109, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-26109, default 26109):
Using default value 26109

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
  • Finally, run resize2fs on /dev/mapper/u02p1. If you are using ext3, you can do an on-line resize while the volume is mounted.  It is probably safest to umount the partition to be re-sized, however.
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/u02p1 is mounted on /u02; on-line resizing required
Performing an on-line resize of /dev/mapper/u02p1 to 52430127 (4k) blocks.
The filesystem on /dev/mapper/u02p1 is now 52430127 blocks long.

Refer to the resize2fs for more information on the command, and its proper usage.


Analyzing Apache Logs interactively from the terminal with GoAccess

I have always been analyzing my Apache logs with the popular tail -f, which to a certain point is quite neat that you can see the whole request in real time. However, there is a point where you may be interested to know more details about your web logs.

Here it is where I find really interesting GoAccess. Whilst Awstats, Analog, Webalizer all generate HTML statistics, this application will let you analyze your Apache Web server logs straight from the terminal. It generates statistics really fast and it displays them in a nice ncurses interface.

More information about this project at:


RAID Disk Configuration (mdadm.conf)

Back again with a very quick tip: RAID disk array configuration.

After few articles like:
Installing GRUB on the other disks
Replacing faulted raid drive
I'm just adding my configuration related to one of my RAID installations on a linux server.

Machine has Gentoo Linux (current portage, AMD64 arch) and a RAID system with only two SATA drives with a simple RAID1 config. Nothing more, nothing less

Quite easy config to have a virtual disk composed like this:

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/md2 4806824 997012 3809812 21% /
tmpfs 449108 0 449108 0% /lib/init/rw
udev 10240 144 10096 2% /dev
tmpfs 449108 0 449108 0% /dev/shm
/dev/md0 90195 11088 79107 13% /boot
/dev/mapper/storage-storage 306966528 82096984 224869544 27% /home

I've a boot partition (md0), a swap partition (md1), root partition (md2) and a logical volume manager (LVM) on /dev/md3

Nothing strange, nothing spectacular, every configuration is maded by hand, no fancy graphical tools involved. Config related to RAID5 installations have the same layout

Here's the array configuration file (mdadm.conf)

# scan all partitions (/proc/partitions) for MD superblocks.
DEVICE partitions

# auto-create devices
CREATE owner=root group=disk mode=0660 auto=yes

# tag arrays as belonging to the local system
# Monitoring daemon instructions
MAILFROM FileServer Administrator
MAILADDR This e-mail address is being protected from spambots. You need JavaScript enabled to view it

# MD array
ARRAY /dev/md0 level=raid1 num-devices=2 UUID=d4eb97cf:da422dd0:36eb05f3:bbd531f4
ARRAY /dev/md1 level=raid1 num-devices=2 UUID=a614ae3f:a9afcbfc:91f980c8:762e06bc
ARRAY /dev/md2 level=raid1 num-devices=2 UUID=19d6f845:358ff0a9:188cf822:397115dc
ARRAY /dev/md3 level=raid1 num-devices=2 UUID=24346f3b:bad36d8b:961a4a14:4eae9079

# Modified by Ben

Again, nothing strange here, hope it helps newbies or contributors interested in a RAID installation, please share your thoughts if this simple config can be better

Next step: LVM configuration sample


Hope it helps you
Glad to read your comments


Andrea (Ben) Benini


Creating XLS file on the fly from a PHP application

Here's a quick and dirty solution for a common problem, if you've a web application used by common Windows users and you publish data on it sometimes you receive this kind of question:

"Are your information exportable into an XLS (Excel) file ?"

For example I've an accounting application exporting some data on a web page, the user just wants to download an Excel file or open it directly from the web page, there's no rocket science here, this is just what I've done, let's roll some php code:

Create an header section (adapted from

$export_file = "my_name.xls";
header('Pragma: public');
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
header("Pragma: no-cache");
header("Expires: 0");
header('Content-Transfer-Encoding: none');
header('Content-Type: application/;'); // This should work for IE & Opera
header("Content-type: application/x-msexcel"); // This should work for the rest
header('Content-Disposition: attachment; filename="'.basename($export_file).'"');

Put your data in a string (of course init it first):

$sBuffer = "";

Then start adding your data in a loop

for (...your loop statement goes here...) {
    $sBuffer .= "column1column2column3column4 ";

Example above creates 4 columns with your raw data, quite easy to adapt to your own needs. Then finally output your data with this:


put this final part after the header section expressed above and that's it ! nothing spectacular I mean but it works fine with every computer with an office automation suite. When the user press your button it gets an XLS sheet and he can open it with Office or OpenOffice as well, it doesn't matter client or server operating system, this trick follows just Excel v1 and v2 specs (very acient but still working).

Please don't deal with ActiveX, proprietary grids or closed source solutions, this is just what you need to keep it simple


Hope it helps
Glad to hear your comments


Andrea (Ben) Benini


Management and economics issues of hosting virtual private email servers

After I published "Wanted: Virtual Personal Email Servers (VPES)" I got lots of feedback. Among others, John made very interesting comments, for example:

  • ... The most user friendly free email management interface is from Zimbra, but the setup is a bear and the system requirements are huge for what it provides
  • ...I (John) spent 20 min earlier today considering whether I could make any profit creating an easy VPES setup script with a fairly low monthly price point.
  • ... BTW, the laws for email metadata retention are different in the EU than in the USA...

The summary of this discussion is at Virtual Personal Email Servers: legal, management and economics issues.


Installing rssh in Linux Server

Here are the steps to install rssh in the linux server :
Follow the below steps to install if your linux os is 32 bit :
Step 1: cd /usr/src
Step 2: wget
Step 3: rpm -ivh rssh-2.3.2-1.2.el4.rf.i386.rpm
If your linux os is 64 bit then follow these steps:
Step 1: cd /usr/src
Step 2: wget
Step 3: rpm -ivh rssh-2.3.2-1.2.el5.rf.x86_64.rpm

For queries @ Linux Server


Set up OSOL 2010-03 (build 134) PV Guest at Xen 4.0 Dom0 ( pvops kernel) on top of Ubuntu Karmic Koala Server

Due to absence in meantime pygrub support for ZFS 24 in Xen 4.0 proceed as usual and copy unix kernel and boot_archive off the disk to Dom0 :

mount -o loop,ro osol-134-dev-x86.iso /mnt
cp /mnt/platform/i86pc/amd64/boot_archive  /home/boris/osol134
cp /mnt/platform/i86xpv/kernel/amd64/unix /home/boris/osol134

In my case OSOL 134 PV DomU was able to obtain IP address just once after first boot up configuring SMF . Afterwards it required restarting ( or reenabling)  service svc:/network/physical:nwam, what finally brought me to accomplish this procedure as OSOL service , because no analog of /etc/rc.local exists on OSOL.

  Two steps in procedure bellow make Xen default Hypervisor on Ubuntu 9.10. First is commenting out (xend-unix-server yes) in /etc/xen/xend-config.sxp, second export variable export VIRSH_DEFAULT_CONNECT_URI=”xen:///” in root’s .bashrc.Then run:-
# apt-get install ubuntu-virt-server ubuntu-virt-mgmt

Create installation XML profile create_osol134.xml as follows :-

<domain type='xen'>
    <cmdline>/platform/i86xpv/kernel/amd64/unix - nowin -B install_media=cdrom</cmdline>
  <clock offset='utc'/>
    <disk type='block' device='disk'>
      <driver name='phy'/>
      <source dev='/dev/sdb5'/>
      <target dev='xvda' bus='xen'/>
    <disk type='file' device='cdrom'>
      <driver name='file'/>
      <source file='/root/MyDownloads/osol-dev-134.iso'/>
      <target dev='xvdc' bus='xen'/>
    <interface type='bridge'>
      <mac address='00:16:3e:72:da:33'/>
      <source bridge='eth0'/>
      <script path='/etc/xen/scripts/vif-bridge'/>
      <target dev='vif7.0'/>
    <console type='pty' tty='/dev/pts/1'>
      <source path='/dev/pts/1'/>
      <target port='0'/>

and run

# virsh create create_osol134.xml
# virsh console osol134
At this point activate VNC connection to DomU via script

domid=`virsh domid osol134`
ip=`/usr/bin/xenstore-read /local/domain/$domid/guest/ipv4/0/address`
echo $ip
port=`/usr/bin/xenstore-read /local/domain/$domid/guest/vnc/port`
echo $port
/usr/bin/xenstore-read /local/domain/$domid/guest/vnc/passwd
vncviewer $ip:$port

and go through normal install. Now define new domain via profile :

<domain type='xen'>
    <cmdline>/platform/i86xpv/kernel/amd64/unix -B zfs-bootfs=rpool/ROOT/opensolaris,bootpath=/xpvd/xdf@51712:a</cmdline>
  <clock offset='utc'/>
    <disk type='block' device='disk'>
      <driver name='phy'/>
      <source dev='/dev/sdb5'/>
      <target dev='xvda' bus='xen'/>
    <interface type='bridge'>
      <mac address='00:16:3e:4d:60:e3'/>
      <source bridge='eth0'/>
      <script path='/etc/xen/scripts/vif-bridge'/>
      <target dev='vif8.0'/>
    <console type='pty' tty='/dev/pts/1'>
      <source path='/dev/pts/1'/>
      <target port='0'/>

# virsh  define osol134-def.xml
# virsh start osol134
# virsh console osol134

In my case after first reboot configuring SMF OSOL 134 stopped obtain IP address via DHCP and required every time commands bellow :-

$ pfexec su -
# svcadm restart svc:/network/physical:nwam
Due /etc/rc.local doesn't exist on OSOL new service to restart NWAM was
implemented. First i created script /bin/ to add as service to SMF

root@opensolaris:~# cat /bin/
svcadm restart svc:/network/physical:nwam

Created XML bellow per [1]:

<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--Script name goes here-->
<service_bundle type='manifest' name='SUNWcsr:dhcp_again'>

<!--Script name goes here too-->

<create_default_instance enabled='false' />


<!--If your script needs to run after a certain milestone has been met
you can specify that here, otherwise delete this bit.
Replace value for milestone you need to meet-->
<service_fmri value='svc:/milestone/network' />

<!--Script to run goes here-->
exec='/usr/bin/bash /bin/'
timeout_seconds='60' />

timeout_seconds='60' />

<!--This bit makes it run ONCE and makes sure it is NOT restarted!-->
<property_group name='startd' type='framework'>
<propval name='duration' type='astring' value='transient' />

<loctext xml:lang='C'>
<!--Script name goes here-->
<manpage title='' section=''
manpath='' />


Next step:-

# cd /var/svc/manifest/site
XML above saved in this directory as dhcp_again.xml
# svccfg validate dhcp_again.xml
# svccfg import dhcp_again.xml
# svcadm enable dhcp_again
#root@opensolaris:~# svcs -a|grep dhcp
online         19:37:20 svc:/site/dhcp_again:default

At this point activate GDM remote login via Xvnc :

root@opensolaris:~# cat /etc/gdm/custom.conf
# Custom Configuration file.
# overrides: /usr/share/gdm/defaults.conf
# AllowRoot=true
# AllowRemoteRoot=true

Then re-enable services :

svcadm disable xvnc-inetd gdm
svcadm enable xvnc-inetd gdm
Runtime snapshots

Runtime snapshots



Virt-install&Virt-manager at Xen 4.0-rc8 ( pvops) Dom0 on top Ubuntu Karmic Koala Server

The final target of this post is to demonstrate how flexible is Ubuntu Karmic Koala Server environment. Build Xen 4.0-rc8 and the most recent stable pvops kernel ( with DRM support). Loading Xen Instance followed by install Ubuntu's Libvirt environment, providing utility virt-install for creating PV and HVM DomUs, virt-manager completely functional to manage any DomU been built via virt-install. Finally HVM image created by beta version Ubuntu 10.04 Lucid Lynx is utilized to bring up Ubuntu 10.04 Lucid Lynx PV DomU, regardless standard trick with "pygrub"  due to Lucid grub2 notation set root='(/dev/sda,1)' instead of  Karmic's set root=(hd0,1) doesn't work any longer. Xen's 4.0-rc8 "pygrub" was not ready to parse such unexpectedness First install required packages:

apt-get install libcurl4-openssl-dev xserver-xorg-dev python2.6-dev mercurial gitk build-essential libncurses5-dev uuid-dev gawk gettext texinfo bcc bridge-utils iasl

Second – build Xen from source

# cd /usr/src
# hg clone
# cd xen-unstable.hg
Set in
PYTHON = python
# make install-xen
# make install-tools
# make install-stubdom

Now checkout and build pvops kernel

# git clone git:// linux-2.6-xen
# cd linux-2.6-xen
# git checkout -b xen/stable-2.6.32.x origin/xen/stable-2.6.32.x

Notice :-

# git checkout origin/xen/master -b xen/master

will result building the most recent 2.31.12 version of pvops kernel. Branch above , actually is not required to be checked out . It’s default branch of "git clone".However, APIC rework has been committed for

# make menuconfig
and tune kernel to support Xen in Dom0

# make -j4
# make modules_install install
# mkinitramfs -o /boot/initrd-

Tuning results Xen packages to be placed into /usr/local/lib/python2.6/dist-packages
due to Changeset 19594 in xen-3.4-testing.hg. Otherwise, Xen packages would go to /usr/lib/python2.6/site-packages, which is not default location for python 2.6 on Ubuntu 9.10 ( vs F12 ). Thus you won’t be able to start xend in Dom0. Add entry to /boot/grub/grab.cfg:-

menuentry "Xen 4.0-rc8 / Ubuntu 9.10 kernel pvops" {
insmod ext2
set root=(hd1,8)
multiboot (hd1,8)/boot/xen.gz
module (hd1,8)/boot/vmlinuz- dummy=dummy root=/dev/sdb8 ro console=tty0
module (hd1,8)/boot/initrd-

Reboot system and install libvirt environment :-

Two steps in procedure bellow make Xen default Hypervisor on Ubuntu 9.10.
First is commenting out (xend-unix-server yes) in /etc/xen/xend-config.sxp , second export variable export VIRSH_DEFAULT_CONNECT_URI="xen:///"
in root’s .bashrc.

Then run:-

# apt-get install ubuntu-virt-server ubuntu-virt-mgmt

Now you should be able to install Ubuntu 10.04 Lucid Server HVM via virt-install :-

# virt-install -n LucidSRV -r 1024 --hvm --vnc -f /dev/sda8 -c /home/boris/Lucid.iso --debug

Start up LucidSRV HVM via virt-manager and scp to Dom0 vmlinuz-2.6.32-16-server and initrd.img-2.6.32-16-server

File bellow may be used for command :-

# virsh define Lucid-def.xml


<domain type='xen' id='3'>
<cmdline>root=/dev/xvda1 ro </cmdline>
<clock offset='utc'/>
<disk type='block' device='disk'>
<driver name='phy'/>
<source dev='/dev/sda8'/>
<target dev='xvda' bus='xen'/>
<interface type='bridge'>
<mac address='00:16:3e:04:6b:5a'/>
<source bridge='eth0'/>
<script path='/etc/xen/scripts/vif-bridge'/>
<target dev='vif3.0'/>
<console type='pty' tty='/dev/pts/1'>
<source path='/dev/pts/1'/>
<target port='0'/>
<input type='mouse' bus='xen'/>
<graphics type='vnc' port='5900' autoport='yes'/>

At this point Lucid Server PV DomU may be started via virt-manager.

Runtime snapshots


Systems Administrator Creed

This is my server.  There are many like it, but this one is mine.  My server is my best friend.  It is my life. I must master it as I master my life.  My server, without me is useless. Without my server, I am useless.  I must configure my server true.  I will...


My server and myself know that what counts in this war is not the packets we drop, the noise of our fans, nor the power we consume. We know that it is the data that counts. We will backup...


My server is human, even as I, because it is my life. Thus, I will learn it as a brother. I will learn its weakness, its strength, its parts, its accessories, its I/O and its slots. I will keep my server clean and ready, even as I am clean and ready. We will become part of each other. We will...


Before God I swear this creed:  My server and myself are defenders of the command prompt, we are the masters of our enemy.  We are the saviors of my life.  So be it, until every server is patched and there is no enemy, but uptime.



Accessing VMWare Server 2 with vSphere Client (the unsupported way)

As many of you already discovered there's no official Linux client for accessing VMWare Server 2.x, the only thing VMWare suggests you to do is to use internal web interface based on a Tomcat webserver.
This web interface is ugly and slow, not so reliable if you plan a clean and fast administration, as alternative you can use the good and efficient Virtual Infrastructure Client (VIC).

Again: VIC is only available for Windows platform and no Linux (or OS-X) client is available now, you can run it on top of WINE libs but it's still not a linux native client.
VMWare promised a lot of time ago a "planned version" for Linux but nobody have already seen it (planned with no expected date...) so we're still waiting for it.

Now vSphere architecture is out, new vSphere Client replaces Virtual Infrastructure Client and guess what ? vSphere Client doesn't support officially VMWare Server, this makes me really upset and after reading different posts even from their community forum (like this) I was really trying to find a different way to access my server installations or move to a totally different product (VirtualBox, KVM, ...)

But after some TCPDUMP traces, a lot of different retries and some Google searches  I've solved my problem and I'll hope this article may help someone else as well.

When you try to connect vSphere to VMWare server you need to insert your credentials and the host name/IP, I've started with (the old way used with VIC),, and so on...
Finally I've discovered this form: seems to be the right one.

At the first connection you need to install a certificate in your Windows machine, second step is to retrieve from server "a generic installer", so you can choose to "Save the Installer" or "Run the Installer";

both options drives you to a generic error like:

"The required client support files cannot be retrieved from the server"
"The login process will now exit"
"Details: The server could not interpret the client's request. (404 not found)"


But what kind of support files do you need, where are there ? Here's a link with some useful and legal files in it

Now what you should do after downloading these support files ?
Just unrar these files into your vSphere Client installation folder, something like
"Program FilesVMWareInfrastructureVirtual Infrastructure Client" (x86 32bit)
"Program Files (x86)VMwareInfrastructureVirtual Infrastructure Client" (x86 64bit)
you'll finally have a directory named "2.5" inside this root folder, now run your vSphere Infrastructure Client again, after inserting your credentials you'll see
the entire login process like in the past with VIC (so "loading inventory form",
"loading classes", and so on...) and the new shiny Client interface is now connected
to VMWare Server as in the past.


This is just a trick to have authentication running again and have access to your
legitimate VMWare Server installation, I'll hope they're really working on this
promised linux client capable of connecting to VMWare Server.
At the moment I'm quite skeptic because this new client relies on Microsoft Windows .NET 3.x Framework and Windows J# redistributable package, as a programmer these are not my preferred tools if I'm planning to have a cross platform program because I'm totally depending on .NET (or Mono) and MS libs.
If you're running a big business you don't really need it, you just purchase vSphere (new ESX) and you're set, but if you really need "bare metal emulation" and you can't afford vSphere, VMWare Server is still the best reliable solution for it, yeah I know Virtual Box/KVM/XEN and others are growing fast but on bare metal VMWare is still the best (from my point of view)



I hope this process may help someone else and I'll look forward for your comments to this post

Andrea (Ben) Benini

Page 5 of 9

Upcoming Linux Foundation Courses

  1. LFD320 Linux Kernel Internals and Debugging
    03 Nov » 07 Nov - Virtual
  2. LFS416 Linux Security
    03 Nov » 06 Nov - Virtual
  3. LFS426 Linux Performance Tuning
    10 Nov » 13 Nov - Virtual

View All Upcoming Courses

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board