Check number of files on a directory

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Re: Check number of files on a directory

Postby cocoyanouck » Thu May 18, 2017 1:41 am

Arf ... :cry:

Code: Select all
root@nagios-debian:/home/nagios# /usr/local/nagios/libexec/check_nrpe -H 10.20.2.12 -c check_files -a path='C:\\Windows'
CHECK_NRPE STATE CRITICAL: Socket timeout after 10 seconds.
root@nagios-debian:/home/nagios# /usr/local/nagios/libexec/check_nrpe -H 10.20.2.12
Erreur de segmentation
Attachments
nsclient.log
(25.14 KiB) Downloaded 7 times
cocoyanouck
 
Posts: 59
Joined: Fri Apr 08, 2016 3:17 am

Re: Check number of files on a directory

Postby tgriep » Thu May 18, 2017 10:14 am

Edit the nsclient.ini file and remove all of nagios-debian entries,
Find this entry and change it from
Code: Select all
allow nasty characters = 1

to
Code: Select all
allow nasty characters = true


Find this entry and change it from
Code: Select all
level = info

to
Code: Select all
level = debug


save the file and restart the NSClient++ service.

Then run the check_nrpe command with the log file enabled to see if it captures any errors.
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H 10.20.2.12 -g /tmp/nrpe.log


If it fails, post the /tmp/nrpe.log file from the Nagios server and the nsclient.log file and the updated nsclient.ini file from the Windows Host.

One question, do you have the check_nrpe command working with other Windows servers?
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 6164
Joined: Thu Oct 30, 2014 9:02 am

Re: Check number of files on a directory

Postby cocoyanouck » Mon May 22, 2017 5:05 am

I have made all the modification, then :

Code: Select all
root@nagios-debian:/home/nagios# /usr/local/nagios/libexec/check_nrpe -H 10.20.2.12 -g /tmp/nrpe.log
I (0.5.0.62 2016-09-14) seem to be doing fine...


And the nsclient.log :

Code: Select all
2017-05-22 18:03:19: debug:c:\source\master\include\nrpe/server/protocol.hpp:72: Accepting connection from: 10.20.2.33, count=1
2017-05-22 18:03:19: debug:c:\source\master\include\nrpe/server/protocol.hpp:72: Accepting connection from: 10.20.2.33, count=1
2017-05-22 18:04:36: debug:c:\source\master\include\nrpe/server/protocol.hpp:72: Accepting connection from: 10.20.2.33, count=1
2017-05-22 18:04:36: debug:c:\source\master\include\nrpe/server/protocol.hpp:72: Accepting connection from: 10.20.2.33, count=1
2017-05-22 18:04:36: debug:c:\source\master\include\nrpe/server/protocol.hpp:72: Accepting connection from: 10.20.2.33, count=1
2017-05-22 18:04:36: debug:c:\source\master\include\nrpe/server/protocol.hpp:72: Accepting connection from: 10.20.2.33, count=1
2017-05-22 18:04:36: debug:c:\source\master\include\nrpe/server/protocol.hpp:72: Accepting connection from: 10.20.2.33, count=1
2017-05-22 18:04:36: debug:c:\source\master\include\nrpe/server/protocol.hpp:72: Accepting connection from: 10.20.2.33, count=1


I already use this file "nsclient.ini" and the command check_nrpe in order to check how many files there are in specifics folders. But not on this nagios-srv (which is located in a different country).
cocoyanouck
 
Posts: 59
Joined: Fri Apr 08, 2016 3:17 am

Re: Check number of files on a directory

Postby tgriep » Mon May 22, 2017 11:04 am

What do you mean by " But not on this nagios-srv (which is located in a different country)."

It looks like the check_nrpe test is working now without generating the Segmentation Error, and the nsclient.log file is not showing any errors.
Is the check_nrpe command that is checking the files in the D:\import\faxin folder functioning for you now?
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 6164
Joined: Thu Oct 30, 2014 9:02 am

Re: Check number of files on a directory

Postby cocoyanouck » Tue May 23, 2017 1:49 am

I want to tell you that the command check_nrpe with the check_files was working on my another nagios server but not on this one.

root@nagios-debian:/home/nagios# /usr/local/nagios/libexec/check_nrpe -H 10.20.2.12 -c check_files -a path='C:\\Windows'
Erreur de segmentation

root@nagios-debian:/home/nagios# /usr/local/nagios/libexec/check_nrpe -H 10.20.2.12 -c check_files -a path='D:\\import\\faxin' pattern=*.* 'warning=count>100' 'critical=count>150'
Erreur de segmentation


And on the nsclient.log :

Code: Select all
root@nagios-debian:/home/nagios# /usr/local/nagios/libexec/check_nrpe -H 10.20.2.12 -c check_files -a path='C:\\Windows'
Erreur de segmentation
root@nagios-debian:/home/nagios# /usr/local/nagios/libexec/check_nrpe -H 10.20.2.12 -c check_files -a path='C:\\Windows'^C
root@nagios-debian:/home/nagios# /usr/local/nagios/libexec/check_nrpe -H 10.20.2.12 -c check_files -a path='D:\\import\\faxin' pattern=*.* 'warning=count>100' 'critical=count>150'
Erreur de segmentation


So strange :/
cocoyanouck
 
Posts: 59
Joined: Fri Apr 08, 2016 3:17 am

Re: Check number of files on a directory

Postby tgriep » Tue May 23, 2017 9:35 am

Ok, I understand now.
Lets replace the check_nrpe plugin on the Nagios server and see if that fixes the issue.
Look at this link
https://support.nagios.com/kb/article/nrpe-how-to-install-nrpe-v3-from-source.html
search for this section in the link for the instructions on installing the check_nrpe plugin.
Install check_nrpe Plugin Only
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 6164
Joined: Thu Oct 30, 2014 9:02 am

Re: Check number of files on a directory

Postby cocoyanouck » Wed May 24, 2017 4:31 am

So, the installation of nrpe 3.1.0 is OK.

Launched these commands :
Code: Select all
root@nagios-debian:/home/nagios# /usr/local/nagios/libexec/check_nrpe -H 10.20.2.12
Erreur de segmentation
root@nagios-debian:/home/nagios# /usr/local/nagios/libexec/check_nrpe -H 10.20.2.12 -c check_files -a path='D:\\import\\faxin' pattern=*.* 'warning=count>100' 'critical=count>150'
Erreur de segmentation


Results :

Code: Select all
2017-05-24 17:29:29: debug:c:\source\master\include\nrpe/server/protocol.hpp:72: Accepting connection from: 10.20.2.33, count=1
2017-05-24 17:29:29: debug:c:\source\master\include\nrpe/server/protocol.hpp:72: Accepting connection from: 10.20.2.33, count=1
2017-05-24 17:29:29: debug:c:\source\master\include\check_nt/server/protocol.hpp:58: Accepting connection from: 10.20.2.33
2017-05-24 17:29:29: debug:c:\source\master\modules\NSClientServer\NSClientServer.cpp:302: Real command: check_drivesize drive=c warn=free<0 crit=free<0 filter=type='fixed' and mounted = 1 perf-config=used(unit:B)free(unit:B)
2017-05-24 17:29:31: debug:c:\source\master\include\nrpe/server/protocol.hpp:72: Accepting connection from: 10.20.2.33, count=1
2017-05-24 17:29:31: debug:c:\source\master\include\nrpe/server/protocol.hpp:72: Accepting connection from: 10.20.2.33, count=1
2017-05-24 17:29:31: debug:c:\source\master\include\check_nt/server/protocol.hpp:58: Accepting connection from: 10.20.2.33
2017-05-24 17:29:36: debug:c:\source\master\include\check_nt/server/protocol.hpp:58: Accepting connection from: 10.20.2.33
2017-05-24 17:29:36: debug:c:\source\master\modules\NSClientServer\NSClientServer.cpp:302: Real command: check_uptime warn=uptime<0
cocoyanouck
 
Posts: 59
Joined: Fri Apr 08, 2016 3:17 am

Re: Check number of files on a directory

Postby tgriep » Wed May 24, 2017 10:02 am

In the folder that you recompiled the check_nrpe command is a log file called config.log, can you post that file?
Can you run the following commands as root and post the output?
Code: Select all
uname -a
cat /etc/*release*


Can you run the check_nrpe command to another remote host without it crashing?
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 6164
Joined: Thu Oct 30, 2014 9:02 am

Re: Check number of files on a directory

Postby cocoyanouck » Mon May 29, 2017 6:50 am

Config.log :

Code: Select all
root@nagios-debian:/home/nagios/nrpe-nrpe-3.1.0# ls -l
total 532
-rwxrwxr-x 1 root root    283 avril 17 16:21 aclocal.m4
drwxrwxr-x 2 root root   4096 avril 17 16:21 build-aux
-rw-rw-r-- 1 root root  16286 avril 17 16:21 Changelog
-rw-r--r-- 1 root root  64616 mai   24 11:19 config.log
-rwxr-xr-x 1 root root  33002 mai   24 11:19 config.status
-rwxrwxr-x 1 root root 248809 avril 17 16:21 configure
-rw-rw-r-- 1 root root  11228 avril 17 16:21 configure.ac
drwxrwxr-x 2 root root   4096 avril 17 16:21 contrib
drwxrwxr-x 2 root root   4096 avril 17 16:21 docs
drwxrwxr-x 2 root root   4096 mai   24 11:19 include
-rw-rw-r-- 1 root root    441 avril 17 16:21 LEGAL
-rw-rw-r-- 1 root root  18092 avril 17 16:21 LICENSE
drwxrwxr-x 2 root root   4096 avril 17 16:21 macros
-rw-r--r-- 1 root root   6787 mai   24 11:19 Makefile
-rw-rw-r-- 1 root root   6768 avril 17 16:21 Makefile.in
-rw-r--r-- 1 root root   5871 mai   24 11:19 nrpe.spec
-rw-rw-r-- 1 root root   5884 avril 17 16:21 nrpe.spec.in
-rwxrwxr-x 1 root root   3248 avril 17 16:21 paths.in
-rw-rw-r-- 1 root root   7011 avril 17 16:21 README.md
-rw-rw-r-- 1 root root  11738 avril 17 16:21 README.SSL.md
drwxrwxr-x 2 root root   4096 mai   24 11:19 sample-config
-rw-rw-r-- 1 root root   3335 avril 17 16:21 SECURITY.md
drwxrwxr-x 2 root root   4096 mai   24 11:20 src
drwxrwxr-x 2 root root   4096 mai   24 11:19 startup
-rw-rw-r-- 1 root root    757 avril 17 16:21 THANKS
-rw-r--r-- 1 root root  10675 mai   24 11:19 uninstall
-rwxrwxr-x 1 root root  10637 avril 17 16:21 uninstall.in
-rwxrwxr-x 1 root root   4326 avril 17 16:21 update-cfg.pl
-rwxrwxr-x 1 root root   3071 avril 17 16:21 update-version
root@nagios-debian:/home/nagios/nrpe-nrpe-3.1.0# vi config.log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by nrpe configure 3.1.0-rc1, which was
generated by GNU Autoconf 2.69.  Invocation command line was

  $ ./configure

## --------- ##
## Platform. ##
## --------- ##

hostname = nagios-debian
uname -m = i686
uname -r = 3.16.0-4-686-pae
uname -s = Linux
uname -v = #1 SMP Debian 3.16.43-2 (2017-04-30)

/usr/bin/uname -p = unknown
/bin/uname -X     = unknown

/bin/arch              = unknown
/usr/bin/arch -k       = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo      = unknown
/bin/machine           = unknown
/usr/bin/oslevel       = unknown
/bin/universe          = unknown

PATH: /usr/local/sbin
PATH: /usr/local/bin
PATH: /usr/sbin
PATH: /usr/bin
PATH: /sbin
PATH: /bin


## ----------- ##
## Core tests. ##
## ----------- ##

configure:2540: checking for a BSD-compatible install
configure:2608: result: /usr/bin/install -c
configure:2628: checking what the operating system is
configure:2695: result: linux
configure:2706: checking what the distribution type is
configure:2818: result: debian
configure:2828: checking what init system is being used
configure:2971: result: systemd
configure:2981: checking what inetd is being used
configure:3070: result: systemd
configure:3114: checking for which paths to use
configure:3796: result: default
configure:3810: checking for which init file to use
configure:3853: result: default-service
configure:3856: checking for which inetd files to use
configure:3878: result: default-socket
configure:5027: checking for gcc
configure:5043: found /usr/bin/gcc
configure:5054: result: gcc
configure:5283: checking for C compiler version
configure:5292: gcc --version >&5
gcc (Debian 4.9.2-10) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
"config.log" 2196 lines, 64616 characters


Output :
Code: Select all
root@nagios-debian:~# uname -a
Linux nagios-debian 3.16.0-4-686-pae #1 SMP Debian 3.16.43-2 (2017-04-30) i686 GNU/Linux


Code: Select all
root@nagios-debian:~# cat /etc/*release*
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=debian
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"


I have installed the latest version of nsclient++ and copy the nsclient.ini which i already use on the other servers => same issue.
Code: Select all
root@nagios-debian:~# /usr/local/nagios/libexec/check_nrpe -H 10.20.2.34 -c check_files -a path='D:\\WSUS'
Erreur de segmentation


I wonder if this is not my nsclient.ini which is the cause of the problem.
cocoyanouck
 
Posts: 59
Joined: Fri Apr 08, 2016 3:17 am

Re: Check number of files on a directory

Postby tgriep » Tue May 30, 2017 12:55 pm

It seems that when the command option or an argument is specified for the check_nrpe command, that is when it fails so let's recompile the check_nrpe plugin by following this procedure.
Code: Select all
cd /home/nagios/nrpe-nrpe-3.1.0
./configure --enable-command-args
make check_nrpe
make install-plugin


Try that and see if it fixes the issue.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 6164
Joined: Thu Oct 30, 2014 9:02 am

PreviousNext

Return to Nagios Core

Who is online

Users browsing this forum: Google [Bot] and 14 guests