<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Just for future reference as you already found your solution:</div><div class=""><br class=""></div>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`.<div class="">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 `/`).</div><div class=""><br class=""></div><div class="">I would expect almost every Linux system in service today to have /proc.</div><div class="">The behaviour of `mount` on other OSes (AIX, *BSD, …) might differ though.</div><div class=""><br class=""></div><div class="">Cheers</div><div class="">Thomas</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 09 Mar 2015, at 18:09, SebA <<a href="mailto:spah@syntec.co.uk" class="">spah@syntec.co.uk</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta content="text/html; charset=us-ascii" http-equiv="Content-Type" class="">
<meta name="GENERATOR" content="MSHTML 9.00.8112.16609" class="">
<div style="WORD-WRAP: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space" class="">
<div class=""><font size="2" face="Arial" class="">
<div dir="ltr" align="left" class=""><span class="532315214-09032015"><font size="2" face="Arial" class="">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:</font></span></div>
<div dir="ltr" align="left" class=""><span class="532315214-09032015"><font size="2" face="Arial" class=""><a href="http://sisyphus.ru/en/srpm/Sisyphus/xymon/sources/8" class="">http://sisyphus.ru/en/srpm/Sisyphus/xymon/sources/8</a></font></span></div>
<div dir="ltr" align="left" class=""><span class="532315214-09032015"><font size="3" face="Arial" class=""><pre class="">#!/bin/sh<br class=""><br class=""># Read data from /proc/mounts on linux and report back in the xymon client<br class=""># It gives more accurate data than the 'mount' command and can catch<br class=""># disks in a read-only state.<br class=""><br class="">test -r /proc/mounts && exec cat /proc/mounts</pre></font></span></div>
<div class=""><span class="532315214-09032015">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...</span></div>
<div class=""><span class="532315214-09032015"></span> </div>
<div class=""><span class="532315214-09032015">In fact, I think I have found the place to
add it and that is in this add-on: <a href="https://wiki.xymonton.org/doku.php/monitors:check-client" class="">https://wiki.xymonton.org/doku.php/monitors:check-client</a> -
then it will work for all hosts (correct me if I am wrong David
Baldwin?)</span></div><!-- Converted from text/rtf format --><div align="left" class=""><span lang="en-gb" class="">Kind regards,</span> </div><div class=""><span lang="en-gb" class="">Seb<span class="532315214-09032015">A</span></span></div></font></div><br class="">
<blockquote style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px" dir="ltr" class="" type="cite">
<div dir="ltr" lang="en-us" class="OutlookMessageHeader" align="left">
<hr tabindex="-1" class="">
<font size="2" face="Tahoma" class=""><b class="">From:</b> Xymon [<a href="mailto:xymon-bounces@xymon.com" class="">mailto:xymon-bounces@xymon.com</a>]
<b class="">On Behalf Of </b>Thomas Eckert<br class=""><b class="">Sent:</b> 09 March 2015
14:05<br class=""><b class="">To:</b> Xymon MailingList<br class=""><b class="">Subject:</b> Re: [Xymon] Detecting
read-only file system in Linux<br class=""></font><br class=""></div>
<div class=""></div>Hi,
<div class=""><br class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On 09 Mar 2015, at 13:44, SebA <<a href="mailto:spah@syntec.co.uk" class="">spah@syntec.co.uk</a>> wrote:</div>
<div class="">
<div class="">
<div class=""></div></div></div></blockquote>
<div class=""><br class=""></div>(…)<br class=""><br class="">
<blockquote type="cite" class="">
<div class="">
<div class=""><font size="2" face="Arial" class="">Although we have some Debian systems, I was
looking for a solution for another Linux distro.</font></div>
<div class=""><font size="2" face="Arial" class=""><span class="298451712-09032015"></span></font> </div>
<div class=""><font size="2" face="Arial" class="">If I was to write something myself to do it, I
would check /proc/mounts and the best command I could find was:</font></div>
<div class=""><font size="2" face="Arial" class="">awk '$4~/(^|,)ro($|,)/' /proc/mounts<br class="">which
outputs:</font></div>
<div class=""><font size="2" face="Arial" class="">/dev/root / ext3 ro,data=ordered 0
0</font></div>
<div class=""><font size="2" face="Arial" class="">with sample line:</font></div>
<div class=""><font size="2" face="Arial" class="">/dev/root / ext3 ro,data=ordered 0
0<br class=""></font></div></div></blockquote>
<div class=""><br class=""></div>
<div class="">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.</div>
<div class=""><br class=""></div>
<div class="">Extract the reported `mount`-data for host bb.local:</div>
<div class=""><br class=""></div>
<div class=""><span style="WHITE-SPACE: pre" class="Apple-tab-span"></span>xymon
127.0.0.1 “clientlog bb.local section=mount”</div>
<div class=""><br class=""></div>
<div class="">Some testing of the output:</div>
<div class=""><br class=""></div>
<div class=""><span style="WHITE-SPACE: pre" class="Apple-tab-span"></span>(export
host=bb.local; xymon 127.0.0.1:1984 "clientlog $host section=mount" | gawk
'/[(,]+ro[,)]+/ { print "filesystem " $1 " mounted RO!" } ')</div>
<div class=""><br class=""></div>
<div class="">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”.</div>
<div class=""><br class=""></div>Cheers</div>
<div class="">Thomas</div>
<div class=""><br class=""> </div></div></blockquote></div>
</div></blockquote></div><br class=""></div></body></html>