Whitespace changes only
[monitoring-plugins.git] / contrib / check_smb.sh
blob9d0da7265e98de48aefdb430e2a09c297af3729b
1 #!/bin/bash
3 # Program : check_smb
4 # :
5 # Author : Cal Evans <cal@calevans.com>
6 # :
7 # Purpose : Nagios plugin to return the number of users logged into a smb
8 # : server and the number of files open.
9 # :
10 # Parameters : --help
11 # : --version
12 # :
13 # Returns : Standard Nagios status_* codes as defined in utils.sh
14 # :
15 # Notes :
16 #============:==============================================================
17 # 1.0 : 06/27/2002
18 # : Initial coding
19 # :
20 # 1.1 : 06/28/2002
21 # : Re-wrote the user counter to match the file-lock counter.
22 # :
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'`
32 . $PROGPATH/utils.sh
34 print_usage() {
35 echo "Usage: $PROGNAME --help"
36 echo "Usage: $PROGNAME --version"
39 print_help() {
40 print_revision $PROGNAME $REVISION
41 echo ""
42 print_usage
43 echo ""
44 echo "Samba status check."
45 echo ""
46 support
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
51 # condition.
53 if [ $# -gt 1 ]; then
54 print_usage
55 exit $STATE_UNKNOWN
60 # If we have arguments, process them.
62 exitstatus=$STATE_WARNING #default
63 while test -n "$1"; do
64 case "$1" in
65 --help)
66 print_help
67 exit $STATE_OK
69 -h)
70 print_help
71 exit $STATE_OK
73 --version)
74 print_revision $PROGNAME $REVISION
75 exit $STATE_OK
77 -V)
78 print_revision $PROGNAME $REVISION
79 exit $STATE_OK
83 echo "Unknown argument: $1"
84 print_usage
85 exit $STATE_UNKNOWN
87 esac
88 shift
89 done
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.
109 exit $STATE_OK