monitor file count of a folder
monitor file count of a folder
Can Nagios monitor the file count of a particular folder? as in when it reaches a certain amount then an alert should be sent out
Re: monitor file count of a folder
Is this folder located on a Windows system, Linux, etc.? You could search for a suitable plugin on the Nagios Exchange:
https://exchange.nagios.org/
Once you find a plugin that works for you, you could add a command and a service to Nagios XI by following the document below:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
https://exchange.nagios.org/
Once you find a plugin that works for you, you could add a command and a service to Nagios XI by following the document below:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: monitor file count of a folder
i found a plugin (count_file.pl) that can work for me and i tested it on the command line and it worked for the nagios server, but how do i get it to monitor client servers? there is no option or arguement that lets you specify a client host to monitor like -H for host name of -C for community, am not sure how to monitor client remote hosts.. see command below for nagios servers it self
libexec]# ./count_file.pl /tmp 100 120
OK: Filecount of '/tmp' 10.
libexec]# ./count_file.pl /tmp 100 120
OK: Filecount of '/tmp' 10.
Re: monitor file count of a folder
The plugin is designed to monitor file count locally, so you will have to copy the plugin to the client (remote machine). If you only have a few clients that you would like to monitor, you could copy the plugin via scp, e.g.
where you substitute x.x.x.x with the actual IP address of the remote machine.
If you had many clients, you could transfer the file in bulk to all of the machines via something like Ansible.
Once you have your plugin installed on the remote machine, you could call it from your Nagios XI server, via some kind of agent, e.g. NRPE, NCPA, etc.
Example with NRPE:
1. You will need to have NRPE agent installed. If you haven't installed it yet, you could follow this guide:
https://assets.nagios.com/downloads/nag ... _Agent.pdf
2. You add a new command definition to nrpe.cfg or common.cfg file on the remote machine (client), e.g.
and restart nrpe or xinet, depending on how you installed the agent:
or
3. Next you test it by running the following command from the command line on the Nagios XI server:
Actual example from my main test XI server:
Code: Select all
scp /usr/local/nagios/libexec/count_file.pl [email protected]:/usr/local/nagios/libexec/If you had many clients, you could transfer the file in bulk to all of the machines via something like Ansible.
Once you have your plugin installed on the remote machine, you could call it from your Nagios XI server, via some kind of agent, e.g. NRPE, NCPA, etc.
Example with NRPE:
1. You will need to have NRPE agent installed. If you haven't installed it yet, you could follow this guide:
https://assets.nagios.com/downloads/nag ... _Agent.pdf
2. You add a new command definition to nrpe.cfg or common.cfg file on the remote machine (client), e.g.
Code: Select all
command[check_count]=/usr/local/nagios/libexec/count_file.pl $ARG1$ $ARG2$ $ARG3$Code: Select all
service nrpe restartCode: Select all
service xinetd restartCode: Select all
/usr/local/nagios/libexec/check_nrpe -H <client ip> -c check_count -a /tmp 100 120Code: Select all
[root@main-nagios-xi ~]# /usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_count -a /tmp 100 120
Critical: Filecount of '/tmp' too large 950 > 100.Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: monitor file count of a folder
i am using ncpa, can i get the steps for that instead of nrpe?
Re: monitor file count of a folder
Sure. Copy the "count_file.pl" plugin to the "/usr/local/ncpa/plugins" directory on the remote machine, then run the following command on the Nagios XI server to test it:
where you substitute <client ip> and '<token> with the actual values.
Hope this helps.
Code: Select all
/usr/local/nagios/libexec/check_ncpa.py -H <client ip> -t '<token>' -M 'plugins/count_file.pl' -q 'args=/tmp,args=100,args=120'Hope this helps.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: monitor file count of a folder
it worked, thanks
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: monitor file count of a folder
Great!rnjie wrote:it worked, thanks
Locking