Page 1 of 1

Alert if file exists

Posted: Tue Jun 25, 2019 9:15 am
by ronaldocr
We are having issues where lot of core file are being generated and dumped in /var/core. I would like to know how can I set up alert so it alert whenever a core file exists in the /var/core. I see there is a check_file_age plugin it alerts if the file does not exist, I want to get an alert if file exists. Please let me.

Thanks in advance.

Re: Alert if file exists

Posted: Tue Jun 25, 2019 2:14 pm
by lmiltchev
You will be better off using the folder_watch.pl plugin that ships with Nagios XI. You could run something like this:

Code: Select all

/usr/local/nagios/libexec/folder_watch.pl  -D /var/core -F '[^\0]+' -C 'ls -lA' -r -w 0: -c 0 -f
You will get OK status from the plugin if the directory is empty, and will get CRITICAL if there is one or more files in it.