check_share

check_share

Original Author: Alan Pipitone, can be found on http://www.alan-pipitone.com/ Many Enhancements by Ulf Lange

This plug-in is free and open source, so It has no warranty.

To function properly it needs java (7 or higher). It also needs the Java library jcifs (http://jcifs.samba.org/).

If you want to edit the source file and redistribute it, please give me a thank in your documentation and on the website (if it's possible) where you will upload your file. If you use jcifs, You must read and follow their licensing terms.

How install:

First of all you need Java 7 or higher on your Nagios server. Then follow these steps:

Copy the check_share.jar and the folder lib (can be extracted from lib.zip) to the libexec directory of your Nagios base directory (/usr/lib/nagios/libexec , in my case).

To print the help run "java -jar /usr/local/nagios/libexec/check_share.jar" on the shell.

How to configure Nagios (an example):

Edit the file commands.cfg in the objects directory of your Nagios base directory (/usr/local/nagios/etc/objects , in my case) and insert this lines:

 define command {
        command_name    check_share
        command_line    java -jar $USER1$/check_share.jar "--filename=$ARG1$" "--remoteshare=$ARG2$" --username=$ARG3$ --password=$ARG4$ --domain=$ARG5$ --warning=$ARG6$ --critical=$ARG7$ --resptimeout=15000 --sotimeout=10000
}

where \$USER1\$ is the variable that contains the libexec directory of your Nagios base directory (you can put /usr/local/nagios/libexec instead of \$USER1\$) and /var/nagios_temp/ is a directory that I created on my Nagios server. Of course you can change the value of the arguments.

Note that I used the quotes for the arguments ---filename and ---remoteshare. In this way you can check share that contain spaces in in their path (and if you want to create a text file with spaces in its name).

Now you can define your service as follows:

define service {
    use         your_service_template
    host_name       your_host_name
    service_description check share on \\server1.domain.local\share01
    check_command       check_share!check_server1_share01.txt!smb://server1.domain.local/share01/!user001!Password2011!domain
!2.5!6
}

Note that i use this convention: text file name = "check_ + server name + share name + .txt" but you can choose what you want.

If you have share (or sub directory) with spaces in their path you can follow below example

define service {
    use         your_service_template
    host_name       your_host_name
    service_description check share on \\server1.domain.local\share01\sub folder\
    check_command       check_share!check_server1_share01_sub_folder.txt!smb://server1.domain.local/share01/sub folder/!user001!Password2011!domain
}

You can use spaces because we have insert the quotes in the command definition.