Page 2 of 6

Re: Plugins Helps

Posted: Mon Jul 25, 2016 9:19 pm
by Box293
On your Nagios server, you need to create the .cfg file that you want to store the host and service definitions in. Simply create the file and paste the example definition into the file.

What the article doesn't show is you need to edit the nagios.cfg file to point to the file, for example:
cfg_file=/etc/nagios/objects/nrpe.cfg
kwhogster wrote:My NRPE.CFG file is located here /etc/Nagios/nrpe.cfg
This file may be the NRPE daemon config file if you installed NRPE on the Nagios Server as well. If that is the case it serves a different purpose, don't put your service definitions in there.

Does that help?

Re: Plugins Helps

Posted: Mon Jul 25, 2016 9:51 pm
by kwhogster
root@TGCS017:/etc/nagios/objects# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Nagios Core 4.1.1
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-19-2015
License: GPL

Website: https://www.nagios.org
Reading configuration data...
Read main config file okay...
Warning: Duplicate definition found for host 'TGCS011' (config file '/etc/nagios/objects/nrpe.cfg', starting on line 11)
Error: Could not add object property in file '/etc/nagios/objects/nrpe.cfg' on line 13.
Error processing object config files!


***> One or more problems was encountered while processing the config files...

Check your configuration file(s) to ensure that they contain valid
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
'Whats New' section to find out what has changed.



All my hosts are defined in my windows.cfg file for Nagios


This is the nrpe.cfg file I created in etc/Nagios/objects


#######################################################################################################
#
# NRPE.CFG
#
# Defined Hosts and Services for the Ngios Plugins
#
#######################################################################################################

# Define Plugin Hosts

define host{
use Windows-server ; Inherit default values from a template
host_name TGCS011 ; The name we're giving to this host
alias Windows 2012 DC ; A longer name associated with the host
address 10.2.8.30 ; IP address of the host
}


# Define Plugin Services

define service {
host_name TGCS011
service_description Check Disk Usage
check_command check_nrpe!check_disk_space! -v -w 80 -c 90 -p C
check_interval 1
use generic-service
}

Re: Plugins Helps

Posted: Mon Jul 25, 2016 10:16 pm
by Box293
Can you please uplload the file /etc/nagios/objects/nrpe.cfg here as an attachment.

I know you pasted the contents of it in your post however there may be something unusual in the file and getting a copy of the actual file can help.

Can you also run the more verbose option and report the output (-vv )

Code: Select all

/usr/local/nagios/bin/nagios -vv /usr/local/nagios/etc/nagios.cfg

Re: Plugins Helps

Posted: Mon Jul 25, 2016 10:25 pm
by kwhogster
See attached

Also here is the -vv output

root@TGCS017:~# /usr/local/nagios/bin/nagios -vv /usr/local/nagios/etc/nagios.cfg

Nagios Core 4.1.1
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-19-2015
License: GPL

Website: https://www.nagios.org
Reading configuration data...
Read main config file okay...
Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/contacts.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/localhost.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/windows.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/computer.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/switch.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/printer.cfg'...
Processing object config file '/etc/nagios/objects/nrpe.cfg'...
Warning: Duplicate definition found for host 'TGCS011' (config file '/etc/nagios/objects/nrpe.cfg', starting on line 11)
Error: Could not add object property in file '/etc/nagios/objects/nrpe.cfg' on line 13.
Error processing object config files!


***> One or more problems was encountered while processing the config files...

Check your configuration file(s) to ensure that they contain valid
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
'Whats New' section to find out what has changed.


HTH

Re: Plugins Helps

Posted: Mon Jul 25, 2016 10:52 pm
by Box293
The file seems OK, however the verbose output is telling us that you've already defined this host.

What is the output of this command:

Code: Select all

grep -R TGCS011 /usr/local/nagios/etc/*
It will report which file already has it defined. Can you post that file here please.

This might be a permissions issue. I suggest moving the from from:
/etc/nagios/objects/
To:
/usr/local/nagios/etc/objects/

You will also need to update nagios.cfg.

Re: Plugins Helps

Posted: Tue Jul 26, 2016 7:24 am
by kwhogster
root@TGCS017:~# grep -R TGCS011 /usr/local/nagios/etc/*
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011 ; The name we're giving to this host
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg:# Create a service for monitoring the System services on TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
/usr/local/nagios/etc/objects/windows.cfg: host_name TGCS011
root@TGCS017:~#

Moved nrpe.cfg to /usr/local/Nagios/etc/objects

Made it same permissions as other .cfg files

Same error

root@TGCS017:/usr/local/nagios/etc/objects# /usr/local/nagios/bin/nagios -vv /usr/local/nagios/etc/nagios.cfg

Nagios Core 4.1.1
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-19-2015
License: GPL

Website: https://www.nagios.org
Reading configuration data...
Read main config file okay...
Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/contacts.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/localhost.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/windows.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/computer.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/switch.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/printer.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/nrpe.cfg'...
Warning: Duplicate definition found for host 'TGCS011' (config file '/usr/local/nagios/etc/objects/nrpe.cfg', starting on line 11)
Error: Could not add object property in file '/usr/local/nagios/etc/objects/nrpe.cfg' on line 13.
Error processing object config files!


***> One or more problems was encountered while processing the config files...

Check your configuration file(s) to ensure that they contain valid
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
'Whats New' section to find out what has changed.

root@TGCS017:/usr/local/nagios/etc/objects#


root@TGCS017:/usr/local/nagios/etc/objects# ls -ltr /usr/local/nagios/etc/objects/
total 212
-rw-rw-r-- 1 nagios nagios 10621 Jul 22 19:23 templates.cfg
-rw-rw-r-- 1 nagios nagios 5375 Jul 22 19:23 localhost.cfg
-rw-rw-r-- 1 nagios nagios 3991 Jul 22 19:23 windows.org
-rw-rw-r-- 1 nagios nagios 3265 Jul 22 19:23 switch.org
-rw-rw-r-- 1 nagios nagios 2365 Jul 22 20:41 contacts.cfg
-rw-rw-r-- 1 nagios nagios 3632 Jul 23 08:55 timeperiods.cfg
-rw-rw-r-- 1 nagios nagios 3567 Jul 23 09:14 printer.cfg
-rw-rw-r-- 1 root root 15500 Jul 23 10:26 computer.cfg
-rw-rw-r-- 1 root root 4907 Jul 23 18:01 switch.cfg
-rw-rw-r-- 1 root root 137225 Jul 23 18:02 windows.cfg
-rw-rw-r-- 1 nagios nagios 8053 Jul 25 20:14 commands.cfg
-rw-rw-r-- 1 root root 991 Jul 25 23:22 nrpe.cfg



I figured it out

I removed the Host definition in NRPE.CFG

Now the verify ran successful

I restarted NAGIOS service

And now the service for the plugin shows

But it failed with this

(No output on stdout) stderr: execvp(/usr/lib/nagios/plugins/check_nrpe, ...) failed. errno is 2: No such file or directory

Do I need to restart NRPE service also???

Thoughts

Re: Plugins Helps

Posted: Tue Jul 26, 2016 10:02 am
by rkennedy

Code: Select all

(No output on stdout) stderr: execvp(/usr/lib/nagios/plugins/check_nrpe, ...) failed. errno is 2: No such file or directory 
Where are your plugins located? It looks like before you were referencing /usr/local/nagios/, and your commands are referencing /usr/lib/nagios/. You'll need to update your command definition for NRPE to be to the correct location.

Re: Plugins Helps

Posted: Tue Jul 26, 2016 2:09 pm
by kwhogster
Plugins are located here

/usr/lib/nagios/plugins

Re: Plugins Helps

Posted: Tue Jul 26, 2016 8:46 pm
by kwhogster
Update

Now getting this error

(Return code of 13 is out of bounds)

Made two changes

command_line /usr/lib/nagios/plugins/check_nrpe.cfg -H '$HOSTADDRESS$' -c '$ARG1$'

command_line /usr/lib/nagios/plugins/check_nrpe.cfg -H '$HOSTADDRESS$' -c '$ARG1$'


FILE NAME WAS THE ERROR I JUST HAD CHECK_NRPE NOW CHECK_NRPE.CFG


check_nrpe.cfg /usr/lib/nagios/plugins

# # the default command is overwritten ##
define command{
command_name check_nrpe
command_line /usr/lib/nagios/plugins/check_nrpe.cfg -H '$HOSTADDRESS$' -c '$ARG1$'
}


NRPE.CFG /usr/local/nagios/etc/objects

#######################################################################################################
#
# NRPE.CFG
#
# Defined Hosts and Services for the Ngios Plugins
#
#######################################################################################################

# Define Plugin Hosts


# Define Plugin Services

define service {
host_name TGCS011
service_description Check Disk Usage
check_command check_nrpe!check_disk_space! -v -w 80 -c 90 -p C
check_interval 1
use generic-service
}


commands.cfg /usr/local/nagios/etc/objects/


#################################################################################
# Defining Nagios Command for NRPE Plugin
#
################################################################################

define command{
command_name check_nrpe
command_line /usr/lib/nagios/plugins/check_nrpe.cfg -H '$HOSTADDRESS$' -c '$ARG1$'
}


Getting closer I think

Re: Plugins Helps

Posted: Tue Jul 26, 2016 9:00 pm
by Box293
Using /usr/lib/nagios/plugins/check_nrpe.cfg won't work.

What is the output of this command:

Code: Select all

find / -name check_nrpe