Question on df processing for xymonclient-linux.sh
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.
On Fri, Apr 13, 2012 at 12:11 AM, Deiss, Mark <Mark.Deiss at acs-inc.com>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
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 <jlaidman at rebel-it.com.au>wrote:
On Fri, Apr 13, 2012 at 12:11 AM, Deiss, Mark <Mark.Deiss at acs-inc.com>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
Xymon mailing list Xymon at xymon.com http://lists.xymon.com/mailman/listinfo/xymon
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% / <--------
On Mon, Sep 3, 2012 at 8:02 PM, Thomas Leavitt <thomleavitt at gmail.com>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 <jlaidman at rebel-it.com.au>wrote:
On Fri, Apr 13, 2012 at 12:11 AM, Deiss, Mark <Mark.Deiss at acs-inc.com>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
Xymon mailing list Xymon at xymon.com http://lists.xymon.com/mailman/listinfo/xymon
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
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
participants (4)
-
henrik@hswn.dk
-
jlaidman@rebel-it.com.au
-
Mark.Deiss@acs-inc.com
-
thomleavitt@gmail.com