Page 1 of 1

Monitor a directory on RHEL

Posted: Tue Oct 04, 2016 12:19 pm
by Chite
Is there a way in Nagios XI to monitor if files exist in a certain directory? recently we've had someone or something removing files in a Scripts directory. My goal is to alarm on when files are removed from this directory. any thoughts on how I can use Nagios for this?

thanks!

Chaden

Re: Monitor a directory on RHEL

Posted: Tue Oct 04, 2016 3:05 pm
by bwallace
There are a number of plugins on our exchange site which will achieve this goal.

Here is a link to all of the plugins under the category of 'filesystem' :
https://exchange.nagios.org/directory/P ... ile-System

To be more specific , the following should work for you but it depends on whether or not you expect the size of the /dir in question to remain static, to check for the existence of one file or a group of files, or just check on file age. Best that you review and let us know if you have any questions:

https://exchange.nagios.org/directory/P ... ry/details
https://exchange.nagios.org/directory/P ... e)/details
https://exchange.nagios.org/directory/P ... ts/details
https://exchange.nagios.org/directory/P ... rs/details

Re: Monitor a directory on RHEL

Posted: Tue Oct 04, 2016 3:11 pm
by Chite
Ok, thanks I'll check them out and let you know if I have any questions

Re: Monitor a directory on RHEL

Posted: Tue Oct 04, 2016 3:41 pm
by bwallace
Sounds good, we'll leave this thread open in the meantime.

Re: Monitor a directory on RHEL

Posted: Thu Oct 06, 2016 2:39 pm
by Chite
I've chosen to use the "check_file_exists" plugin. Does anyone know if there's a way to authenticate with a different user? I have a scripts directory under /home/applmgr/Scripts that's owned by applmgr and nagios doesn't have access to the scripts directory. I'm a little new to linux so I know I could probably change permissions under the Scripts directory, but I don't want to open it to other users. is it possible to maybe run the script as "applmgr" ?

if I run the check as is, I'm getting a critical alarm saying "CRITICAL : /home/applmgr/Scripts/apps_manager Does NOT exists" even though I can see the file exists. I believe it's an issue with nagios' permissions to this directory

thanks!!

Chaden

Re: Monitor a directory on RHEL

Posted: Thu Oct 06, 2016 3:09 pm
by rkennedy
Depending on how you installed NRPE, this could vary.

Take a look at /etc/xinetd.d/nrpe -

Code: Select all


# default: on
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
        flags           = REUSE
        socket_type     = stream
        port            = 5666
        wait            = no
        user            = nagios
        group           = nagios
        server          = /usr/local/nagios/bin/nrpe
        server_args     = -c /usr/local/nagios/etc/nrpe.cfg --inetd
        log_on_failure  += USERID
        disable         = no
        only_from       = 127.0.0.1 192.168.4.179
}

This file will allow you to change the user / group NRPE runs on with these two variables -

Code: Select all

        user            = nagios
        group           = nagios
After modifying it, you'll want to restart the xinetd service for the change to take affect.