Monitor a directory on RHEL

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
Chite
Posts: 23
Joined: Tue Jan 26, 2016 5:32 pm

Monitor a directory on RHEL

Post 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
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: Monitor a directory on RHEL

Post 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
Be sure to check out the Knowledgebase for helpful articles and solutions!
Chite
Posts: 23
Joined: Tue Jan 26, 2016 5:32 pm

Re: Monitor a directory on RHEL

Post by Chite »

Ok, thanks I'll check them out and let you know if I have any questions
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: Monitor a directory on RHEL

Post by bwallace »

Sounds good, we'll leave this thread open in the meantime.
Be sure to check out the Knowledgebase for helpful articles and solutions!
Chite
Posts: 23
Joined: Tue Jan 26, 2016 5:32 pm

Re: Monitor a directory on RHEL

Post 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
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Monitor a directory on RHEL

Post 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.
Former Nagios Employee
Locked