[Xymon] Patch for xymonclient-darwin.sh to fix numerous bugs
Jeremy Laidman
jlaidman at rebel-it.com.au
Mon Oct 19 08:45:54 CEST 2015
Jason
Nice work.
A suggestion, to avoid setting oIFS and then having to clean up again later:
FILESYSTEMS=`mount | egrep -v '[\( ](nobrowse|read-only)[ ,\)]' | sed
's/^.* on \(.*\) (.*)$/\1/'`
echo "[df]"
(IFS=$'\n'
set $FILESYSTEMS
df -PH $1; shift
while test $# -gt 0
do
df -PH $1 | tail -1 | sed 's/\([^ ]\) \([^ ]\)/\1_\2/g'
shift
done) | column -t -s " " | sed -e 's!Mounted *on!Mounted on!'
By moving "IFS=..." and "set $FILESYSTEMS" into the parens, the scope of
the variable change is kept within the parens, thus auto-cleanup.
A second suggestion is to replace the egrep+sed pipeline with a single sed
command, such as:
FILESYSTEMS=`mount | sed '/[\( ](nobrowse|read-only)[ ,\)]/d;s/^.* on
\(.*\) (.*$/\1/'`
This saves an extra process fork/exec. The "/<regexp>/d" operation for sed
will delete matching lines, emulating "egrep -v".
Cheers
Jeremy
On 18 October 2015 at 23:17, Jason White <jdwhite at menelos.com> wrote:
> Greetings,
> The following patch fixes these long-standing issues with
> xymonclient-darwin.sh:
>
> * Disk usage test erroneously uses inode usage values as Darwin combines
> disk usage and inode usage into the same 'df' output by default.
> * Mountpoints with spaces in them were not reported.
>
> The former issues is fixed by passing the '-P' flag to 'df' to restore
> legacy mode reporting. The latter issue replaces spaces with underscores in
> the mountpoint.
>
> In addition to checking mount options for 'nobrowse', this patch also
> exclude readonly volumes which I find are mostly transient DMG files.
>
> Regards,
> -Jason
>
> --
> Jason White
> jdwhite at menelos.com
>
>
> _______________________________________________
> Xymon mailing list
> Xymon at xymon.com
> http://lists.xymon.com/mailman/listinfo/xymon
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20151019/21bae8ec/attachment.html>
More information about the Xymon
mailing list