Xymon Mailing List Archive search

Xymon client on MacOS Catalina (10.15)

3 messages in this thread

list Brian Scott · Sat, 5 Sep 2020 13:29:54 +1000 ·
Hi list,

Has anyone had experience with running the xymon client on the latest Macos?

My particular problem is that the handling of disk mounts and capacities
has gone seriously weird. First exhibit - output from the mount command:

# mount
/dev/disk1s1 on / (apfs, local, read-only, journaled)
devfs on /dev (devfs, local, nobrowse)
/dev/disk1s2 on /System/Volumes/Data (apfs, local, journaled, nobrowse)
/dev/disk1s5 on /private/var/vm (apfs, local, journaled, nobrowse)
map auto_home on /System/Volumes/Data/home (autofs, automounted, nobrowse)

All volumes are either marked nobrowse or read-only so no disks are
selected by xymonclient-darwin.sh. This has the immediate kick on effect
of causing a bash set command to dump all set variables because the
filesystem list is empty. Ignoring this because we actually want to
select some filesystems, the question is which ones. Looking at the
output from df:

# df -P -H
Filesystem????? Size?? Used? Avail Capacity? Mounted on
/dev/disk1s1??? 1.0T??? 11G??? 92G??? 11%??? /
devfs?????????? 345k?? 345k???? 0B?? 100%??? /dev
/dev/disk1s2??? 1.0T?? 893G??? 92G??? 91%??? /System/Volumes/Data
/dev/disk1s5??? 1.0T?? 3.2G??? 92G???? 4%??? /private/var/vm
map auto_home???? 0B???? 0B???? 0B?? 100%??? /System/Volumes/Data/home

It looks like /dev/disk1s1, s2 and s5 are all the same real partition
but account for different space from it, i.e. total size = 1.0T, Used =
11G+893G+3.2G=907.2G, Avail=92G.

This would suggest that a reasonable thing to monitor would be one of
these entries ('/' makes some sense) and derive used as size-avail
(1.0T-92G).

This then falls down when I plug an extra disk in (in this case a FAT32
USB drive) adding:

/dev/disk2s1 on /Volumes/NO NAME (msdos, local, nodev, nosuid, noowners)

and

/dev/disk2s1???? 15G?? 137M??? 15G???? 1%??? /Volumes/NO NAME

Which looks a lot more like conventional drives on a normal unix-style
system.

Fortunately (?) for me, the server I'm trying to monitor only has a
single disk so this isn't a further complicating issue.

Has anyone already done anything to make sense of all this in a modified
version of xymonclient-darwin.sh? Is there a cutoff point in macos
versions where the existing script was good and a new one is needed? I
haven't had to deal with a Mac server before so haven't particularly
cared about what xymon made of it until now.

Cheers, stay safe,


Brian Scott
list Mark Wagner · Fri, 4 Sep 2020 22:30:26 -0700 ·
On Sat, 5 Sep 2020 13:29:54 +1000
quoted from Brian Scott
Brian Scott <user-7c0060721e1b@xymon.invalid> wrote:
Hi list,

Has anyone had experience with running the xymon client on the latest
Macos?

My particular problem is that the handling of disk mounts and
capacities has gone seriously weird. First exhibit - output from the
mount command:

# mount
/dev/disk1s1 on / (apfs, local, read-only, journaled)
devfs on /dev (devfs, local, nobrowse)
/dev/disk1s2 on /System/Volumes/Data (apfs, local, journaled,
nobrowse) /dev/disk1s5 on /private/var/vm (apfs, local, journaled,
nobrowse) map auto_home on /System/Volumes/Data/home (autofs,
automounted, nobrowse)

All volumes are either marked nobrowse or read-only so no disks are
selected by xymonclient-darwin.sh. This has the immediate kick on
effect of causing a bash set command to dump all set variables
because the filesystem list is empty. Ignoring this because we
actually want to select some filesystems, the question is which ones.
Looking at the output from df:

# df -P -H
Filesystem????? Size?? Used? Avail Capacity? Mounted on
/dev/disk1s1??? 1.0T??? 11G??? 92G??? 11%??? /
devfs?????????? 345k?? 345k???? 0B?? 100%??? /dev
/dev/disk1s2??? 1.0T?? 893G??? 92G??? 91%??? /System/Volumes/Data
/dev/disk1s5??? 1.0T?? 3.2G??? 92G???? 4%??? /private/var/vm
map auto_home???? 0B???? 0B???? 0B?? 100%??? /System/Volumes/Data/home

It looks like /dev/disk1s1, s2 and s5 are all the same real partition
but account for different space from it, i.e. total size = 1.0T, Used
= 11G+893G+3.2G=907.2G, Avail=92G.

This would suggest that a reasonable thing to monitor would be one of
these entries ('/' makes some sense) and derive used as size-avail
(1.0T-92G).
APFS volumes are more akin to BTRFS subvolumes or ZFS filesystems
than to traditional partitions: the available space on the physical
storage is shared between them on an as-needed basis.

There might be some Apple-specific command line tool to get the
statistics you want, but failing that, you'll need to track which
partitions are APFS versus something else when deciding how to
calculate usage.

-- 
Mark
list Brian Scott · Sat, 5 Sep 2020 22:47:08 +1000 ·
quoted from Mark Wagner
On 5/9/20 3:30 pm, Mark Wagner wrote:
On Sat, 5 Sep 2020 13:29:54 +1000
Brian Scott <user-7c0060721e1b@xymon.invalid> wrote:
Hi list,

Has anyone had experience with running the xymon client on the latest
Macos?

My particular problem is that the handling of disk mounts and
capacities has gone seriously weird. First exhibit - output from the
mount command:

# mount
/dev/disk1s1 on / (apfs, local, read-only, journaled)
devfs on /dev (devfs, local, nobrowse)
/dev/disk1s2 on /System/Volumes/Data (apfs, local, journaled,
nobrowse) /dev/disk1s5 on /private/var/vm (apfs, local, journaled,
nobrowse) map auto_home on /System/Volumes/Data/home (autofs,
automounted, nobrowse)

All volumes are either marked nobrowse or read-only so no disks are
selected by xymonclient-darwin.sh. This has the immediate kick on
effect of causing a bash set command to dump all set variables
because the filesystem list is empty. Ignoring this because we
actually want to select some filesystems, the question is which ones.
Looking at the output from df:

# df -P -H
Filesystem????? Size?? Used? Avail Capacity? Mounted on
/dev/disk1s1??? 1.0T??? 11G??? 92G??? 11%??? /
devfs?????????? 345k?? 345k???? 0B?? 100%??? /dev
/dev/disk1s2??? 1.0T?? 893G??? 92G??? 91%??? /System/Volumes/Data
/dev/disk1s5??? 1.0T?? 3.2G??? 92G???? 4%??? /private/var/vm
map auto_home???? 0B???? 0B???? 0B?? 100%??? /System/Volumes/Data/home

It looks like /dev/disk1s1, s2 and s5 are all the same real partition
but account for different space from it, i.e. total size = 1.0T, Used
= 11G+893G+3.2G=907.2G, Avail=92G.

This would suggest that a reasonable thing to monitor would be one of
these entries ('/' makes some sense) and derive used as size-avail
(1.0T-92G).
APFS volumes are more akin to BTRFS subvolumes or ZFS filesystems
than to traditional partitions: the available space on the physical
storage is shared between them on an as-needed basis.

There might be some Apple-specific command line tool to get the
statistics you want, but failing that, you'll need to track which
partitions are APFS versus something else when deciding how to
calculate usage.
Many thanks,

I've cooked up a change to xymonclient-darwin.sh to try to deal with
this. In particular, non-apfs disks and partitions should be treated as
you would expect for conventional file systems.

For apfs volumes, I've just reported one for each underlying disk
showing the total used figures.

Inodes seem to be used individually for each volume so I've reported
each of them. Mind you, the maximum appears to be effectively infinite
so there is no danger of ever running out so this is of limited use. The
existing code wouldn't have been reporting inodes anyway (df command
mistake).

Cheers,

Brian Scott

-------------- next part --------------
--- client/xymonclient-darwin.sh.orig	2015-10-20 09:34:59.000000000 +1100
+++ client/xymonclient-darwin.sh	2020-09-05 22:28:06.000000000 +1000
@@ -26,28 +26,62 @@
 echo "[who]"
 who
 
-FILESYSTEMS=`mount | sed -E '/[\( ](nobrowse|afs|read-only)[ ,\)]/d;s/^.* on (.*) \(.*$/\1/'`
+FILESYSTEMS=
+APFS=`mount | grep -E '[( ]apfs[,)]' | sed -E -e 's/s[0-9]{1,} .*/s/' | sort -u`
+for apfs in $APFS; do
+	# Find the 'best' mountpoint to use for this disk (whatever that means...)
+	mp=`mount|grep -E "^$apfs.*[( ]local[,)]"| grep -v '[( ](nobrowse|afs|nfs|smbfs|nullfs|devfs|read-only)[ ,)]'|head -1`
+	if [ -z "$mp" ]; then
+		mp=`mount|grep -E "^$apfs.*[( ]local[,)]"| grep -v '[( ](nobrowse|afs|nfs|smbfs|nullfs|devfs)[ ,)]'|head -1`
+		if [ -z "$mp" ]; then
+			mp=`mount|grep -E "^$apfs.*[( ]local[,)]"| grep -v '[( ](afs|nfs|smbfs|nullfs|devfs)[ ,)]'|head -1`
+		fi
+	fi
+	if [ -n "$mp" ]; then
+		mp=`echo $mp|sed -E -e 's/^.*on //' -e 's/ \(.*//'`
+		FILESYSTEMS="$FILESYSTEMS =$apfs $mp"
+	fi
+done
• +FILESYSTEMS="$FILESYSTEMS "`mount | sed -E -e '/[\( ](nobrowse|afs|read-only|apfs)[ ,\)]/d' -e 's/^.* on (.*) \(.*$/\1/'`
 
 echo "[df]"
-(IFS=$'\n'
- set $FILESYSTEMS
- df -P -H $1; shift
+(IFS=" "
+ set -- $FILESYSTEMS
+ df -P -H / | head -1
  while test $# -gt 0
  do
-   df -P -H $1 | tail -1 | sed 's/\([^ ]\) \([^ ]\)/\1_\2/g'
+   case "$1" in
+     =*)
+	 	shift
+		df -P -m $1 | tail -1 | sed -E -e 's/s[0-9]{1,} */ /' | awk '{printf "%-20s %10dM %10dM %10dM %10d%% %s\n", $1, $2, $2-$4, $4, 100*($2-$4)/$2, $6}'
+	    ;;
+	*)
+        df -P -H $1 | tail -1 | sed 's/\([^ ]\) \([^ ]\)/\1_\2/g'
+		;;
+   esac
    shift
  done) | column -t -s " " | sed -e 's!Mounted *on!Mounted on!'
 
 echo "[inode]"
-(IFS=$'\n'
- set $FILESYSTEMS
- df -P -i $1; shift
+(IFS=" "
+ set -- $FILESYSTEMS
+ df -i / | head -1
  while test $# -gt 0
  do
-   df -P -H $1 | tail -1 | sed 's/\([^0123456789% ]\) \([^ ]\)/\1_\2/g'
+   case "$1" in
+     =*)
+	 	dev=`echo $1|cut -d= -f2-`
+	 	shift
+		df -i | grep "^$dev"
+	    ;;
+	*)
+        df -i $1 | tail -1 | sed 's/\([^0123456789% ]\) \([^ ]\)/\1_\2/g'
+		;;
+   esac
    shift
  done) | awk '
-NR<2{printf "%-20s %10s %10s %10s %10s %s\n", $1, "itotal", $6, $7, $8, $9} 
+NR<2{printf "%-20s %10s %10s %10s %10s %s %s\n", $1, "itotal", $6, $7, $8, $9, $10} 
 (NR>=2 && $6>0) {printf "%-20s %10d %10d %10d %10s %s\n", $1, $6+$7, $6, $7, $8, $9}'
 
 echo "[mount]"
@@ -59,7 +93,7 @@
 echo "[route]"
 netstat -rn
 echo "[netstat]"
-netstat -s
+netstat -s 2>/dev/null
 echo "[ifstat]"
 netstat -ibn | egrep -v "^lo|<Link"
 echo "[ports]"