check_file_exists_glob ERROR: The FILE name must be specifie

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.
welbp00
Posts: 50
Joined: Fri Mar 08, 2019 5:48 am

Re: check_file_exists_glob ERROR: The FILE name must be spec

Post by welbp00 »

-d must be specified, to determine the directory where the file is...
welbp00
Posts: 50
Joined: Fri Mar 08, 2019 5:48 am

Re: check_file_exists_glob ERROR: The FILE name must be spec

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check_file_exists_glob ERROR: The FILE name must be spec

Post by scottwilkerson »

I don't believe it has that ability built-in but you could modify the script to suit your needs
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
welbp00
Posts: 50
Joined: Fri Mar 08, 2019 5:48 am

Re: check_file_exists_glob ERROR: The FILE name must be spec

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check_file_exists_glob ERROR: The FILE name must be spec

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
welbp00
Posts: 50
Joined: Fri Mar 08, 2019 5:48 am

Re: check_file_exists_glob ERROR: The FILE name must be spec

Post by welbp00 »

Thnx Scott,
I Will try this out Tomorrow, and let you know.

Regards,
Paul. :)
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check_file_exists_glob ERROR: The FILE name must be spec

Post by scottwilkerson »

welbp00 wrote:Thnx Scott,
I Will try this out Tomorrow, and let you know.

Regards,
Paul. :)
sounds good
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
welbp00
Posts: 50
Joined: Fri Mar 08, 2019 5:48 am

Re: check_file_exists_glob ERROR: The FILE name must be spec

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check_file_exists_glob ERROR: The FILE name must be spec

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked