From a7d3fd9c7e45668e1b7f78faf1fd169af1ed4662 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Sat, 13 Apr 2013 15:31:04 +0200 Subject: [PATCH] Add filesystem discovery script --- conf/filesystems.conf | 4 ++++ scripts/disco_filesystems | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 conf/filesystems.conf create mode 100644 scripts/disco_filesystems diff --git a/conf/filesystems.conf b/conf/filesystems.conf new file mode 100644 index 0000000..3291773 --- /dev/null +++ b/conf/filesystems.conf @@ -0,0 +1,4 @@ +# Provides an equivalent to the builtin vfs.fs.discovery, but works +# on older agent (pre 2.0.0) and FreeBSD +# Uncomment to enable +#UserParameter=vfs.fs.discovery,/var/lib/zabbix/bin/disco_filesystems diff --git a/scripts/disco_filesystems b/scripts/disco_filesystems new file mode 100644 index 0000000..97b7154 --- /dev/null +++ b/scripts/disco_filesystems @@ -0,0 +1,35 @@ +#!/usr/bin/perl + +$first = 1; + +print "{\n"; +print "\t\"data\":[\n\n"; + +my $cmd; +my $re; +# On Linux, parse /proc/mounts +if (-e "/proc/mounts"){ + $cmd = 'cat /proc/mounts'; + $re = qr/\S+ (\S+) (\S+)/; +} +# On BSD (at least pfsense), there's no /proc/mounts +# parse the mount output +else{ + $cmd = '/sbin/mount'; + $re = qr/on (\S+) \((\S+), /; +} +for (`$cmd`){ + ($fsname, $fstype) = m/$re/; + $fsname =~ s!/!\\/!g; + + print "\t,\n" if not $first; + $first = 0; + + print "\t{\n"; + print "\t\t\"{#FSNAME}\":\"$fsname\",\n"; + print "\t\t\"{#FSTYPE}\":\"$fstype\"\n"; + print "\t}\n"; +} + +print "\n\t]\n"; +print "}\n";