5 # Author : Cal Evans <cal@calevans.com>
7 # Purpose : Nagios plugin to return the number of users logged into a smb
8 # : server and the number of files open.
13 # Returns : Standard Nagios status_* codes as defined in utils.sh
16 #============:==============================================================
21 # : Re-wrote the user counter to match the file-lock counter.
25 # Shamelessly stolen from other Nagios plugins.
27 PROGNAME
=`basename $0`
28 PROGPATH
=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'`
29 REVISION
=`echo '$Revision: 71 $' | sed -e 's/[^0-9.]//g'`
35 echo "Usage: $PROGNAME --help"
36 echo "Usage: $PROGNAME --version"
40 print_revision
$PROGNAME $REVISION
44 echo "Samba status check."
49 # No command line arguments are required for this script. We accept only 2,
50 # --help and --version. If more than 1 is passed in then we have an error
60 # If we have arguments, process them.
62 exitstatus
=$STATE_WARNING #default
63 while test -n "$1"; do
74 print_revision
$PROGNAME $REVISION
78 print_revision
$PROGNAME $REVISION
83 echo "Unknown argument: $1"
92 # No arguments. Let's kick this pig.
94 total_users
=$
(smbstatus
-b |
grep "^[0-9]" |
wc -l)
97 # Ok, now let's grab a count of the files.
99 total_files
=$
(smbstatus |
grep "^[0-9]" |
wc -l)
102 # now for the dismount.
104 echo "Total Users:$total_users Total Files:$total_files"
107 # let Nagios know that everything is ok.