Page 1 of 2

Directory monitoring

Posted: Mon Dec 17, 2018 5:58 pm
by donnyforbes
We are needing to do a count on txt files in a certain directory and when there is more then 500 in that directory we need nagios to alert us via email. Here is what I have done, however what is the best way to do this?

On the remote server I created a script and put it here

Code: Select all

proxy4gl>pwd
/usr/local/nagios/libexec
Basically the script is basic and does the following.

Code: Select all

#!/bin/bash
#
# check /usr/rmca/doc_image/ directory for txt files
#
find /usr/rmca/doc_image/ -name *.txt | wc -l
I change the permission and group on the script and ran it as nagios and it seem to run fine.

Code: Select all

proxy4gl>whoami
nagios
proxy4gl>./check_files_txt.sh
110
proxy4gl>
I will add the command to the nagios server next. Please advise if this I am doing this correct. I have added the following to the nagios server

Code: Select all

command[check_files]=/usr/local/nagios/libexec/check_files_txt.sh
when testing from it I am getting this.

Code: Select all

[root@nag etc]# /usr/local/nagios/libexec/check_nrpe -H 192.168.1.12 -c check_files_txt.sh
NRPE: Command 'check_files_txt.sh' not defined
[root@nag etc]#
what am I doing wrong?


Thanks

Re: Directory monitoring

Posted: Tue Dec 18, 2018 2:42 pm
by npolovenko
Hi, @donnyforbes. I suggest using the following command instead:
command[check_files]=/usr/local/nagios/libexec/folder_watch.pl -T 'files' -D /usr/rmca/doc_image/ -F '*.txt' -w 480 -c 500
This should go on the remote nrpe server in the /usr/local/nagios/etc/nrpe.cfg file.

The command to run from the XI server will look like this:
/usr/local/nagios/libexec/check_nrpe -H 192.168.1.12 -c check_files

Re: Directory monitoring

Posted: Tue Dec 18, 2018 4:28 pm
by donnyforbes
Thanks for getting back to me. Here is what I did.

Remote Server:
vi /usr/local/nagios/etc/nrpe.cfg

added the following ...

Code: Select all

command[check_files]=/usr/local/nagios/libexec/folder_watch.pl -T 'files' -D /usr/rmca/doc_image/ -F '*.txt' -w 480 -c 500

Ran the following command on the Nagios server and got the following error message.

Code: Select all

[root@nag etc]# /usr/local/nagios/libexec/check_nrpe -H 192.168.1.12 -c check_files
NRPE: Unable to read output
[root@nag etc]#
Also I did stop /start the xinetd service on both servers.

What am i missing ? Thanks for your help..

Re: Directory monitoring

Posted: Tue Dec 18, 2018 4:46 pm
by donnyforbes
I did a a search for this folder_watch.pl in the /usr/local/nagios/libexec directory and that was not there.
Is this something I need to download or is this on the XI interface?

Re: Directory monitoring

Posted: Tue Dec 18, 2018 4:56 pm
by donnyforbes
I did check on the Nagios XI and I do see the plugin there, also on the Nagios server NOT remote server I do see the following

folder_watch.pl

Do I need to add this command

Code: Select all

command[check_files]=/usr/local/nagios/libexec/folder_watch.pl -T 'files' -D /usr/rmca/doc_image/ -F '*.txt' -w 480 -c 500
To the nagios server or the remote? I have it added on the remote server as of now...

Please advise .

Re: Directory monitoring

Posted: Tue Dec 18, 2018 5:20 pm
by npolovenko
@donnyforbes, Sorry I wasn't aware that this plugin doesn't come with nrpe by default. Please use WinSCP or FileZilla to copy over the plugin from the /usr/local/nagios/libexec folder on the nagios server to the same folder on the nrpe server.

Re: Directory monitoring

Posted: Tue Dec 18, 2018 5:28 pm
by donnyforbes
npolovenko wrote:@donnyforbes, Sorry I wasn't aware that this plugin doesn't come with nrpe by default. Please use WinSCP or FileZilla to copy over the plugin from the /usr/local/nagios/libexec folder on the nagios server to the same folder on the nrpe server.
So copy the plugin from my nagios server to the remote server is that what you are asking me to do?

Re: Directory monitoring

Posted: Tue Dec 18, 2018 5:31 pm
by donnyforbes
Ok this worked see below.

[root@nag libexec]# /usr/local/nagios/libexec/check_nrpe -H 192.168.1.12 -c check_files
OK - 0 *.txt files found
[root@nag libexec]#

Is says 0 found, however when i run this command on the remote server ... I get this

Code: Select all

proxy4gl>find /usr/rmca/doc_image/ -name *.txt | wc -l
110
proxy4gl>
Is something not correct? So one says there 110 and the other ones says there is 0. Any ideas?

Re: Directory monitoring

Posted: Tue Dec 18, 2018 5:36 pm
by npolovenko
@donnyforbes , Can you run ls -lR /usr/rmca/doc_image/ and show me the output?

Re: Directory monitoring

Posted: Tue Dec 18, 2018 5:42 pm
by donnyforbes
Sure here you go.

/usr/rmca/doc_image/:
total 360
drwxrwsrwx. 2 gene rmca 4096 Dec 14 09:50 aassful
drwxrwsrwx. 2 root rmca 4096 Dec 17 13:42 aassinv
drwxrwsrwx. 2 gene rmca 4096 Jul 2 2009 agginv
drwxrwsrwx. 2 root rmca 4096 Jan 26 2010 aggtkt
drwxrwsrwx. 2 gene rmca 4096 Mar 4 2010 apgarn
drwxrwsrwx. 2 gene rmca 4096 Jul 2 10:53 aspinv
drwxrwsrwx. 2 gene rmca 114688 Dec 17 15:29 asptkt -rw-r--r--. 1 gene rmca 36792 Mar 27 2015 caminv
drwxrwxrwx. 2 gene rmca 4096 Jul 6 2004 compdir
drwxrwsrwx. 2 root rmca 32768 Dec 18 09:37 compdwr drwxrwsrwx. 2 gene rmca 98304 Dec 17 11:37 constpo
drwxrwsrwx. 2 gene rmca 4096 Dec 18 12:43 continv
drwxrwsrwx. 2 gene rmca 4096 Dec 14 09:36 ddtoim
drwxrwsrwx. 2 root rmca 4096 May 19 2011 dirdpst
drwxrwsrwx. 2 gene rmca 4096 Aug 8 2006 dwrpost
drwxrwsrwx. 2 root rmca 4096 Feb 20 2015 edd2063
lrwxrwxrwx. 1 root rmca 7 May 29 2017 eddde2063 -> edd2063
drwxrwsrwx. 2 root rmca 4096 Feb 20 2015 justintest
drwxrwsrwx. 8 gene rmca 4096 Dec 14 09:39 miscinv
drwxrwsrwx. 2 gene rmca 4096 Sep 21 2011 newdd
drwxrwsrwx. 2 gene rmca 4096 Dec 18 08:57 otmappost
drwxrwsrwx. 2 gene rmca 4096 Jun 29 2012 prelim
drwxrwsrwx. 2 gene rmca 4096 Dec 12 03:00 temp
drwxrwsrwx. 2 gene rmca 4096 Dec 14 10:24 testtable
drwxrwsrwx. 5 gene rmca 4096 Dec 14 09:48 w2

/usr/rmca/doc_image/aassful:
total 86732
-rw-rw-r--. 1 305 rmca 765994 Jan 2 2014 010220.txt
-rw-rw-r--. 1 305 rmca 488380 Jan 5 2017 010520.txt
-rw-rw-r--. 1 305 rmca 470945 Jan 7 2015 010720.txt
-rw-rw-r--. 1 305 rmca 638089 Jan 11 2016 011120.txt
-rw-rw-r--. 1 305 rmca 727352 Jan 13 2014 011320.txt
-rw-rw-r--. 1 305 rmca 321863 Jan 18 2017 011820.txt
-rw-rw-r--. 1 305 rmca 445571 Jan 20 2016 012020.txt
-rw-rw-r--. 1 305 rmca 549610 Jan 24 2013 012420.txt
-rw-rw-r--. 1 305 rmca 626569 Jan 28 2014 012820.txt
-rw-r--r--. 1 367 rmca 884847 Feb 4 2015 020420.txt
-rw-rw-r--. 1 305 rmca 672100 Feb 8 2017 020820.txt
-rw-rw-r--. 1 305 rmca 698492 Feb 9 2016 020920.txt
-rw-rw-r--. 1 305 rmca 715078 Feb 10 2014 021020.txt
-rw-rw-r--. 1 305 rmca 664274 Feb 12 2013 021220.txt
-rw-rw-r--. 1 305 rmca 651905 Feb 22 2017 022220.txt
-rw-rw-r--. 1 305 rmca 741072 Feb 23 2016 022320.txt
-rw-rw-r--. 1 305 rmca 528170 Feb 26 2014 022620.txt
-rw-rw-r--. 1 305 rmca 623358 Mar 1 2013 030120.txt
-rw-rw-r--. 1 305 rmca 665216 Mar 4 2016 030420.txt
-rw-rw-r--. 1 305 rmca 547141 Mar 7 2017 030720.txt
-rw-rw-r--. 1 305 rmca 509374 Mar 8 2013 030820.txt
-rw-rw-r--. 1 305 rmca 690612 Mar 9 2015 030920.txt
-rw-rw-r--. 1 305 rmca 521466 Mar 10 2014 031020.txt
-rw-rw-r--. 1 305 rmca 894578 Mar 20 2017 032020.txt
-rw-rw-r--. 1 305 rmca 605868 Mar 21 2016 032120.txt
-rw-rw-r--. 1 305 rmca 609868 Mar 29 2013 032920.txt
-rw-rw-r--. 1 305 rmca 842627 Apr 7 2017 040720.txt
-rw-rw-r--. 1 305 rmca 797884 Apr 8 2016 040820.txt
-rw-rw-r--. 1 305 rmca 739001 Apr 9 2014 040920.txt
-rw-rw-r--. 1 305 rmca 651616 Apr 10 2013 041020.txt
-rw-rw-r--. 1 aaa_wm_1 rmca 701689 Apr 11 2018 041120.txt -rw-rw-r--. 1 aaa_wm_1 rmca 875802 Apr 24 2018 042420.txt
-rw-rw-r--. 1 305 rmca 660992 Apr 25 2016 042520.txt
-rw-rw-r--. 1 305 rmca 677048 Apr 28 2015 042820.txt
-rw-rw-r--. 1 305 rmca 611499 Apr 30 2013 043020.txt
-rw-rw-r--. 1 305 rmca 972688 May 5 2017 050520.txt
-rw-rw-r--. 1 305 rmca 845833 May 9 2016 050920.txt
-rw-rw-r--. 1 aaa_wm_1 rmca 954601 May 10 2018 051020.txt
-rw-rw-r--. 1 305 rmca 822394 May 11 2015 051120
-rw-r--r--. 1 gene rmca 690450 May 11 2012 051120.txt
-rw-rw-r--. 1 305 rmca 827612 May 14 2014 051420.txt
-rw-rw-r--. 1 aaa_wm_1 rmca 886939 May 24 2018 052420.txt
-rw-rw-r--. 1 305 rmca 882858 May 25 2017 052520.txt
-rw-rw-r--. 1 305 rmca 690017 May 28 2015 052820.txt
-rw-rw-r--. 1 305 rmca 759839 May 30 2014 053020.txt
-rw-rw-r--. 1 aaa_wm_1 rmca 910369 Jun 8 2018 060820.txt
-rw-rw-r--. 1 305 rmca 739483 Jun 10 2014 061020.txt
-rw-rw-r--. 1 305 rmca 717593 Jun 11 2015 061120.txt
-rw-rw-r--. 1 305 rmca 982889 Jun 12 2013 061220.txt
-rw-rw-r--. 1 aaa_wm_1 rmca 904112 Jun 20 09:57 062020.txt
-rw-rw-r--. 1 305 rmca 859955 Jun 22 2016 062220.txt
-rw-rw-r--. 1 305 rmca 891659 Jun 26 2015 062620.txt
-rw-rw-r--. 1 305 rmca 848484 Jun 27 2014 062720.txt
-rw-r--r--. 1 gene rmca 216101 Jul 3 2012 070320.bac
-rw-r--r--. 1 gene rmca 216101 Jul 3 2012 070320.txt
-rw-rw-r--. 1 305 rmca 918246 Jul 5 2016 070520.txt
-rw-rw-r--. 1 aaa_wm_1 rmca 910454 Jul 9 16:17 070920.txt
-rw-rw-r--. 1 305 rmca 911763 Jul 10 2013 071020.txt
-rw-r--r--. 1 305 rmca 729878 Jul 11 2012 071120.txt
-rw-rw-r--. 1 305 rmca 915001 Jul 13 2015 071320.txt
-rw-rw-r--. 1 305 rmca 897338 Jul 14 2014 071420.txt
-rw-rw-r--. 1 305 rmca 783293 Jul 20 2016 072020.txt
-rw-rw-r--. 1 305 rmca 769603 Jul 23 2013 072320.txt
-rw-rw-r--. 1 aaa_wm_1 rmca 767145 Jul 24 10:54 072420.txt
-rw-rw-r--. 1 305 rmca 859409 Jul 29 2015 072920.txt
-rw-r--r--. 1 305 rmca 665843 Jul 31 2012 073120.txt
-rw-rw-r--. 1 305 rmca 1037014 Aug 8 2013 080820.txt
-rw-rw-r--. 1 aaa_wm_1 rmca 1025247 Aug 10 09:15 081020.txt
-rw-rw-r--. 1 305 rmca 1027573 Aug 13 2014 081320.txt
-rw-rw-r--. 1 305 rmca 953346 Aug 18 2016 081820.txt
-rw-rw-r--. 1 305 rmca 993558 Aug 22 2016 082220.txt
-rw-rw-r--. 1 aaa_wm_1 rmca 998551 Aug 24 11:30 082420.txt
-rw-rw-r--. 1 305 rmca 1129835 Aug 26 2015 082620.txt
-rw-rw-r--. 1 305 rmca 999776 Aug 29 2013 082920.txt
-rw-rw-r--. 1 305 rmca 1063198 Sep 2 2016 090220.txt
-rw-rw-r--. 1 305 rmca 971750 Sep 4 2012 090420.txt
-rw-rw-r--. 1 aaa_wm_1 rmca 1041347 Sep 11 16:15 091120.txt
-rw-rw-r--. 1 305 rmca 1067275 Sep 12 2012 091220.txt
-rw-rw-r--. 1 305 rmca 1062820 Sep 14 2015 091420.txt
-rw-rw-r--. 1 305 rmca 946837 Sep 15 2014 091520.txt
-rw-rw-r--. 1 aaa_wm_1 rmca 840388 Sep 24 15:30 092420.txt
-rw-rw-r--. 1 305 rmca 846327 Sep 27 2013 092720.txt
-rw-rw-r--. 1 305 rmca 847689 Sep 30 2016 093020.txt
-rw-rw-r--. 1 305 rmca 932664 Oct 3 2014 100320.txt
-rw-rw-r--. 1 305 rmca 751296 Oct 4 2012 100420.txt
-rw-rw-r--. 1 aaa_wm_1 rmca 894625 Oct 8 16:22 100820.txt
-rw-rw-r--. 1 305 rmca 975478 Oct 11 2016 101120.txt
-rw-rw-r--. 1 305 rmca 921937 Oct 13 2015 101320.txt
-rw-rw-r--. 1 305 rmca 963476 Oct 15 2014 101520.txt
-rw-rw-r--. 1 aaa_wm_1 rmca 817363 Oct 23 10:36 102320.txt
-rw-rw-r--. 1 305 rmca 885417 Oct 25 2016 102520.txt
-rw-rw-r--. 1 305 rmca 880608 Oct 27 2015 102720.txt
-rw-rw-r--. 1 305 rmca 922781 Oct 29 2014 102920.txt
-rw-rw-r--. 1 305 rmca 790103 Nov 1 2012 110120.txt
-rw-rw-r--. 1 305 rmca 967411 Nov 6 2015 110620.txt
-rw-rw-r--. 1 aaa_wm_1 rmca 1053059 Nov 7 14:35 110720.txt
-rw-rw-r--. 1 305 rmca 1081352 Nov 12 2014 111220.txt
-rw-rw-r--. 1 305 rmca 816422 Nov 15 2016 111520
-rw-rw-r--. 1 305 rmca 154407 Nov 15 2012 111520-1.txt
-rw-r--r--. 1 gene rmca 739418 Nov 15 2012 111520.txt
-rw-rw-r--. 1 aaa_wm_1 rmca 918332 Nov 20 13:20 112020.txt
-rw-rw-r--. 1 305 rmca 843443 Nov 21 2016 112120.txt
-rw-rw-r--. 1 305 rmca 721358 Nov 23 2015 112320.txt
-rw-rw-r--. 1 305 rmca 876772 Nov 26 2013 112620.txt
-rw-r--r--. 1 gene rmca 780737 Nov 29 2012 112920.txt
-rw-rw-r--. 1 305 rmca 760809 Dec 2 2014 120220.txt
-rw-rw-r--. 1 305 rmca 605010 Dec 8 2016 120820.txt
-rw-rw-r--. 1 aaa_wm_1 rmca 630432 Dec 10 11:32 121020.txt
-rw-rw-r--. 1 305 rmca 715935 Dec 12 2014 121220.txt
-rw-rw-r--. 1 305 rmca 681312 Dec 15 2015 121520.txt
-rw-rw-r--. 1 305 rmca 790687 Dec 20 2016 122020.txt
-rw-rw-r--. 1 305 rmca 757455 Dec 28 2015 122820.txt
-rw-rw-r--. 1 305 rmca 528027 Dec 30 2014 123020.txt

/usr/rmca/doc_image/aassinv:
total 1132
-rw-rw-r--. 1 aaa_wm_1 rmca 10144 Aug 22 10:05 082218 -rw-rw-r--. 1 aaa_wm_1 rmca 56964 Aug 28 13:22 082818 -rw-rw-r--. 1 aaa_wm_1 rmca 18712 Aug 31 14:25 083118
-rw-rw-r--. 1 aaa_wm_1 rmca 4505 Sep 5 09:39 090518
-rw-rw-r--. 1 aaa_wm_1 rmca 1563 Sep 11 14:44 091118
-rw-rw-r--. 1 aaa_wm_1 rmca 194359 Sep 20 15:36 092018
-rw-rw-r--. 1 aaa_wm_1 rmca 2188 Sep 21 09:20 092118
-rw-rw-r--. 1 aaa_wm_1 rmca 86490 Sep 24 09:43 092418 -rw-rw-r--. 1 aaa_wm_1 rmca 43494 Sep 26 11:22 092618
-rw-rw-r--. 1 aaa_wm_1 rmca 9984 Sep 27 15:02 092718
-rw-rw-r--. 1 aaa_wm_1 rmca 67630 Sep 28 10:52 092818 -rw-rw-r--. 1 aaa_wm_1 rmca 45744 Oct 4 16:57 100418 -rw-rw-r--. 1 aaa_wm_1 rmca 15873 Oct 9 09:52 100918
-rw-rw-r--. 1 aaa_wm_1 rmca 3126 Oct 12 11:46 101218
-rw-rw-r--. 1 aaa_wm_1 rmca 8737 Oct 16 12:32 101618
-rw-rw-r--. 1 aaa_wm_1 rmca 34290 Oct 18 09:13 101818 -rw-rw-r--. 1 aaa_wm_1 rmca 32017 Oct 23 11:50 102318
-rw-rw-r--. 1 aaa_wm_1 rmca 6999 Oct 26 09:00 102618
-rw-rw-r--. 1 aaa_wm_1 rmca 180377 Oct 30 09:36 103018
-rw-rw-r--. 1 aaa_wm_1 rmca 1706 Nov 2 09:26 110218
-rw-rw-r--. 1 aaa_wm_1 rmca 25347 Nov 5 12:59 110518 -rw-rw-r--. 1 aaa_wm_1 rmca 19246 Nov 8 14:43 110818 -rw-rw-r--. 1 aaa_wm_1 rmca 46028 Nov 15 11:29 111518 -rw-rw-r--. 1 aaa_wm_1 rmca 43889 Nov 19 09:33 111918 -rw-rw-r--. 1 aaa_wm_1 rmca 43795 Nov 26 11:57 112618 -rw-rw-r--. 1 aaa_wm_1 rmca 39836 Nov 30 15:26 113018 -rw-rw-r--. 1 aaa_wm_1 rmca 46478 Dec 7 10:30 120718
-rw-rw-r--. 1 aaa_wm_1 rmca 3014 Dec 10 10:02 121018
-rw-rw-r--. 1 aaa_wm_1 rmca 1438 Dec 11 10:51 121118
-rw-rw-r--. 1 aaa_wm_1 rmca 3124 Dec 12 12:45 121218

/usr/rmca/doc_image/agginv:
total 0

/usr/rmca/doc_image/aggtkt:
total 0

/usr/rmca/doc_image/apgarn:
total 0

/usr/rmca/doc_image/aspinv:
total 912
-rw-rw-r--. 1 212 rmca 634880 Jun 17 2016 061720160622.out -rw-rw-r--. 1 212 rmca 299008 Aug 15 2016 081520160850.out

/usr/rmca/doc_image/asptkt:
total 4
-rw-r--r--. 1 gene rmca 1355 Sep 21 13:37 holder.out

/usr/rmca/doc_image/compdir:
total 0

/usr/rmca/doc_image/compdwr:
total 0

/usr/rmca/doc_image/constpo:
total 0

/usr/rmca/doc_image/continv:
total 0

/usr/rmca/doc_image/ddtoim:
total 0

/usr/rmca/doc_image/dirdpst:
total 0

/usr/rmca/doc_image/dwrpost:
total 0

/usr/rmca/doc_image/edd2063:
total 0

/usr/rmca/doc_image/justintest:
total 0

/usr/rmca/doc_image/miscinv:
total 24
drwxrwsrwx. 2 gene rmca 4096 Dec 17 14:26 27 drwxrwsrwx. 2 gene rmca 4096 Nov 20 15:14 34 drwxrwsrwx. 2 gene rmca 4096 Nov 27 14:07 36 drwxrwsrwx. 2 gene rmca 4096 Dec 12 17:16 37 drwxrwsrwx. 2 gene rmca 4096 Dec 18 08:37 38 drwxrwsrwx. 2 gene rmca 4096 Dec 18 08:40 39

/usr/rmca/doc_image/miscinv/27:
total 56
-rw-rw-r--. 1 aaa_wm_1 rmca 21083 Dec 17 12:53 1217181253206 -rw-rw-r--. 1 aaa_wm_1 rmca 2400 Dec 17 14:26 1217181426206
-rw-r--r--. 1 gene rmca 27171 Apr 18 2018 test.out

/usr/rmca/doc_image/miscinv/34:
total 0

/usr/rmca/doc_image/miscinv/36:
total 0

/usr/rmca/doc_image/miscinv/37:
total 0

/usr/rmca/doc_image/miscinv/38:
total 0

/usr/rmca/doc_image/miscinv/39:
total 4
-rw-rw-r--. 1 aaa_wm_1 rmca 3115 Dec 18 08:40 1218180840206

/usr/rmca/doc_image/newdd:
total 0

/usr/rmca/doc_image/otmappost:
total 4
-rw-r--r--. 1 gene rmca 797 Jan 16 2017 report2

/usr/rmca/doc_image/prelim:
total 204
-rw-r--r--. 1 324 rmca 53248 Mar 19 2008 324142542.out -rw-r--r--. 1 324 rmca 155648 Mar 28 2008 324144905.out

/usr/rmca/doc_image/temp:
total 0

/usr/rmca/doc_image/testtable:
total 64
-rw-r--r--. 1 gene rmca 63671 Sep 27 2007 092720071702.hld

/usr/rmca/doc_image/w2:
total 160
drwxrwsrwx. 2 gene rmca 4096 Apr 1 2011 2005
drwxrwsrwx. 2 gene rmca 4096 Jan 23 2014 2006
drwxrwsrwx. 2 gene rmca 4096 Feb 24 2014 2007
-rw-r--r--. 1 gene rmca 151186 Jul 30 2007 ACCRRPT.hold

/usr/rmca/doc_image/w2/2005:
total 0

/usr/rmca/doc_image/w2/2006:
total 2352
-rw-r--r--. 1 gene rmca 1867870 Jan 5 2010 AAA -rw-r--r--. 1 gene rmca 224686 Jan 5 2010 AASS -rw-r--r--. 1 gene rmca 220936 Jan 5 2010 BETTS
-rw-r--r--. 1 gene rmca 45416 Jan 5 2010 MTL
-rw-r--r--. 1 gene rmca 39124 Jan 5 2010 RAMSEY

/usr/rmca/doc_image/w2/2007:
total 4
-rw-r--r--. 1 gene rmca 2289 Nov 19 2009 4260.old