Thanks Thomas. Simulating this suggests your code will work on our server, but as you said, you are not 100% sure that the 'ro' will surface in the mount command. The output here suggests that it may not: http://sisyphus.ru/en/srpm/Sisyphus/xymon/sources/8 #!/bin/sh
Read data from /proc/mounts on linux and report back in the xymon client
It gives more accurate data than the 'mount' command and can catch
disks in a read-only state.
test -r /proc/mounts && exec cat /proc/mounts But maybe that is only needed for some other version of linux... Our server is now fixed so I can't test it properly. But I do prefer a server-side extension, or even a patch to xymon-server, to client plugins that I have to install to every server. The issue with your code is that it only works for 1 named server ('bb.local'), so I would need to have something iterating over all hosts. Probably not hard, and probably something that someone here already does...
In fact, I think I have found the place to add it and that is in this add-on: https://wiki.xymonton.org/doku.php/monitors:check-client - then it will work for all hosts (correct me if I am wrong David Baldwin?)
Kind regards,
SebA
From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Thomas Eckert Sent: 09 March 2015 14:05 To: Xymon MailingList Subject: Re: [Xymon] Detecting read-only file system in Linux
Hi,
On 09 Mar 2015, at 13:44, SebA <spah at syntec.co.uk> wrote:
(.)
Although we have some Debian systems, I was looking for a solution for another Linux distro.
If I was to write something myself to do it, I would check /proc/mounts and the best command I could find was: awk '$4~/(^|,)ro($|,)/' /proc/mounts which outputs: /dev/root / ext3 ro,data=ordered 0 0 with sample line: /dev/root / ext3 ro,data=ordered 0 0
You could use the reported "Client data" / "clientlog" with a server-side
extension. I have to admit that I'm not 100% sure if error-or-remounts are
reflected properly by this - but mount seems to use /proc/self/mountinfo
as it's datasource, so it _should_ be ok.
Extract the reported mount-data for host bb.local:
xymon 127.0.0.1 "clientlog bb.local section=mount"
Some testing of the output:
(export host=bb.local; xymon 127.0.0.1:1984 "clientlog $host section=mount" | gawk '/[(,]+ro[,)]+/ { print "filesystem " $1 " mounted RO!" } ')
This would not require installing and maintaining an extension on every client. One drawback would be increased latency as the ro-check would be "indirect".
Cheers Thomas