Xymon Mailing List Archive search

Question on df processing for xymonclient-linux.sh

6 messages in this thread

list Mark Deiss · Thu, 12 Apr 2012 09:11:43 -0500 ·
In looking df processing in the Linux Xymon client module in
client/xymonclient-linux.sh:

echo "[df]"
EXCLUDES=`cat /proc/filesystems | grep nodev | awk '{print $2}' | xargs
echo | sed -e 's! ! -x !g'`
df -Pl -x iso9660 -x $EXCLUDES | sed -e '/^[^   ][^     ]*$/{
N
s/[     ]*\n[   ]*/ /
}'


A bit concerned that the df line can have a dangling "-x" option if the
EXCLUDES variable is not populated. With a dangling "-x", the df command
will abort with a syntax error and the df status will probably end up
with a green status with no rrd history being populated. Users would not
be aware unless they specifically brought up the green disk display or
were reviewing disk trends and noticing the gap.

The EXCLUDES variable can become null if the xymon client account loses
read access to /proc/filesystems, for some reason the Linux flavor quit
using the nodev tag (maybe started using NODEV or Nodev after a patch
update....) or the xymon client went onto an (older) Linux version that
did not use the /proc system.

Suggest a revision either using sed or awk to build the EXCLUDES
variable and a modification of the df command to eliminate the dangling
"-x" option


EXCLUDES=`cat /proc/filesystems 2>/dev/null | awk ' $1 ~ /nodev/ {
printf("-x %s ", $2) }'`

Or

EXCLUDES=`cat /proc/filesystems 2>/dev/null | sed -ne '
	/nodev/{
		s/nodev[ 	]*/ -x /
		H
	}
	${
		x
		s/\n//g
		p
	}'`


df -Pl -x iso9660 $EXCLUDES 2>/dev/null | sed -e '/^[^ 	][^ 	]*$/{
N
s/[ 	]*\n[ 	]*/ /
}'


If the parsing for nondev entries in /proc/filesystems now blows up for
whatever reason (EXCLUDES is null), the df command will be capturing
more than is desired which I believe would be preferred over missing the
important file systems. Would like to use "2>&1" rather than
"2>/dev/null" in the df line except any captured error lines may cause
some downstream havoc with the rrd database processing.
list Jeremy Laidman · Fri, 13 Apr 2012 13:37:53 +1000 ·
quoted from Mark Deiss
On Fri, Apr 13, 2012 at 12:11 AM, Deiss, Mark <user-5cd8675c2346@xymon.invalid>wrote:
A bit concerned that the df line can have a dangling "-x" option if the
EXCLUDES variable is not populated.

Perhaps just wrap the variable in quotes like so:

  df -Pl -x iso9660 -x "$EXCLUDES" | sed -e

Then "df" doesn't throw an error.

J
list Thomas Leavitt · Mon, 3 Sep 2012 20:02:01 -0700 ·
I've recently run up against this problem... after doing a virtual machine
migration using the P2V functionality of VMware Converter 5.0, which leaves
you with an unbootable VM due to the fact that the kernel binaries used in
the converter server VM are five years old, and thus incompatible with
current kernels and their dependencies, I used the excellent "Boot Repair"
utility to repair grub and restore my converted VMs to functionality.

Unfortunately, this has the side effect of causing DF to go from this:

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              95G  2.7G   87G   3% /
tmpfs                 2.0G     0  2.0G   0% /lib/init/rw
udev                  2.0G  100K  2.0G   1% /dev
tmpfs                 2.0G     0  2.0G   0% /dev/shm

to this:


which, if you look at the code, has the obvious undesirable side effect of
causing rootfs to be seen as a "nodev" filesystem, and Xymon to think there
are no filesystems to parse.

The obvious hack is to simply manually tell it to not exclude rootfs. I do
think, however, that there are more graceful and less breakage prone ways
to achieve the same end (only parsing filesystems we care about). I'm not a
major coder, so I don't really have any suggestions for a patch, but I
would start out by affirmatively including filesystems, rather than relying
on an exclusion list, and basing the inclusion list on /etc/fstab

Thomas
quoted from Jeremy Laidman

On Thu, Apr 12, 2012 at 8:37 PM, Jeremy Laidman <user-71895fb2e44c@xymon.invalid>wrote:
On Fri, Apr 13, 2012 at 12:11 AM, Deiss, Mark <user-5cd8675c2346@xymon.invalid>wrote:
A bit concerned that the df line can have a dangling "-x" option if the
EXCLUDES variable is not populated.

Perhaps just wrap the variable in quotes like so:

  df -Pl -x iso9660 -x "$EXCLUDES" | sed -e

Then "df" doesn't throw an error.

J

list Thomas Leavitt · Mon, 3 Sep 2012 20:06:29 -0700 ·
Hit send prematurely:

to this should have included:

Filesystem            Size  Used Avail Use% Mounted on
tmpfs                 1.9G     0  1.9G   0% /lib/init/rw
udev                  1.9G  100K  1.9G   1% /dev
tmpfs                 1.9G     0  1.9G   0% /dev/shm
rootfs                 15G  2.7G   12G  19% / <--------
quoted from Thomas Leavitt


On Mon, Sep 3, 2012 at 8:02 PM, Thomas Leavitt <user-22bea179a13a@xymon.invalid>wrote:
I've recently run up against this problem... after doing a virtual machine
migration using the P2V functionality of VMware Converter 5.0, which leaves
you with an unbootable VM due to the fact that the kernel binaries used in
the converter server VM are five years old, and thus incompatible with
current kernels and their dependencies, I used the excellent "Boot Repair"
utility to repair grub and restore my converted VMs to functionality.

Unfortunately, this has the side effect of causing DF to go from this:

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              95G  2.7G   87G   3% /
tmpfs                 2.0G     0  2.0G   0% /lib/init/rw
udev                  2.0G  100K  2.0G   1% /dev
tmpfs                 2.0G     0  2.0G   0% /dev/shm

to this:


which, if you look at the code, has the obvious undesirable side effect of
causing rootfs to be seen as a "nodev" filesystem, and Xymon to think there
are no filesystems to parse.

The obvious hack is to simply manually tell it to not exclude rootfs. I do
think, however, that there are more graceful and less breakage prone ways
to achieve the same end (only parsing filesystems we care about). I'm not a
major coder, so I don't really have any suggestions for a patch, but I
would start out by affirmatively including filesystems, rather than relying
on an exclusion list, and basing the inclusion list on /etc/fstab

Thomas

On Thu, Apr 12, 2012 at 8:37 PM, Jeremy Laidman <user-71895fb2e44c@xymon.invalid>wrote:
On Fri, Apr 13, 2012 at 12:11 AM, Deiss, Mark <user-5cd8675c2346@xymon.invalid>wrote:
A bit concerned that the df line can have a dangling "-x" option if the
EXCLUDES variable is not populated.

Perhaps just wrap the variable in quotes like so:

  df -Pl -x iso9660 -x "$EXCLUDES" | sed -e

Then "df" doesn't throw an error.

J

list Henrik Størner · Tue, 04 Sep 2012 08:29:33 +0200 ·
quoted from Thomas Leavitt
On 04-09-2012 05:02, Thomas Leavitt wrote:
Unfortunately, this has the side effect of causing DF to go from this:

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              95G  2.7G   87G   3% /
tmpfs                 2.0G     0  2.0G   0% /lib/init/rw
udev                  2.0G  100K  2.0G   1% /dev
tmpfs                 2.0G     0  2.0G   0% /dev/shm

to this:

Filesystem            Size  Used Avail Use% Mounted on
tmpfs                 1.9G     0  1.9G   0% /lib/init/rw
udev                  1.9G  100K  1.9G   1% /dev
tmpfs                 1.9G     0  1.9G   0% /dev/shm
rootfs                 15G  2.7G   12G  19% / <--------

which, if you look at the code, has the obvious undesirable side effect
of causing rootfs to be seen as a "nodev" filesystem, and Xymon to think
there are no filesystems to parse.

The obvious hack is to simply manually tell it to not exclude rootfs. I
do think, however, that there are more graceful and less breakage prone
ways to achieve the same end (only parsing filesystems we care about).
The problem with this approach is that "filesystems we care about" 
changes regularly, whenever some clever kernel hacker comes up with a 
new filesystem.

So the obvious hack for this is attached. Note that simply not excluding 
"rootfs" won't work, since "rootfs" is not seen by Xymon as a device 
name which breaks the graph handling code ... So this patch has the 
added bonus of actually providing you with the correct devicename for 
your root filesystem.

Regards,
Henrik
Attachments (1)
list Henrik Størner · Tue, 04 Sep 2012 08:33:08 +0200 ·
On 04-09-2012 08:29, Henrik Størner wrote:
So the obvious hack for this is attached.
Well, that patch also included a patch for some file permission issues 
with the 4.3.10 Makefile's. It won't do any harm, but you can use this 
instead to just fix the disk status problem.


Regards,
Henrik
Attachments (1)