diff options
author | Subhendu Ghosh <sghosh@users.sourceforge.net> | 2002-08-14 15:29:58 +0000 |
---|---|---|
committer | Subhendu Ghosh <sghosh@users.sourceforge.net> | 2002-08-14 15:29:58 +0000 |
commit | 2e24418ea7c179d2db3eccf9a6b6b4378e2857d2 (patch) | |
tree | 613e25bd7b03eb1a6cfce39d4e21516c3f189e92 /contrib/check_smb.sh | |
parent | e5822d19fc6cf2398ead6a465f2cede568e12ee7 (diff) | |
download | monitoring-plugins-2e24418ea7c179d2db3eccf9a6b6b4378e2857d2.tar.gz |
new smb check - users
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@71 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'contrib/check_smb.sh')
-rw-r--r-- | contrib/check_smb.sh | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/contrib/check_smb.sh b/contrib/check_smb.sh new file mode 100644 index 00000000..728535a1 --- /dev/null +++ b/contrib/check_smb.sh | |||
@@ -0,0 +1,111 @@ | |||
1 | #!/bin/bash | ||
2 | # | ||
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 | # : | ||
23 | |||
24 | # | ||
25 | # Shamelessly stolen from other Nagios plugins. | ||
26 | # | ||
27 | PROGNAME=`basename $0` | ||
28 | PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'` | ||
29 | REVISION=`echo '$Revision$' | sed -e 's/[^0-9.]//g'` | ||
30 | |||
31 | |||
32 | . $PROGPATH/utils.sh | ||
33 | |||
34 | print_usage() { | ||
35 | echo "Usage: $PROGNAME --help" | ||
36 | echo "Usage: $PROGNAME --version" | ||
37 | } | ||
38 | |||
39 | print_help() { | ||
40 | print_revision $PROGNAME $REVISION | ||
41 | echo "" | ||
42 | print_usage | ||
43 | echo "" | ||
44 | echo "Samba status check." | ||
45 | echo "" | ||
46 | support | ||
47 | } | ||
48 | |||
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. | ||
52 | |||
53 | if [ $# -gt 1 ]; then | ||
54 | print_usage | ||
55 | exit $STATE_UNKNOWN | ||
56 | fi | ||
57 | |||
58 | |||
59 | # | ||
60 | # If we have arguments, process them. | ||
61 | # | ||
62 | exitstatus=$STATE_WARNING #default | ||
63 | while test -n "$1"; do | ||
64 | case "$1" in | ||
65 | --help) | ||
66 | print_help | ||
67 | exit $STATE_OK | ||
68 | ;; | ||
69 | -h) | ||
70 | print_help | ||
71 | exit $STATE_OK | ||
72 | ;; | ||
73 | --version) | ||
74 | print_revision $PROGNAME $REVISION | ||
75 | exit $STATE_OK | ||
76 | ;; | ||
77 | -V) | ||
78 | print_revision $PROGNAME $REVISION | ||
79 | exit $STATE_OK | ||
80 | ;; | ||
81 | |||
82 | *) | ||
83 | echo "Unknown argument: $1" | ||
84 | print_usage | ||
85 | exit $STATE_UNKNOWN | ||
86 | ;; | ||
87 | esac | ||
88 | shift | ||
89 | done | ||
90 | |||
91 | # | ||
92 | # No arguments. Let's kick this pig. | ||
93 | # | ||
94 | total_users=$(smbstatus -b | grep "^[0-9]" | wc -l) | ||
95 | |||
96 | # | ||
97 | # Ok, now let's grab a count of the files. | ||
98 | # | ||
99 | total_files=$(smbstatus | grep "^[0-9]" | wc -l) | ||
100 | |||
101 | # | ||
102 | # now for the dismount. | ||
103 | # | ||
104 | echo "Total Users:$total_users Total Files:$total_files" | ||
105 | |||
106 | # | ||
107 | # let Nagios know that everything is ok. | ||
108 | # | ||
109 | exit $STATE_OK | ||
110 | |||
111 | |||