check_dir_files plugin can't get to work on remote nrpe serv

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
gmills
Posts: 114
Joined: Wed Jun 12, 2019 2:08 pm

check_dir_files plugin can't get to work on remote nrpe serv

Post by gmills »

Hello, I need help, of course I'm still new to nagios, but, I've had tremendous success so far, thank you nagios and community

I am trying to get the plugin check_dir_files.sh to work on remote NRPE server. It works on localhost, the nagios server node.
it works manually by executing the command on both my servers, it works on nagios local system, I can't get it to work on remote server.

./check_dir_files.sh
Usage: check_dir_files.sh -d|--dirname [-w|--warning ] [-c|--critical ] [-f|--perfdata]
Usage: check_dir_files.sh -h|--help
Usage: check_dir_files.sh -V|--version

on nagios monitor server
commands.cfg
# 'check_local_dir_files' command definition
define command{
command_name check_local_dir_files
command_line $USER1$/check_dir_files.sh -d $ARG1$ -w $ARG2$ -c $ARG3$ -f
}

# 'check_dir_files' command definition
define command{
command_name check_dir_files
command_line $USER1$/check_dir_files.sh -H $HOSTADDRESS$ -d $ARG1$ -w $ARG2$ -c $ARG3$ -f
}

localhost.cfg
define service{
use local-service ; Name of service template to use
host_name localhost
service_description Inbound Directory Count - Noble
check_command check_local_dir_files!/GlobalScapeSftpRepo/Noble!10!100!
notifications_enabled 0
}
define service{
use local-service ; Name of service template to use
host_name localhost
service_description Inbound Directory Count - MSCommand
check_command check_local_dir_files!/GlobalScapeSftpRepo/MSCommand!10!100!
notifications_enabled 0
}
define service{
use local-service ; Name of service template to use
host_name localhost
service_description Inbound Directory Count - MaerskDrilling
check_command check_local_dir_files!/GlobalScapeSftpRepo/MaerskDrilling!10!100!
notifications_enabled 0
}
define service{
use local-service ; Name of service template to use
host_name localhost
service_description Inbound Directory Count - GCMS
check_command check_local_dir_files!/GlobalScapeSftpRepo/GCMS!10!100!
notifications_enabled 0
}
define service{
use local-service ; Name of service template to use
host_name localhost
service_description Inbound Directory Count - BPCRP
check_command check_local_dir_files!/GlobalScapeSftpRepo/BPCRP!10!100!
notifications_enabled 0
}
define service{
use local-service ; Name of service template to use
host_name localhost
service_description Inbound Directory Count - CoP_Alaska
check_command check_local_dir_files!/GlobalScapeSftpRepo/CoP_Alaska!10!100!
notifications_enabled 0
}

services.cfg
define service{
use local-service ; Name of service template to use
host_name localhost
service_description Inbound Directory Count - Noble
check_command check_nrpe!check_dir_files.sh!/GlobalScapeSftpRepo/Noble!10!100!
notifications_enabled 0
}
define service{
use local-service ; Name of service template to use
host_name localhost
service_description Inbound Directory Count - MSCommand
check_command check_nrpe!check_dir_files.sh!/GlobalScapeSftpRepo/MSCommand!10!100!
notifications_enabled 0
}
define service{
use local-service ; Name of service template to use
host_name localhost
service_description Inbound Directory Count - MaerskDrilling
check_command check_nrpe!check_dir_files.sh!/GlobalScapeSftpRepo/MaerskDrilling!10!100!
notifications_enabled 0
}
define service{
use local-service ; Name of service template to use
host_name localhost
service_description Inbound Directory Count - GCMS
check_command check_nrpe!check_dir_files.sh!/GlobalScapeSftpRepo/GCMS!10!100!
notifications_enabled 0
}
define service{
use local-service ; Name of service template to use
host_name localhost
service_description Inbound Directory Count - BPCRP
check_command check_nrpe!check_dir_files.sh!/GlobalScapeSftpRepo/BPCRP!10!100!
notifications_enabled 0
}
define service{
use local-service ; Name of service template to use
host_name localhost
service_description Inbound Directory Count - CoP_Alaska
check_command check_nrpe!check_dir_files.sh!/GlobalScapeSftpRepo/CoP_Alaska!10!100!
notifications_enabled 0
}
On NRPE server
nrpe.cfg

command[check_dir_files]=/usr/local/nagios/libexec/check_dir_files.sh -d $ARG1$ -w $ARG2$ -c $ARG3$ -f

it works manually on both machines manually
./check_dir_files.sh -d /GlobalScapeSftpRepo/Noble/ -w 10 -c 100 -f
OK - There are 1 files in dir /GlobalScapeSftpRepo/Noble/|'size'=1;10;100

hoping others have set this plugin up or knowledge is deeper than mine(newbie) :) thank you

I know it is something how the args are defined in statement because of below, execute on nagios server to nrpe server
./check_nrpe -H 3.36.24.89
NRPE v3.2.1

./check_nrpe -H 3.36.24.89 -c check_dir_files
OK - There are 0 files in dir -w
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check_dir_files plugin can't get to work on remote nrpe

Post by scottwilkerson »

you are so close

In your NRPE config you have this

Code: Select all

command[check_dir_files]=/usr/local/nagios/libexec/check_dir_files.sh -d $ARG1$ -w $ARG2$ -c $ARG3$ -f
this makes the NRPE command name check_dir_files however in your configs are passing check_dir_files.sh

that's problem one.

Problem 2 I cannot identify because you didn't post your check_nrpe command definition, so I have no way of knowing how the arguments should be passed, buy your commands would likely need to look something like this

Code: Select all

check_command check_nrpe!check_dir_files!-a '"/GlobalScapeSftpRepo/Noble" "10" "100"'!
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
gmills
Posts: 114
Joined: Wed Jun 12, 2019 2:08 pm

Re: check_dir_files plugin can't get to work on remote nrpe

Post by gmills »

thanks Scott, I will try this, hmmm, learning :) feels good. I totally neglected the abiltiy to separate the parameters like that and the -a option.

thanks so much, I'll be back to let you know...
gmills
Posts: 114
Joined: Wed Jun 12, 2019 2:08 pm

Re: check_dir_files plugin can't get to work on remote nrpe

Post by gmills »

Scott, thank you
I am still having issue on remote execution. here is my test command line. now to resemble what I just learned from you.

./check_nrpe -H 3.34.2.87 -c check_dir_files
OK - There are 0 files in dir -w

./check_nrpe -H 3.34.2.87 -c check_dir_files -a '"-f /GlobalScapeSftpRepo/Noble" "-s g" "-w 60" "-c 80"'
NRPE: Command 'check_dir_files!"-f /GlobalScapeSftpRepo/Noble" "-s g" "-w 60" "-c 80"' not defined

./check_nrpe -H 3.34.2.87 -c check_dir_files -a "-f /GlobalScapeSftpRepo/Noble" "-s g" "-w 60" "-c 80"
NRPE: Command 'check_dir_files!-f /GlobalScapeSftpRepo/Noble!-s g!-w 60!-c 80' not defined

./check_nrpe -H 3.34.2.87 -c check_dir_files -a "-f /GlobalScapeSftpRepo/Noble" "-s g" "-w 60" "-c 80" "-f"
NRPE: Command 'check_dir_files!-f /GlobalScapeSftpRepo/Noble!-s g!-w 60!-c 80!-f' not defined

Geese, some times I feel like an idiot, I thank you for your help. ???

Scott, I have enabled debugging, not sure how to read it
**** BEGIN MACRO PROCESSING ***********
Processing: 'check_dir_files'
Processing part: 'check_dir_files'
Not currently in macro. Running output (15): 'check_dir_files'
Done. Final output: 'check_dir_files'
**** END MACRO PROCESSING *************
**** BEGIN MACRO PROCESSING ***********
Processing: '-a '"/GlobalScapeSftpRepo/Noble" "10" "100"''
Processing part: '-a '"/GlobalScapeSftpRepo/Noble" "10" "100"''
Not currently in macro. Running output (44): '-a '"/GlobalScapeSftpRepo/Noble" "10" "100"''
Done. Final output: '-a '"/GlobalScapeSftpRepo/Noble" "10" "100"''
**** END MACRO PROCESSING *************
**** BEGIN MACRO PROCESSING ***********
Processing: '$USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$'
Processing part: ''
Not currently in macro. Running output (0): ''
Processing part: 'USER1'
Processed 'USER1', Free: 0
Processed 'USER1', Free: 0, Cleaning options: 3
Uncleaned macro. Running output (25): '/usr/local/nagios/libexec'
Just finished macro. Running output (25): '/usr/local/nagios/libexec'
Processing part: '/check_nrpe -H '
Not currently in macro. Running output (40): '/usr/local/nagios/libexec/check_nrpe -H '
Processing part: 'HOSTADDRESS'
Processed 'HOSTADDRESS', Free: 0
Processed 'HOSTADDRESS', Free: 0, Cleaning options: 3
Uncleaned macro. Running output (49): '/usr/local/nagios/libexec/check_nrpe -H 3.34.2.87'
Just finished macro. Running output (49): '/usr/local/nagios/libexec/check_nrpe -H 3.34.2.87'
Processing part: ' -c '
Not currently in macro. Running output (53): '/usr/local/nagios/libexec/check_nrpe -H 3.34.2.87 -c '
Processing part: 'ARG1'
Processed 'ARG1', Free: 0
Processed 'ARG1', Free: 0, Cleaning options: 3
Uncleaned macro. Running output (68): '/usr/local/nagios/libexec/check_nrpe -H 3.34.2.87 -c check_dir_files'
Just finished macro. Running output (68): '/usr/local/nagios/libexec/check_nrpe -H 3.34.2.87 -c check_dir_files'
Processing part: ''
Not currently in macro. Running output (68): '/usr/local/nagios/libexec/check_nrpe -H 3.34.2.87 -c check_dir_files'
Done. Final output: '/usr/local/nagios/libexec/check_nrpe -H 3.34.2.87 -c check_dir_files'
**** END MACRO PROCESSING *************


Last edited by gmills on Fri Jun 14, 2019 4:40 pm, edited 2 times in total.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check_dir_files plugin can't get to work on remote nrpe

Post by scottwilkerson »

Code: Select all

./check_nrpe -H 3.34.2.87 -c check_dir_files -a '"/GlobalScapeSftpRepo/Noble" "10" "100"'
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
gmills
Posts: 114
Joined: Wed Jun 12, 2019 2:08 pm

Re: check_dir_files plugin can't get to work on remote nrpe

Post by gmills »

./check_nrpe -H 3.34.2.87 -c check_dir_files -a '"/GlobalScapeSftpRepo/Noble" "10" "100"'
NRPE: Command 'check_dir_files!"/GlobalScapeSftpRepo/Noble" "10" "100"' not defined
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check_dir_files plugin can't get to work on remote nrpe

Post by scottwilkerson »

gmills wrote:./check_nrpe -H 3.34.2.87 -c check_dir_files -a '"/GlobalScapeSftpRepo/Noble" "10" "100"'
NRPE: Command 'check_dir_files!"/GlobalScapeSftpRepo/Noble" "10" "100"' not defined
Can you show your current command in nrpe.cfg?
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
gmills
Posts: 114
Joined: Wed Jun 12, 2019 2:08 pm

Re: check_dir_files plugin can't get to work on remote nrpe

Post by gmills »

NRPE server
command[check_dir_files]=/usr/local/nagios/libexec/check_dir_files.sh -d $ARG1$ -w $ARG2$ -c $ARG3$ -f


Nagios monitor server -

# 'check_dir_files' command definition
define command{
command_name check_dir_files
command_line $USER1$/check_dir_files -d $ARG1$ -w $ARG2$ -c $ARG3$ -f
}


Services.cfg
define service{
use local-service ; Name of service template to use
host_name alphprdfuse1i
service_description Inbound Dir Count Noble
check_command check_nrpe!check_dir_files!-a '"/GlobalScapeSftpRepo/Noble" "10" "100"'
notifications_enabled 0
}



Scott, interestingly I am looking in the nagios logs on the NRPR server and it looks that the parameters are not being passed or transfered over from the nagios server issuing the command on the NRPE server

from log on NRPE server
is_an_allowed_host (AF_INET): is host >3.239.245.209< an allowed host >3.239.245.209<
[1560743224] is_an_allowed_host (AF_INET): host is in allowed host list!
[1560743224] Host address is in allowed_hosts
[1560743224] Host 3.239.245.209 is asking for command 'check_dir_files' to be run...
[1560743224] Running command: /usr/local/nagios/libexec/check_dir_files.sh -d -w -c -f
[1560743224] Command completed with return code 0 and output: OK - There are 0 files in dir -w
[1560743224] Return Code: 0, Output: OK - There are 0 files in dir -w
[1560743224] Connection from 3.239.245.209 closed.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check_dir_files plugin can't get to work on remote nrpe

Post by scottwilkerson »

Do you have COMMAND ARGUMENT PROCESSING enabled in the nrpe.cfg?

Code: Select all

grep dont_blame_nrpe nrpe.cfg
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
gmills
Posts: 114
Joined: Wed Jun 12, 2019 2:08 pm

Re: check_dir_files plugin can't get to work on remote nrpe

Post by gmills »

dont_blame_nrpe=1

allow_bash_command_substitution=1
Locked