[Xymon] Detecting read-only file system in Linux

Thomas Eckert thomas.eckert at it-eckert.de
Tue Mar 10 14:44:12 CET 2015


Just for future reference as you already found your solution:

From looking at the util-linux package I understand that _if_ the /proc-filesystem is mounted the information is used from there. So it is ensured that up-to-date information is returned by `mount`.
Back in the old Linux-days before /proc existed (at the minimum pre kernel 2.4) `mount` relied on the information from `/etc/mtab` which was not necessarily up-to-date (in particular in case of a ro-mount of `/`).

I would expect almost every Linux system in service today to have /proc.
The behaviour of `mount` on other OSes (AIX, *BSD, …) might differ though.

Cheers
Thomas

> On 09 Mar 2015, at 18:09, SebA <spah at syntec.co.uk> wrote:
> 
> 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 <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 <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 <mailto: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
>> 
>>  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20150310/149b1497/attachment.html>


More information about the Xymon mailing list