Need Plugin Recommendation For Monitoring Shared Folder

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Jacktivated
Posts: 33
Joined: Wed Nov 25, 2015 1:49 pm

Need Plugin Recommendation For Monitoring Shared Folder

Post by Jacktivated »

Greetings,

I have attempted to locate a plugin to do this, but have not yet found what I'm looking for in the Nagios Exchange. I need a recommendation on what plugin I should use to monitor a password-protected inter-network shared directory, and notify me when the credentials expire (approx every 60 days).

DETAILED SCENARIO:
Users upload scanned documents to our website. The files are placed temporarily in a folder that is being watched by one of our servers and, when a file arrives, our server copies the file to another folder where it gets imported into an archive, that can be viewed by the users online, etc.

The problem is that the folder is password protected and the password expires every 60 days. Once this happens, users start calling customer service, complaining that they can't view their documents on our site. Customer service notifies me. I then notify the website developer, who then resets the password. This whole process usually equates to several hours and can cause up to a hundred phone calls in one day.

I have asked the developer to make it never expire (since we are the only ones accessing it), but he said he tried and can't do it because the share was created on a small business server or some such.

REQUEST:
So, rather than waiting for 100+ users to call us every couple of months, or even have a reminder timer for myself, I would like to set it up so Nagios is actively checking and authenticating the credentials against this network share and, as soon as the share is not accessible, send a notification directly to the website developer (along with a copy to me).

Thanks in advance. This is a great forum.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Need Plugin Recommendation For Monitoring Shared Folder

Post by rkennedy »

Just to make sure - you would be creating one service check for each user right?

You would need to create a custom powershell script that checks if the password is expired for that specific user.
Here's a reference that should help -
https://gallery.technet.microsoft.com/s ... e-f27b7d39

You can then use a service check with NSClient++ to run that remote powershell script and report back to your Nagios.
Former Nagios Employee
Jacktivated
Posts: 33
Joined: Wed Nov 25, 2015 1:49 pm

Re: Need Plugin Recommendation For Monitoring Shared Folder

Post by Jacktivated »

rkennedy wrote:Just to make sure - you would be creating one service check for each user right?

You would need to create a custom powershell script that checks if the password is expired for that specific user.
Here's a reference that should help -
https://gallery.technet.microsoft.com/s ... e-f27b7d39

You can then use a service check with NSClient++ to run that remote powershell script and report back to your Nagios.
Thanks for the reply.

There is only one user that needs to authenticate, and that's our server. The password never changes, it just expires. It is then reset to the same password again once we tell the developer it's no longer working.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Need Plugin Recommendation For Monitoring Shared Folder

Post by rkennedy »

Former Nagios Employee
Jacktivated
Posts: 33
Joined: Wed Nov 25, 2015 1:49 pm

Re: Need Plugin Recommendation For Monitoring Shared Folder

Post by Jacktivated »

rkennedy wrote:Thanks for the clarification. Would one of these work for you?

https://exchange.nagios.org/directory/P ... re/details
https://exchange.nagios.org/directory/P ... AA/details
The share is not on our domain, so the first one is out, since it is for a domain account. But, the first one might work. I'm checking it out now and will let you know how it goes.

Thanks.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Need Plugin Recommendation For Monitoring Shared Folder

Post by rkennedy »

Sounds good, let us know the result once you have a chance to check it out.
Former Nagios Employee
Jacktivated
Posts: 33
Joined: Wed Nov 25, 2015 1:49 pm

Re: Need Plugin Recommendation For Monitoring Shared Folder

Post by Jacktivated »

rkennedy wrote:Sounds good, let us know the result once you have a chance to check it out.
Okay, I got a positive result from the command line for the second one (check_smb_share_AA), so that's great.

Now I have to figure out exactly what files to make changes to and what to type in them, lol.

Perhaps, since this is a much simpler plugin than say, "check_printer", this will be a good one to learn how to manage plugins with. I could really use some help getting from this point, to the finish line, if you don't mind.

Also, this isn't something that would show up in my dashboard, right? So, I'll need to just have it set up for email notification.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Need Plugin Recommendation For Monitoring Shared Folder

Post by rkennedy »

What is the full command you are using to check with that is returning the proper result for you? Can you post both the full input / output for us to take a look at?
Former Nagios Employee
Jacktivated
Posts: 33
Joined: Wed Nov 25, 2015 1:49 pm

Re: Need Plugin Recommendation For Monitoring Shared Folder

Post by Jacktivated »

rkennedy wrote:What is the full command you are using to check with that is returning the proper result for you? Can you post both the full input / output for us to take a look at?
Absolutely.
First, I checked the help for the plugin:

[root@nagioscore libexec]# ./check_smb_share_AA --help
check_smb_share_AA v1.1 (nagios-plugins 2.1.1)
The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute
copies of the plugins under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

Nagios plugin to check Windows share

Usage:
check_smb_share_AA -H <host> -U USER%PASSWORD -S SHARE
check_smb_share_AA --help
check_smb_share_AA --version

Here is what I ran and the result:
./check_smb_share_AA -H 66.XXX.XX.XX -U username%password -S sharefolder
OK Share : sharefolder
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Need Plugin Recommendation For Monitoring Shared Folder

Post by rkennedy »

Navigate to the directory where the config files are stored -

Code: Select all

cd /usr/local/nagios/etc/objects/
At the bottom of the file commands.cfg, add the following lines -
(this part does not need to be modified.)

Code: Select all

# 'check_smb_share_AA' command definition
define command{
        command_name    check_smb_share_AA
        command_line    $USER1$/check_smb_share_AA -H $HOSTADDRESS$ -U $ARG1$ -S $ARG2$
        }
From there, navigate to the folder where your host / service configuration files are stored -

Code: Select all

cd /usr/local/nagios/etc/servers/
Open a new file with the name '<host>.cfg' and add the following lines. Modify to your needs.

Code: Select all

define host {
        use                             linux-server
        host_name                       <host>
        alias                           <host alias>
        address                         <ip address of server>
        max_check_attempts              5
        check_period                    24x7
        notification_interval           30
        notification_period             24x7
}
define service {
        use                             generic-service
        host_name                      <host> (must be the same as the one entered above)
        service_description             <decription of service>
        check_command                   check_smb_share_AA!username%password!<share folder>
}
(modify the <host>, <host alias>, <ip address of server>, <description of service>, username%password, and <share folder> as it pertains to your environment.)

Notice that username%password is defined as $ARG1$, <share folder> corresponds to $ARG2$. You can add more $ARG#$ values if needed for a certain scripts.

Restart Nagios -

Code: Select all

service nagios restart
Now navigate to your 'Services' page and the check should be functioning properly.

Has this helped you setup a check?
Last edited by rkennedy on Wed Dec 09, 2015 4:00 pm, edited 1 time in total.
Reason: fixed commands.cfg directory.
Former Nagios Employee
Locked