Cleanup config.nodes_of
[check_mk.git] / agents / plugins / nfsexports.solaris
blob858682f72bab972a17b1b9b2a6a1852719be1c30
1 #!/usr/bin/bash
2 # +------------------------------------------------------------------+
3 # | ____ _ _ __ __ _ __ |
4 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
5 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
6 # | | |___| | | | __/ (__| < | | | | . \ |
7 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
8 # | |
9 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
10 # +------------------------------------------------------------------+
12 # This file is part of Check_MK.
13 # The official homepage is at http://mathias-kettner.de/check_mk.
15 # check_mk is free software; you can redistribute it and/or modify it
16 # under the terms of the GNU General Public License as published by
17 # the Free Software Foundation in version 2. check_mk is distributed
18 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
19 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
20 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
21 # tails. You should have received a copy of the GNU General Public
22 # License along with GNU Make; see the file COPYING. If not, write
23 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
24 # Boston, MA 02110-1301 USA.
26 # Check_MK agent plugin for monitoring nfsexports on Solaris. This plugin
27 # has been tested with solaris 10 in a standalone and cluster setting.
29 clusterconfigdir="/etc/cluster/ccr/global/directory"
30 if [ -r "$clusterconfigdir" ]; then
31 # is a clustered nfs server
32 nfsconfig=/etc/cluster/ccr/global/$(grep rgm $clusterconfigdir | grep nfs | grep rg_)
33 if [ -r "$nfsconfig" ]; then
34 Pathprefix=$(grep Pathprefix "$nfsconfig" | awk {'print $2'})/SUNW.nfs
35 dfstabfile=$Pathprefix/dfstab.$(grep -v FilesystemMountPoints "$nfsconfig" | grep SUNW.nfs | \
36 awk {'print $1'} | sed -e 's/RS_//')
37 if [ -r "$dfstabfile" ]; then
38 EXPORTS=$(grep -v ^\# "$dfstabfile" | grep -v ^$)
39 ps -aef | grep nfsd | grep "$Pathprefix" >/dev/null && DAEMONS="ok"
42 else
43 # is a standalone nfs server
44 dfstabfile="/etc/dfs/dfstab"
45 if [ -r $dfstabfile ]; then
46 EXPORTS=$(grep -v ^\# $dfstabfile | grep -v ^$)
47 elif [ -x /usr/sbin/zfs ]; then
48 EXPORTS=$(zfs get sharenfs)
51 if [ -n "$EXPORTS" ]; then
52 svcs -a | grep nfs/server | grep ^online >/dev/null && DAEMONS="ok"
56 # any exports or have running daemons? then look for registered exports
57 if [ -n "$EXPORTS" ]; then
58 echo "<<<nfsexports>>>"
59 if [ -n "$DAEMONS" ]; then
60 showmount -e | grep ^/