Page 2 of 2

Re: check_file_exists_glob ERROR: The FILE name must be spec

Posted: Tue Apr 09, 2019 8:30 am
by welbp00
-d must be specified, to determine the directory where the file is...

Re: check_file_exists_glob ERROR: The FILE name must be spec

Posted: Tue Apr 09, 2019 1:05 pm
by welbp00
Hi Scott,
i've tried another script:

https://exchange.nagios.org/directory/P ... ts/details


check_command check_file_exists!/waslog/core*


define service {

use generic-service

host_name {{ connectpeople.addon1.name }}

check_interval 300

service_description Check File Exists

check_command check_file_exists!/waslog/core*






define command{

command_name check_file_exists

command_line /usr/lib64/nagios/plugins/check_nrpe -H '$HOSTADDRESS$' -c check_file_exists -a '-n $ARG1$'
}


nrpe.cfg:

command[check_file_exists]=/usr/lib64/nagios/plugins/check_file_exists -n $ARG1$

It seems to be working. I have to test it a little bit more. Do you know this script? Is it possible to let it search for several files, or do i have to make several commands?

Regards,

Paul.

Re: check_file_exists_glob ERROR: The FILE name must be spec

Posted: Tue Apr 09, 2019 4:35 pm
by scottwilkerson
I don't believe it has that ability built-in but you could modify the script to suit your needs

Re: check_file_exists_glob ERROR: The FILE name must be spec

Posted: Wed Apr 10, 2019 9:58 am
by welbp00
Does anyone know how to adjust the script so nagios can monitor several files?
I want to monitor javacore, core and heap.dmp files. Recieve a warning if one of these files appears in de dir /waslog.
The script works nog for just one file-name...

Thnx,

Paul.

Re: check_file_exists_glob ERROR: The FILE name must be spec

Posted: Wed Apr 10, 2019 12:36 pm
by scottwilkerson
Here's a freebie based on you specifications.

Code: Select all

#! /bin/bash
#
# Author : Scott Wilkerson (Nagios Enterprises)
#

PROGNAME=`basename $0`
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`

. $PROGPATH/utils.sh

if [ `ls -l /waslog/{javacore,core,heap.dmp} 2>/dev/null | wc -l ` -gt 0 ]
then
        echo "CRITICAL - /waslog/{javacore,core,heap.dmp}  : EXISTS"
        exit $STATE_CRITICAL
else
        echo "OK : /waslog/{javacore,core,heap.dmp} Does NOT exists "
        exit $STATE_OK
fi
Please note, we do not always write custom plugins for people but this one seemed easy enough.

Any required modification will be yours to figure out

Re: check_file_exists_glob ERROR: The FILE name must be spec

Posted: Wed Apr 10, 2019 1:55 pm
by welbp00
Thnx Scott,
I Will try this out Tomorrow, and let you know.

Regards,
Paul. :)

Re: check_file_exists_glob ERROR: The FILE name must be spec

Posted: Wed Apr 10, 2019 2:49 pm
by scottwilkerson
welbp00 wrote:Thnx Scott,
I Will try this out Tomorrow, and let you know.

Regards,
Paul. :)
sounds good

Re: check_file_exists_glob ERROR: The FILE name must be spec

Posted: Thu Apr 11, 2019 9:05 am
by welbp00
Hi Scott.

It works fine! Just changed the file-names with a wildcard: /waslog/{javacore*,core*,heap*

nrpe.cfg:
command[check_file_exists]=/usr/lib64/nagios/plugins/check_file_exists $ARG1$

cfg:

define command{
command_name check_file_exists
command_line /usr/lib64/nagios/plugins/check_nrpe -H '$HOSTADDRESS$' -c check_file_exists -a '$ARG1$'
}

Thnx so much for your patience and help!

Best regards,

Paul.

Re: check_file_exists_glob ERROR: The FILE name must be spec

Posted: Thu Apr 11, 2019 9:24 am
by scottwilkerson
welbp00 wrote:Hi Scott.

It works fine! Just changed the file-names with a wildcard: /waslog/{javacore*,core*,heap*

nrpe.cfg:
command[check_file_exists]=/usr/lib64/nagios/plugins/check_file_exists $ARG1$

cfg:

define command{
command_name check_file_exists
command_line /usr/lib64/nagios/plugins/check_nrpe -H '$HOSTADDRESS$' -c check_file_exists -a '$ARG1$'
}

Thnx so much for your patience and help!

Best regards,

Paul.
Glad you got it working!

Locking thread